From 141b24cf4493b5f84ecea138208e868eac3b8f35 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Wed, 22 Jul 2020 13:44:22 +0300 Subject: [PATCH] Replaced copy_with_new_args() to clone_with_new_inputs() (#1395) --- .../IE_DG/Extensibility_DG/AddingNGraphOps.md | 6 ++--- docs/template_extension/op.cpp | 2 +- docs/template_extension/op.hpp | 2 +- .../reshape_ssd_extension.hpp | 2 +- .../src/inference_engine/generic_ie.cpp | 7 +----- .../src/plugin_api/generic_ie.hpp | 7 +----- .../include/ngraph_ops/crop_ie.hpp | 2 +- .../include/ngraph_ops/eltwise.hpp | 2 +- .../include/ngraph_ops/fully_connected.hpp | 2 +- .../include/ngraph_ops/gather_tree_ie.hpp | 2 +- .../include/ngraph_ops/gru_cell_ie.hpp | 2 +- .../include/ngraph_ops/hard_sigmoid_ie.hpp | 2 +- .../include/ngraph_ops/interp.hpp | 4 +-- .../include/ngraph_ops/lrn_ie.hpp | 2 +- .../include/ngraph_ops/lstm_cell_ie.hpp | 2 +- .../include/ngraph_ops/normalize_ie.hpp | 2 +- .../include/ngraph_ops/onehot_ie.hpp | 2 +- .../include/ngraph_ops/pad_ie.hpp | 2 +- .../include/ngraph_ops/power.hpp | 2 +- .../include/ngraph_ops/proposal_ie.hpp | 2 +- .../include/ngraph_ops/relu_ie.hpp | 2 +- .../include/ngraph_ops/rnn_cell_ie.hpp | 2 +- .../include/ngraph_ops/scaleshift.hpp | 2 +- .../include/ngraph_ops/selu_ie.hpp | 2 +- .../include/ngraph_ops/tile_ie.hpp | 2 +- .../src/ngraph_ops/crop_ie.cpp | 2 +- .../src/ngraph_ops/eltwise.cpp | 2 +- .../src/ngraph_ops/fully_connected.cpp | 2 +- .../src/ngraph_ops/gather_tree_ie.cpp | 2 +- .../src/ngraph_ops/gru_cell_ie.cpp | 2 +- .../src/ngraph_ops/hard_sigmoid_ie.cpp | 2 +- .../transformations/src/ngraph_ops/interp.cpp | 4 +-- .../transformations/src/ngraph_ops/lrn_ie.cpp | 2 +- .../src/ngraph_ops/lstm_cell_ie.cpp | 2 +- .../src/ngraph_ops/normalize_ie.cpp | 2 +- .../src/ngraph_ops/onehot_ie.cpp | 2 +- .../transformations/src/ngraph_ops/pad_ie.cpp | 2 +- .../transformations/src/ngraph_ops/power.cpp | 2 +- .../src/ngraph_ops/proposal_ie.cpp | 2 +- .../src/ngraph_ops/relu_ie.cpp | 2 +- .../src/ngraph_ops/rnn_cell_ie.cpp | 4 +-- .../src/ngraph_ops/scaleshift.cpp | 2 +- .../src/ngraph_ops/selu_ie.cpp | 2 +- .../src/ngraph_ops/tile_ie.cpp | 2 +- .../operations/dynamic_shape_resolver.hpp | 2 +- .../operations/static_shape_nonzero.hpp | 2 +- .../operations/dynamic_shape_resolver.cpp | 2 +- .../operations/static_shape_nonzero.cpp | 4 +-- .../extension_lib/include/extension.hpp | 2 +- .../ngraph_reader/abs_tests.cpp | 2 +- .../inference_engine/ngraph_reshape_tests.cpp | 2 +- .../extensions_tests/extensions_test.cpp | 2 +- ngraph/changes.md | 1 - .../frontend/onnx_import/core/null_node.cpp | 3 ++- .../frontend/onnx_import/core/null_node.hpp | 2 +- ngraph/src/ngraph/node.cpp | 25 ------------------- ngraph/src/ngraph/node.hpp | 11 ++------ ngraph/src/ngraph/op/fused/fake_quantize.cpp | 12 --------- ngraph/src/ngraph/op/fused/fake_quantize.hpp | 6 ----- ngraph/src/ngraph/op/transpose.cpp | 6 ----- ngraph/src/ngraph/op/transpose.hpp | 3 --- ngraph/src/ngraph/pattern/op/pattern.hpp | 2 +- ngraph/test/op.cpp | 18 ------------- 63 files changed, 64 insertions(+), 151 deletions(-) diff --git a/docs/IE_DG/Extensibility_DG/AddingNGraphOps.md b/docs/IE_DG/Extensibility_DG/AddingNGraphOps.md index 8c181062cb6..263d3b90afd 100644 --- a/docs/IE_DG/Extensibility_DG/AddingNGraphOps.md +++ b/docs/IE_DG/Extensibility_DG/AddingNGraphOps.md @@ -12,7 +12,7 @@ To add your custom nGraph operation, create a new class that extends `ngraph::Op 3. Override the shape inference method `validate_and_infer_types`. This method is called multiple times during graph manipulations to determine the shapes and element types of the outputs of the operations. You can access the input shapes through the `get_input_partial_shape()` method and input element types through the `get_input_element_type()` method of `ngraph::Node`. Set the inferred shape and element type of the output using `set_output_type`. -4. Override the `copy_with_new_args` method, which allows graph manipulation routines to create copies of this operation and connect it to different nodes during optimization. +4. Override the `clone_with_new_inputs` method, which allows graph manipulation routines to create copies of this operation and connect it to different nodes during optimization. 5. Override the `visit_attributes` method, which allows serialization and deserialization of attributes. An `AttributeVisitor` is passed to the method, and the implementation is expected to walk over all the attributes in the op using the type-aware `on_attribute` helper. Helpers are already implemented for standard C++ types like `int64_t`, `float`, `bool`, `vector` and for existing nGraph defined types. @@ -39,9 +39,9 @@ nGraph operation contains two constructors: a default constructor, which allows @snippet op.cpp op:validate -### `copy_with_new_args()` +### `clone_with_new_inputs()` -`ngraph::Node::copy_with_new_args` method creates a copy of nGraph operation with new inputs. +`ngraph::Node::clone_with_new_inputs` method creates a copy of nGraph operation with new inputs. @snippet op.cpp op:copy diff --git a/docs/template_extension/op.cpp b/docs/template_extension/op.cpp index 2939138ebd5..8e450eb6c2e 100644 --- a/docs/template_extension/op.cpp +++ b/docs/template_extension/op.cpp @@ -21,7 +21,7 @@ void Operation::validate_and_infer_types() { //! [op:validate] //! [op:copy] -std::shared_ptr Operation::copy_with_new_args(const ngraph::NodeVector &new_args) const { +std::shared_ptr Operation::clone_with_new_inputs(const ngraph::OutputVector &new_args) const { if (new_args.size() != 1) { throw ngraph::ngraph_error("Incorrect number of new arguments"); } diff --git a/docs/template_extension/op.hpp b/docs/template_extension/op.hpp index f56b36e4db6..beb03601241 100644 --- a/docs/template_extension/op.hpp +++ b/docs/template_extension/op.hpp @@ -17,7 +17,7 @@ public: Operation() = default; Operation(const ngraph::Output& arg, int64_t add); void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const ngraph::NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override; bool visit_attributes(ngraph::AttributeVisitor& visitor) override; int64_t getAddAttr() { return add; } diff --git a/inference-engine/samples/hello_reshape_ssd/reshape_ssd_extension.hpp b/inference-engine/samples/hello_reshape_ssd/reshape_ssd_extension.hpp index 3f0eeae08f9..6c44f575140 100644 --- a/inference-engine/samples/hello_reshape_ssd/reshape_ssd_extension.hpp +++ b/inference-engine/samples/hello_reshape_ssd/reshape_ssd_extension.hpp @@ -107,7 +107,7 @@ public: set_output_type(0, get_input_element_type(0), ngraph::PartialShape(output_shape)); } - std::shared_ptr copy_with_new_args(const ngraph::NodeVector& new_args) const override { + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override { if (new_args.size() != 1) { throw ngraph::ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/src/inference_engine/generic_ie.cpp b/inference-engine/src/inference_engine/generic_ie.cpp index d1c45f20d4b..b26a61922b2 100644 --- a/inference-engine/src/inference_engine/generic_ie.cpp +++ b/inference-engine/src/inference_engine/generic_ie.cpp @@ -57,11 +57,6 @@ std::vector ngraph::op::GenericIE::get return extensions; } -ngraph::op::GenericIE::GenericIE(const ngraph::NodeVector& inputs, - const std::map& params, - const std::string type, const std::vector& outputs) - : GenericIE(as_output_vector(inputs), params, type, outputs) {} - ngraph::op::GenericIE::GenericIE(const ngraph::OutputVector& inputs, const std::map& params_, const std::string type_, const std::vector& outputs_) @@ -69,7 +64,7 @@ ngraph::op::GenericIE::GenericIE(const ngraph::OutputVector& inputs, constructor_validate_and_infer_types(); } -std::shared_ptr ngraph::op::GenericIE::copy_with_new_args(const ngraph::NodeVector& new_args) const { +std::shared_ptr ngraph::op::GenericIE::clone_with_new_inputs(const ngraph::OutputVector& new_args) const { auto genNode = std::make_shared(new_args, params, type, outputs); genNode->extensions = extensions; genNode->reshape = reshape; diff --git a/inference-engine/src/plugin_api/generic_ie.hpp b/inference-engine/src/plugin_api/generic_ie.hpp index bad38b21ef7..fbe4aea610a 100644 --- a/inference-engine/src/plugin_api/generic_ie.hpp +++ b/inference-engine/src/plugin_api/generic_ie.hpp @@ -87,11 +87,6 @@ public: * @param type string with original layer type * @param outputs information about output ports from IR */ - GenericIE(const NodeVector& inputs, - const std::map& params, - const std::string type, - const std::vector& outputs); - GenericIE(const OutputVector& inputs, const std::map& params, const std::string type, @@ -99,7 +94,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; static void addExtension(std::shared_ptr func, const InferenceEngine::IShapeInferExtensionPtr& ext); static std::vector getExtensions(std::shared_ptr func); diff --git a/inference-engine/src/transformations/include/ngraph_ops/crop_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/crop_ie.hpp index c33fcc71d87..9677e75231a 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/crop_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/crop_ie.hpp @@ -26,7 +26,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; std::vector axes, dim, offset; }; diff --git a/inference-engine/src/transformations/include/ngraph_ops/eltwise.hpp b/inference-engine/src/transformations/include/ngraph_ops/eltwise.hpp index 9aa84242d47..660c574f43c 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/eltwise.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/eltwise.hpp @@ -26,7 +26,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; ELTWISE_TYPE eltwise_type; }; diff --git a/inference-engine/src/transformations/include/ngraph_ops/fully_connected.hpp b/inference-engine/src/transformations/include/ngraph_ops/fully_connected.hpp index ca28925720c..4471e8a7cb5 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/fully_connected.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/fully_connected.hpp @@ -33,7 +33,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; size_t get_out_size() { return m_output_size; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/gather_tree_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/gather_tree_ie.hpp index 54c12407531..88840f59b23 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/gather_tree_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/gather_tree_ie.hpp @@ -33,7 +33,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace op diff --git a/inference-engine/src/transformations/include/ngraph_ops/gru_cell_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/gru_cell_ie.hpp index 8d4fd019f9b..6418ab7e323 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/gru_cell_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/gru_cell_ie.hpp @@ -33,7 +33,7 @@ public: GRUCellIE() = delete; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; std::size_t get_hidden_size() { return m_hidden_size; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/hard_sigmoid_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/hard_sigmoid_ie.hpp index 7aa020ca7c6..02cf5816d3a 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/hard_sigmoid_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/hard_sigmoid_ie.hpp @@ -25,7 +25,7 @@ public: float alpha, float beta); - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; float get_alpha() const { return m_alpha; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/interp.hpp b/inference-engine/src/transformations/include/ngraph_ops/interp.hpp index 2255b6ae56e..a06db3077fc 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/interp.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/interp.hpp @@ -37,7 +37,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; InterpolateIEAttrs get_attrs() { return m_attrs; } @@ -65,7 +65,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; ResampleIEAttrs get_attrs() { return m_attrs; } private: diff --git a/inference-engine/src/transformations/include/ngraph_ops/lrn_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/lrn_ie.hpp index 0af36bb8fa6..291e8658aa3 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/lrn_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/lrn_ie.hpp @@ -28,7 +28,7 @@ public: size_t size, std::string region); - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; double get_alpha() const { return m_alpha; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/lstm_cell_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/lstm_cell_ie.hpp index f690da3c894..91914f8cad4 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/lstm_cell_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/lstm_cell_ie.hpp @@ -33,7 +33,7 @@ public: LSTMCellIE() = delete; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; std::size_t get_hidden_size() { return m_hidden_size; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/normalize_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/normalize_ie.hpp index 1bc9a1abf39..79af2db216e 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/normalize_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/normalize_ie.hpp @@ -33,7 +33,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; protected: float m_eps; diff --git a/inference-engine/src/transformations/include/ngraph_ops/onehot_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/onehot_ie.hpp index 35d0541dee8..629266e876b 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/onehot_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/onehot_ie.hpp @@ -26,7 +26,7 @@ public: size_t get_version() const override { return 1; } void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; int get_axis() { return m_axis; } int get_depth() { return m_depth; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/pad_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/pad_ie.hpp index 8522aeea611..345663d04e2 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/pad_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/pad_ie.hpp @@ -26,7 +26,7 @@ public: size_t get_version() const override { return 1; } void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; PadMode get_pad_mode() { return m_pad_mode; } CoordinateDiff get_pads_begin() { return m_pads_begin; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/power.hpp b/inference-engine/src/transformations/include/ngraph_ops/power.hpp index 5928c7aa0ea..7fb3a8446f8 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/power.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/power.hpp @@ -23,7 +23,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; float scale, power, shift; }; diff --git a/inference-engine/src/transformations/include/ngraph_ops/proposal_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/proposal_ie.hpp index 2ee7f9050dc..e7f2a2a5570 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/proposal_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/proposal_ie.hpp @@ -33,7 +33,7 @@ public: void validate_and_infer_types() override; std::shared_ptr - copy_with_new_args(const NodeVector& new_args) const override; + clone_with_new_inputs(const OutputVector& new_args) const override; const ProposalAttrs& get_attrs() const { return m_attrs; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/relu_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/relu_ie.hpp index 91f081406e8..a61d84b556b 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/relu_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/relu_ie.hpp @@ -22,7 +22,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; float get_slope() { return m_negative_slope; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/rnn_cell_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/rnn_cell_ie.hpp index 7450e38685e..430002a1c15 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/rnn_cell_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/rnn_cell_ie.hpp @@ -32,7 +32,7 @@ public: RNNCellIE() = delete; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; void validate_and_infer_types() override; std::size_t get_hidden_size() { return m_hidden_size; } diff --git a/inference-engine/src/transformations/include/ngraph_ops/scaleshift.hpp b/inference-engine/src/transformations/include/ngraph_ops/scaleshift.hpp index 354edf306a7..f701c20611e 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/scaleshift.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/scaleshift.hpp @@ -24,7 +24,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace op diff --git a/inference-engine/src/transformations/include/ngraph_ops/selu_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/selu_ie.hpp index eb9ad07400c..584a0b6a7f8 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/selu_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/selu_ie.hpp @@ -24,7 +24,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; float gamma, alpha; }; diff --git a/inference-engine/src/transformations/include/ngraph_ops/tile_ie.hpp b/inference-engine/src/transformations/include/ngraph_ops/tile_ie.hpp index b7c74a37782..676de684976 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/tile_ie.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/tile_ie.hpp @@ -24,7 +24,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; int64_t axis, tiles; }; diff --git a/inference-engine/src/transformations/src/ngraph_ops/crop_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/crop_ie.cpp index 68c14304658..4216b8a92ce 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/crop_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/crop_ie.cpp @@ -22,7 +22,7 @@ op::CropIE::CropIE(const Output& data, std::vector axes, std::vec constructor_validate_and_infer_types(); } -std::shared_ptr op::CropIE::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::CropIE::clone_with_new_inputs(const OutputVector& new_args) const { if (new_args.size() != 1) { throw ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/eltwise.cpp b/inference-engine/src/transformations/src/ngraph_ops/eltwise.cpp index ed28654f24a..0e5229f1253 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/eltwise.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/eltwise.cpp @@ -20,7 +20,7 @@ op::Eltwise::Eltwise(const Output& data1, const Output& data2, const constructor_validate_and_infer_types(); } -std::shared_ptr op::Eltwise::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::Eltwise::clone_with_new_inputs(const OutputVector& new_args) const { if (new_args.size() != 2) { throw ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/fully_connected.cpp b/inference-engine/src/transformations/src/ngraph_ops/fully_connected.cpp index 2a0cd649d25..40fdeab9522 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/fully_connected.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/fully_connected.cpp @@ -21,7 +21,7 @@ op::FullyConnected::FullyConnected(const Output& A, const Output& B, constructor_validate_and_infer_types(); } -shared_ptr op::FullyConnected::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::FullyConnected::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_output_shape); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/gather_tree_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/gather_tree_ie.cpp index c916ccab6ae..c42f3df275e 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/gather_tree_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/gather_tree_ie.cpp @@ -20,7 +20,7 @@ op::GatherTreeIE::GatherTreeIE(const Output& step_ids, constructor_validate_and_infer_types(); } -shared_ptr op::GatherTreeIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::GatherTreeIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared( new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3)); diff --git a/inference-engine/src/transformations/src/ngraph_ops/gru_cell_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/gru_cell_ie.cpp index 0eacf48070a..a4806bd3979 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/gru_cell_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/gru_cell_ie.cpp @@ -40,7 +40,7 @@ void op::GRUCellIE::validate_and_infer_types() { set_output_type(0, arg_type, output_shape); } -shared_ptr op::GRUCellIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::GRUCellIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), m_hidden_size, m_activations, m_activations_alpha, m_activations_beta, m_clip, diff --git a/inference-engine/src/transformations/src/ngraph_ops/hard_sigmoid_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/hard_sigmoid_ie.cpp index 3738bf1bcdb..e810432c491 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/hard_sigmoid_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/hard_sigmoid_ie.cpp @@ -31,7 +31,7 @@ void op::HardSigmoid_IE::validate_and_infer_types() { set_output_type(0, arg_type, arg_shape); } -shared_ptr op::HardSigmoid_IE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::HardSigmoid_IE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), m_alpha, m_beta); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/interp.cpp b/inference-engine/src/transformations/src/ngraph_ops/interp.cpp index 7cc9d72da02..e19acbd1aad 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/interp.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/interp.cpp @@ -61,7 +61,7 @@ void op::Interp::validate_and_infer_types() { } } -shared_ptr op::Interp::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::Interp::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), m_attrs); } @@ -101,7 +101,7 @@ void op::ResampleV2::validate_and_infer_types() { } } -shared_ptr op::ResampleV2::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::ResampleV2::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), m_attrs); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/lrn_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/lrn_ie.cpp index 7263d658012..ea9b9fe4d42 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/lrn_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/lrn_ie.cpp @@ -28,7 +28,7 @@ void op::LRN_IE::validate_and_infer_types() { set_output_type(0, arg_type, arg_shape); } -shared_ptr op::LRN_IE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::LRN_IE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), m_alpha, m_beta, m_bias, m_size, m_region); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/lstm_cell_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/lstm_cell_ie.cpp index d21803eb250..196ad4c2152 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/lstm_cell_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/lstm_cell_ie.cpp @@ -37,7 +37,7 @@ void op::LSTMCellIE::validate_and_infer_types() { set_output_type(1, arg_type, output_shape); } -shared_ptr op::LSTMCellIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::LSTMCellIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), new_args.at(4), m_hidden_size, m_activations, m_activations_alpha, m_activations_beta, m_clip); diff --git a/inference-engine/src/transformations/src/ngraph_ops/normalize_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/normalize_ie.cpp index 65275853552..8c7e1c0f76a 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/normalize_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/normalize_ie.cpp @@ -32,7 +32,7 @@ void op::NormalizeIE::validate_and_infer_types() { "Argument must have rank >= 2 and <= 4 (argument shape: ", input_shape, ")."); } -shared_ptr op::NormalizeIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::NormalizeIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), m_eps, m_across_spatial, m_channel_shared); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/onehot_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/onehot_ie.cpp index 4aa92ceb56d..a31b886c15e 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/onehot_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/onehot_ie.cpp @@ -31,7 +31,7 @@ void op::OneHotIE::validate_and_infer_types() { } } -shared_ptr op::OneHotIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::OneHotIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), m_axis, m_depth, m_on_value, m_off_value, m_type); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/pad_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/pad_ie.cpp index 72780f07f2c..4fd08a704e2 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/pad_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/pad_ie.cpp @@ -41,6 +41,6 @@ void op::PadIE::validate_and_infer_types() { set_output_type(0, get_input_element_type(0), m_output_shape); } -shared_ptr op::PadIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::PadIE::clone_with_new_inputs(const OutputVector& new_args) const { return nullptr; } diff --git a/inference-engine/src/transformations/src/ngraph_ops/power.cpp b/inference-engine/src/transformations/src/ngraph_ops/power.cpp index 24e61c443e5..b1f682ace12 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/power.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/power.cpp @@ -19,7 +19,7 @@ op::PowerIE::PowerIE(const Output& data_batch, const float power, constructor_validate_and_infer_types(); } -std::shared_ptr op::PowerIE::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::PowerIE::clone_with_new_inputs(const OutputVector& new_args) const { if (new_args.size() != 1) { throw ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/proposal_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/proposal_ie.cpp index 6d3a00cb6c5..f856c1e474c 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/proposal_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/proposal_ie.cpp @@ -53,7 +53,7 @@ void op::ProposalIE::validate_and_infer_types() { } } -shared_ptr op::ProposalIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::ProposalIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), m_attrs); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/relu_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/relu_ie.cpp index 2ec4f399daa..9517dcefb1f 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/relu_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/relu_ie.cpp @@ -20,7 +20,7 @@ op::ReLUIE::ReLUIE(const Output& data, const float& negative_slope) constructor_validate_and_infer_types(); } -std::shared_ptr op::ReLUIE::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::ReLUIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), m_negative_slope); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/rnn_cell_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/rnn_cell_ie.cpp index f7ebc7278e1..e5a5e329d81 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/rnn_cell_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/rnn_cell_ie.cpp @@ -37,7 +37,7 @@ void op::RNNCellIE::validate_and_infer_types() { set_output_type(0, arg_type, output_shape); } -shared_ptr op::RNNCellIE::copy_with_new_args(const NodeVector& new_args) const { +shared_ptr op::RNNCellIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), m_hidden_size, m_activations, m_activations_alpha, m_activations_beta, m_clip); @@ -50,4 +50,4 @@ bool op::RNNCellIE::visit_attributes(AttributeVisitor &visitor) { visitor.on_attribute("activations_beta", m_activations_beta); visitor.on_attribute("clip", m_clip); return true; -} \ No newline at end of file +} diff --git a/inference-engine/src/transformations/src/ngraph_ops/scaleshift.cpp b/inference-engine/src/transformations/src/ngraph_ops/scaleshift.cpp index 0f9e8d0e8d1..1af37154b8c 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/scaleshift.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/scaleshift.cpp @@ -19,7 +19,7 @@ op::ScaleShiftIE::ScaleShiftIE(const Output& data_batch, const Output op::ScaleShiftIE::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::ScaleShiftIE::clone_with_new_inputs(const OutputVector& new_args) const { if (new_args.size() != 3) { throw ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/selu_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/selu_ie.cpp index 7ec9522a759..9430f73b85a 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/selu_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/selu_ie.cpp @@ -22,7 +22,7 @@ op::SeluIE::SeluIE(const Output & input, constructor_validate_and_infer_types(); } -std::shared_ptr op::SeluIE::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::SeluIE::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return make_shared(new_args.at(0), alpha, gamma); } diff --git a/inference-engine/src/transformations/src/ngraph_ops/tile_ie.cpp b/inference-engine/src/transformations/src/ngraph_ops/tile_ie.cpp index 241d9680637..92d39a70519 100644 --- a/inference-engine/src/transformations/src/ngraph_ops/tile_ie.cpp +++ b/inference-engine/src/transformations/src/ngraph_ops/tile_ie.cpp @@ -20,7 +20,7 @@ op::TileIE::TileIE(const Output& data1, const int64_t axis, const constructor_validate_and_infer_types(); } -std::shared_ptr op::TileIE::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr op::TileIE::clone_with_new_inputs(const OutputVector& new_args) const { if (new_args.size() != 1) { throw ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/src/vpu/common/include/vpu/ngraph/operations/dynamic_shape_resolver.hpp b/inference-engine/src/vpu/common/include/vpu/ngraph/operations/dynamic_shape_resolver.hpp index 57ace6a5897..fcf5f21b293 100644 --- a/inference-engine/src/vpu/common/include/vpu/ngraph/operations/dynamic_shape_resolver.hpp +++ b/inference-engine/src/vpu/common/include/vpu/ngraph/operations/dynamic_shape_resolver.hpp @@ -28,7 +28,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; bool visit_attributes(ngraph::AttributeVisitor& visitor) override; diff --git a/inference-engine/src/vpu/common/include/vpu/ngraph/operations/static_shape_nonzero.hpp b/inference-engine/src/vpu/common/include/vpu/ngraph/operations/static_shape_nonzero.hpp index 5a9c75240c9..e41c5c58e7e 100644 --- a/inference-engine/src/vpu/common/include/vpu/ngraph/operations/static_shape_nonzero.hpp +++ b/inference-engine/src/vpu/common/include/vpu/ngraph/operations/static_shape_nonzero.hpp @@ -22,7 +22,7 @@ public: void validate_and_infer_types() override; - std::shared_ptr copy_with_new_args(const NodeVector& new_args) const override; + std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; bool visit_attributes(ngraph::AttributeVisitor& visitor) override; diff --git a/inference-engine/src/vpu/common/src/ngraph/operations/dynamic_shape_resolver.cpp b/inference-engine/src/vpu/common/src/ngraph/operations/dynamic_shape_resolver.cpp index e673ce3b120..1f55417c32d 100644 --- a/inference-engine/src/vpu/common/src/ngraph/operations/dynamic_shape_resolver.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/operations/dynamic_shape_resolver.cpp @@ -18,7 +18,7 @@ DynamicShapeResolver::DynamicShapeResolver( constructor_validate_and_infer_types(); } -std::shared_ptr DynamicShapeResolver::copy_with_new_args(const NodeVector& new_args) const { +std::shared_ptr DynamicShapeResolver::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); return std::make_shared(new_args.at(0), new_args.at(1), m_mode); } diff --git a/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_nonzero.cpp b/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_nonzero.cpp index 9dc857efcff..b0dbd5d23b3 100644 --- a/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_nonzero.cpp +++ b/inference-engine/src/vpu/common/src/ngraph/operations/static_shape_nonzero.cpp @@ -40,8 +40,8 @@ void StaticShapeNonZero::validate_and_infer_types() { set_output_type(1, m_output_type, {Dimension(2)}); } -std::shared_ptr StaticShapeNonZero::copy_with_new_args( - const NodeVector& new_args) const { +std::shared_ptr StaticShapeNonZero::clone_with_new_inputs( + const OutputVector& new_args) const { check_new_args_count(this, new_args); return std::make_shared(new_args.at(0), m_output_type); } diff --git a/inference-engine/tests/functional/inference_engine/extension_lib/include/extension.hpp b/inference-engine/tests/functional/inference_engine/extension_lib/include/extension.hpp index 5e60d4b689e..80d5e35a5e8 100644 --- a/inference-engine/tests/functional/inference_engine/extension_lib/include/extension.hpp +++ b/inference-engine/tests/functional/inference_engine/extension_lib/include/extension.hpp @@ -33,7 +33,7 @@ public: set_output_type(0, get_input_element_type(0), ngraph::PartialShape(output_shape)); } - std::shared_ptr copy_with_new_args(const ngraph::NodeVector& new_args) const override { + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override { if (new_args.size() != 1) { throw ngraph::ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/tests/functional/inference_engine/ngraph_reader/abs_tests.cpp b/inference-engine/tests/functional/inference_engine/ngraph_reader/abs_tests.cpp index 9567cab9636..6460907f9c5 100644 --- a/inference-engine/tests/functional/inference_engine/ngraph_reader/abs_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/ngraph_reader/abs_tests.cpp @@ -20,7 +20,7 @@ public: void validate_and_infer_types() override { set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); } - std::shared_ptr copy_with_new_args(const ngraph::NodeVector& new_args) const override { + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override { return std::make_shared(new_args.at(0)); } bool visit_attributes(ngraph::AttributeVisitor& visitor) override { diff --git a/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp b/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp index 65f6cd27b8d..cd7fb7af826 100644 --- a/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/ngraph_reshape_tests.cpp @@ -175,7 +175,7 @@ public: set_output_type(0, get_input_element_type(0), ngraph::PartialShape(output_shape)); } - std::shared_ptr copy_with_new_args(const ngraph::NodeVector& new_args) const override { + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override { if (new_args.size() != 1) { throw ngraph::ngraph_error("Incorrect number of new arguments"); } diff --git a/inference-engine/tests_deprecated/functional/mkldnn/extensions_tests/extensions_test.cpp b/inference-engine/tests_deprecated/functional/mkldnn/extensions_tests/extensions_test.cpp index 0893d4262be..3ced259297e 100644 --- a/inference-engine/tests_deprecated/functional/mkldnn/extensions_tests/extensions_test.cpp +++ b/inference-engine/tests_deprecated/functional/mkldnn/extensions_tests/extensions_test.cpp @@ -131,7 +131,7 @@ public: set_output_type(0, get_input_element_type(0), ngraph::PartialShape(output_shape)); } - std::shared_ptr copy_with_new_args(const ngraph::NodeVector& new_args) const override { + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector& new_args) const override { if (new_args.size() != 1) { throw ngraph::ngraph_error("Incorrect number of new arguments"); } diff --git a/ngraph/changes.md b/ngraph/changes.md index 32b851de731..bd5d3c281ef 100644 --- a/ngraph/changes.md +++ b/ngraph/changes.md @@ -43,7 +43,6 @@ * `Parameters` is now `ParameterVector` * `NodeVector`, `ParameterVector`, `AxisVector`, `AxisSet`, `Shape`, `Stride`, `Coordinate`, and `CoordinateDiff` are now classes, not type aliases. * `PrimaryTensorView` is now `TensorView` (and will merge into `Tensor`) -* `copy_with_new_args` is protected; use `copy_with_new_inputs` which takes an `OutputVector` as an argument and preserves control dependencies. ## Changes to ops diff --git a/ngraph/src/ngraph/frontend/onnx_import/core/null_node.cpp b/ngraph/src/ngraph/frontend/onnx_import/core/null_node.cpp index 2a6ca1eb801..cc150af595a 100644 --- a/ngraph/src/ngraph/frontend/onnx_import/core/null_node.cpp +++ b/ngraph/src/ngraph/frontend/onnx_import/core/null_node.cpp @@ -25,7 +25,8 @@ namespace ngraph { constexpr NodeTypeInfo NullNode::type_info; - std::shared_ptr NullNode::copy_with_new_args(const NodeVector& /* new_args */) const + std::shared_ptr + NullNode::clone_with_new_inputs(const OutputVector& /* new_args */) const { return std::make_shared(); } diff --git a/ngraph/src/ngraph/frontend/onnx_import/core/null_node.hpp b/ngraph/src/ngraph/frontend/onnx_import/core/null_node.hpp index 373bf87f5c6..167097eb7c6 100644 --- a/ngraph/src/ngraph/frontend/onnx_import/core/null_node.hpp +++ b/ngraph/src/ngraph/frontend/onnx_import/core/null_node.hpp @@ -49,7 +49,7 @@ namespace ngraph NullNode() = default; virtual std::shared_ptr - copy_with_new_args(const NodeVector& new_args) const override; + clone_with_new_inputs(const OutputVector& new_args) const override; }; } // namespace onnx_import } // namespace ngraph diff --git a/ngraph/src/ngraph/node.cpp b/ngraph/src/ngraph/node.cpp index 0de765f5e94..b51dfcf429a 100644 --- a/ngraph/src/ngraph/node.cpp +++ b/ngraph/src/ngraph/node.cpp @@ -124,31 +124,6 @@ std::shared_ptr return clone; } -std::shared_ptr Node::copy_with_new_args(const NodeVector& args) const -{ - NODE_VALIDATION_CHECK( - this, false, "Internal error: copy_with_new_args not replaced by clone_with_new_inputs"); -} - -std::shared_ptr Node::clone_with_new_inputs(const OutputVector& inputs) const -{ - NodeVector args; - for (const Output& input : inputs) - { - args.push_back(get_output_element(input)); - } - std::shared_ptr clone = copy_with_new_args(args); - // Remove the inserted GOEs - for (size_t i = 0; i < inputs.size(); ++i) - { - if (clone->input_value(i) != inputs.at(i)) - { - clone->set_argument(i, inputs.at(i)); - } - } - return clone; -} - void Node::safe_delete(NodeVector& nodes, bool recurse) { for (auto& input : m_inputs) diff --git a/ngraph/src/ngraph/node.hpp b/ngraph/src/ngraph/node.hpp index 4f740c67190..745872ca626 100644 --- a/ngraph/src/ngraph/node.hpp +++ b/ngraph/src/ngraph/node.hpp @@ -397,15 +397,8 @@ namespace ngraph std::shared_ptr get_input_node_shared_ptr(size_t index) const; Output get_input_source_output(size_t i) const; - protected: - // Will be replaced with clone_with_new_inputs - virtual std::shared_ptr copy_with_new_args(const NodeVector& new_args) const - NGRAPH_DEPRECATED("use copy_with_new_inputs instead"); - public: - // TODO: When all copy_with_new_args have been replaced with copy_with_new_inputs, make - // this pure and remove copy_with_new_args - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const; + virtual std::shared_ptr clone_with_new_inputs(const OutputVector& inputs) const = 0; std::shared_ptr copy_with_new_inputs(const OutputVector& new_args) const; @@ -625,7 +618,7 @@ namespace ngraph { NODE_VALIDATION_CHECK(node, new_args.size() == node->input_values().size(), - "copy_with_new_args() expected ", + "clone_with_new_inputs() expected ", node->input_values().size(), " argument", (node->input_values().size() == 1 ? "" : "s"), diff --git a/ngraph/src/ngraph/op/fused/fake_quantize.cpp b/ngraph/src/ngraph/op/fused/fake_quantize.cpp index cf3ed4a6c6a..fd57fc0e918 100644 --- a/ngraph/src/ngraph/op/fused/fake_quantize.cpp +++ b/ngraph/src/ngraph/op/fused/fake_quantize.cpp @@ -160,18 +160,6 @@ NodeVector op::FakeQuantize::decompose_op() const return {dequantized_data + output_low}; } -shared_ptr op::FakeQuantize::copy_with_new_args(const NodeVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args.at(0), // X - new_args.at(1), // input_low - new_args.at(2), // input_high - new_args.at(3), // output_low - new_args.at(4), // output_high - m_levels, - m_auto_broadcast); -} - shared_ptr op::FakeQuantize::clone_with_new_inputs(const OutputVector& new_args) const { check_new_args_count(this, new_args); diff --git a/ngraph/src/ngraph/op/fused/fake_quantize.hpp b/ngraph/src/ngraph/op/fused/fake_quantize.hpp index e864cbabc5e..62ca798f135 100644 --- a/ngraph/src/ngraph/op/fused/fake_quantize.hpp +++ b/ngraph/src/ngraph/op/fused/fake_quantize.hpp @@ -70,12 +70,6 @@ namespace ngraph virtual NodeVector decompose_op() const override; virtual void validate_and_infer_types() override; - // This is a hack to work around dldt directly calling copy_with_new_args - // When that code is replace with clone_with_new_inputs then remove this - // method. - virtual std::shared_ptr - copy_with_new_args(const NodeVector& new_args) const override; - virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; diff --git a/ngraph/src/ngraph/op/transpose.cpp b/ngraph/src/ngraph/op/transpose.cpp index ac3e654f313..391c4b28a8c 100644 --- a/ngraph/src/ngraph/op/transpose.cpp +++ b/ngraph/src/ngraph/op/transpose.cpp @@ -78,12 +78,6 @@ shared_ptr op::v1::Transpose::clone_with_new_inputs(const OutputVector& ne return make_shared(new_args[0], new_args[1]); } -shared_ptr op::v1::Transpose::copy_with_new_args(const NodeVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args[0], new_args[1]); -} - namespace { template diff --git a/ngraph/src/ngraph/op/transpose.hpp b/ngraph/src/ngraph/op/transpose.hpp index 36e17f336fa..93b34a52f7c 100644 --- a/ngraph/src/ngraph/op/transpose.hpp +++ b/ngraph/src/ngraph/op/transpose.hpp @@ -50,9 +50,6 @@ namespace ngraph virtual std::shared_ptr clone_with_new_inputs(const OutputVector& new_args) const override; - virtual std::shared_ptr - copy_with_new_args(const NodeVector& new_args) const override; - bool evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) override; }; diff --git a/ngraph/src/ngraph/pattern/op/pattern.hpp b/ngraph/src/ngraph/pattern/op/pattern.hpp index f2188651fbf..0ec1e5102e7 100644 --- a/ngraph/src/ngraph/pattern/op/pattern.hpp +++ b/ngraph/src/ngraph/pattern/op/pattern.hpp @@ -78,7 +78,7 @@ namespace ngraph } virtual std::shared_ptr - copy_with_new_args(const NodeVector& /* new_args */) const override + clone_with_new_inputs(const OutputVector& /* new_args */) const override { throw ngraph_error("Uncopyable"); } diff --git a/ngraph/test/op.cpp b/ngraph/test/op.cpp index 99aa84c442a..04b383ed799 100644 --- a/ngraph/test/op.cpp +++ b/ngraph/test/op.cpp @@ -114,21 +114,3 @@ TEST(op, variant) Ship& node_ship = as_type_ptr>(node_var_ship)->get(); EXPECT_EQ(&node_ship, &ship); } - -// TODO: Need to mock Node, Op etc to be able to unit test functions like replace_node(). -// Mocking them directly isn't possible because google test requires methods to be -// non-virtual. For non-virtual methods we will need to templatize these classes and call using -// different template argument between testing and production. -/* -TEST(op, provenance_replace_node) -{ - class MockOp: public op::Op - { - MOCK_CONST_METHOD1(copy_with_new_args, std::shared_ptr(const NodeVector& new_args)); - MOCK_CONST_METHOD1(get_users, NodeVector (bool check_is_used)); // This can't be mocked as - // it's non-virtual - }; - - ::testing::NiceMock mock_op; -} -*/