From 16bb29f29c19f481b2d5ea799090d3124a47193c Mon Sep 17 00:00:00 2001 From: Mateusz Tabaka Date: Mon, 2 Nov 2020 10:22:01 +0100 Subject: [PATCH] Remove obsoleted v0::StopGradient op (#2935) --- .../common_optimizations/nop_elimination.cpp | 6 --- .../transformations/nop_elimination.cpp | 13 ------ ngraph/core/include/ngraph/op/op_version_tbl.hpp | 1 - ngraph/core/include/ngraph/op/stop_gradient.hpp | 51 ---------------------- ngraph/core/include/ngraph/ops.hpp | 1 - ngraph/core/src/op/stop_gradient.cpp | 37 ---------------- ngraph/test/eval.cpp | 1 - ngraph/test/op_is.cpp | 9 ---- ngraph/test/runtime/interpreter/int_executable.hpp | 1 - ngraph/test/runtime/opset0_tbl.hpp | 1 - 10 files changed, 121 deletions(-) delete mode 100644 ngraph/core/include/ngraph/op/stop_gradient.hpp delete mode 100644 ngraph/core/src/op/stop_gradient.cpp diff --git a/inference-engine/src/transformations/src/transformations/common_optimizations/nop_elimination.cpp b/inference-engine/src/transformations/src/transformations/common_optimizations/nop_elimination.cpp index 4da31e8..0514b74 100644 --- a/inference-engine/src/transformations/src/transformations/common_optimizations/nop_elimination.cpp +++ b/inference-engine/src/transformations/src/transformations/common_optimizations/nop_elimination.cpp @@ -332,18 +332,12 @@ static bool eliminate_squeeze(const std::shared_ptr& node) { return false; } -static bool eliminate_stop_gradient(const std::shared_ptr& node) { - replace_output_update_name(node->output(0), node->input_value(0)); - return true; -} - bool pass::NopElimination::run_on_function(std::shared_ptr function) { static const std::unordered_map&)>> dispatcher{{TI(opset3::Pad), &eliminate_nop}, {TI(op::v0::Sum), &eliminate_sum}, {TI(opset3::Convert), &eliminate_convert}, {TI(op::v0::Slice), &eliminate_nop}, - {TI(op::v0::StopGradient), &eliminate_stop_gradient}, {TI(opset3::Reshape), &eliminate_reshape_v1}, {TI(opset3::Concat), &eliminate_concat}, {TI(opset3::Squeeze), &eliminate_squeeze}, diff --git a/inference-engine/tests/functional/inference_engine/transformations/nop_elimination.cpp b/inference-engine/tests/functional/inference_engine/transformations/nop_elimination.cpp index 9d2f1d0..f9d9560 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/nop_elimination.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/nop_elimination.cpp @@ -97,19 +97,6 @@ TEST(nop_elimination, eliminate_broadcast) { ASSERT_EQ(count_ops_of_type(f), 0); } -TEST(nop_elimination, eliminate_stop_gradient) { - Shape shape{}; - auto A = make_shared(element::f32, shape); - auto s = make_shared(A); - auto f = make_shared(make_shared(s), ParameterVector{A}); - - pass::Manager pass_manager; - pass_manager.register_pass(); - pass_manager.run_passes(f); - - ASSERT_EQ(count_ops_of_type(f), 0); -} - TEST(nop_elimination, pass_property) { auto pass = std::make_shared(); ASSERT_FALSE(pass->get_property(pass::PassProperty::CHANGE_DYNAMIC_STATE)); diff --git a/ngraph/core/include/ngraph/op/op_version_tbl.hpp b/ngraph/core/include/ngraph/op/op_version_tbl.hpp index d61062c..5250072 100644 --- a/ngraph/core/include/ngraph/op/op_version_tbl.hpp +++ b/ngraph/core/include/ngraph/op/op_version_tbl.hpp @@ -174,7 +174,6 @@ NGRAPH_OP(Split, ngraph::op::v0, 0) NGRAPH_OP(Sqrt, ngraph::op::v0, 0) NGRAPH_OP(SquaredDifference, ngraph::op::v0, 0) NGRAPH_OP(Squeeze, ngraph::op::v0, 0) -NGRAPH_OP(StopGradient, ngraph::op::v0, 0) NGRAPH_OP(StridedSlice, ngraph::op::v1, 1) NGRAPH_OP(Subtract, ngraph::op::v0, 0) NGRAPH_OP(Subtract, ngraph::op::v1, 1) diff --git a/ngraph/core/include/ngraph/op/stop_gradient.hpp b/ngraph/core/include/ngraph/op/stop_gradient.hpp deleted file mode 100644 index 057aa9a..0000000 --- a/ngraph/core/include/ngraph/op/stop_gradient.hpp +++ /dev/null @@ -1,51 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2020 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#pragma once - -#include "ngraph/op/util/unary_elementwise_arithmetic.hpp" - -namespace ngraph -{ - namespace op - { - namespace v0 - { - /// \brief create StopGrdient op - class NGRAPH_DEPRECATED( - "This operation is deprecated and will be removed soon. Please do not use it.") - NGRAPH_API StopGradient : public util::UnaryElementwiseArithmetic - { - NGRAPH_SUPPRESS_DEPRECATED_START - public: - static constexpr NodeTypeInfo type_info{"StopGradient", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - /// \brief Constructs StopGradient - /// - /// \param arg Node that produces the input tensor. - StopGradient(const Output& arg); - StopGradient() = default; - - virtual std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - NGRAPH_SUPPRESS_DEPRECATED_END - }; - } - NGRAPH_SUPPRESS_DEPRECATED_START - using v0::StopGradient; - NGRAPH_SUPPRESS_DEPRECATED_END - } -} diff --git a/ngraph/core/include/ngraph/ops.hpp b/ngraph/core/include/ngraph/ops.hpp index 07c63a2..90b2e68 100644 --- a/ngraph/core/include/ngraph/ops.hpp +++ b/ngraph/core/include/ngraph/ops.hpp @@ -155,7 +155,6 @@ #include "ngraph/op/sqrt.hpp" #include "ngraph/op/squared_difference.hpp" #include "ngraph/op/squeeze.hpp" -#include "ngraph/op/stop_gradient.hpp" #include "ngraph/op/strided_slice.hpp" #include "ngraph/op/subtract.hpp" #include "ngraph/op/sum.hpp" diff --git a/ngraph/core/src/op/stop_gradient.cpp b/ngraph/core/src/op/stop_gradient.cpp deleted file mode 100644 index ca8a8f2..0000000 --- a/ngraph/core/src/op/stop_gradient.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//***************************************************************************** -// Copyright 2017-2020 Intel Corporation -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -//***************************************************************************** - -#include "ngraph/op/stop_gradient.hpp" -#include "ngraph/op/broadcast.hpp" - -NGRAPH_SUPPRESS_DEPRECATED_START - -using namespace std; -using namespace ngraph; - -constexpr NodeTypeInfo op::StopGradient::type_info; - -op::StopGradient::StopGradient(const Output& arg) - : UnaryElementwiseArithmetic(arg) -{ - constructor_validate_and_infer_types(); -} - -shared_ptr op::StopGradient::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args.at(0)); -} diff --git a/ngraph/test/eval.cpp b/ngraph/test/eval.cpp index 25cdcad..6632f08 100644 --- a/ngraph/test/eval.cpp +++ b/ngraph/test/eval.cpp @@ -62,7 +62,6 @@ #include "ngraph/op/sinh.hpp" #include "ngraph/op/sqrt.hpp" #include "ngraph/op/squeeze.hpp" -#include "ngraph/op/stop_gradient.hpp" #include "ngraph/op/tan.hpp" #include "ngraph/op/tanh.hpp" #include "ngraph/op/topk.hpp" diff --git a/ngraph/test/op_is.cpp b/ngraph/test/op_is.cpp index 04c5593..df2ce0f 100644 --- a/ngraph/test/op_is.cpp +++ b/ngraph/test/op_is.cpp @@ -830,15 +830,6 @@ namespace EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); } - void op_is_StopGradient() - { - op::StopGradient node; - EXPECT_TRUE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - void op_is_Subtract() { op::Subtract node; diff --git a/ngraph/test/runtime/interpreter/int_executable.hpp b/ngraph/test/runtime/interpreter/int_executable.hpp index 0da1ba0..6c27f43 100644 --- a/ngraph/test/runtime/interpreter/int_executable.hpp +++ b/ngraph/test/runtime/interpreter/int_executable.hpp @@ -1463,7 +1463,6 @@ protected: case OP_TYPEID::SpaceToDepth: case OP_TYPEID::Split: case OP_TYPEID::SquaredDifference: - case OP_TYPEID::StopGradient: case OP_TYPEID::TensorIterator: case OP_TYPEID::Tile: case OP_TYPEID::UnknownOp: diff --git a/ngraph/test/runtime/opset0_tbl.hpp b/ngraph/test/runtime/opset0_tbl.hpp index e8f6f80..c206bf0 100644 --- a/ngraph/test/runtime/opset0_tbl.hpp +++ b/ngraph/test/runtime/opset0_tbl.hpp @@ -126,7 +126,6 @@ NGRAPH_OP(Split, ngraph::op) NGRAPH_OP(Sqrt, ngraph::op) NGRAPH_OP(SquaredDifference, ngraph::op) NGRAPH_OP(Squeeze, ngraph::op) -NGRAPH_OP(StopGradient, ngraph::op) NGRAPH_OP(Subtract, ngraph::op) NGRAPH_OP(Sum, ngraph::op) NGRAPH_OP(Tan, ngraph::op) -- 2.7.4