From ac99cc882bd6e968883ecb4b9bd02eab84ca211b Mon Sep 17 00:00:00 2001 From: Xuejun Zhai Date: Tue, 23 Jan 2024 21:04:49 +0800 Subject: [PATCH] [Remove API] remove ov::clone_model() replace by ov::model:;clone() (#22283) * [Remove API] remove ov::clone_model() replace by ov::model:;clone() Signed-off-by: Zhai, Xuejun * clean code Signed-off-by: Zhai, Xuejun --------- Signed-off-by: Zhai, Xuejun --- src/core/include/ngraph/graph_util.hpp | 14 -------------- src/core/include/openvino/core/graph_util.hpp | 16 ---------------- src/core/src/graph_util.cpp | 12 ------------ src/core/src/model.cpp | 5 ++--- src/inference/src/cnn_network_ngraph_impl.cpp | 2 +- .../single_layer_tests/classes/transpose.cpp | 2 +- .../functional/single_layer_tests/cum_sum.cpp | 2 +- .../single_layer_tests/matmul_sparse.cpp | 2 +- .../single_layer_tests/roi_pooling.cpp | 2 +- .../functional/test_utils/fusing_test_utils.cpp | 2 +- .../shared/include/subgraph_tests/basic_lstm.hpp | 2 +- .../src/base/layer_test_utils.cpp | 4 ++-- .../src/single_layer/memory.cpp | 2 +- .../src/subgraph/basic_lstm.cpp | 4 ++-- 14 files changed, 14 insertions(+), 57 deletions(-) diff --git a/src/core/include/ngraph/graph_util.hpp b/src/core/include/ngraph/graph_util.hpp index 576acc5f7996ae..7b91dd34cffe2c 100644 --- a/src/core/include/ngraph/graph_util.hpp +++ b/src/core/include/ngraph/graph_util.hpp @@ -46,20 +46,6 @@ using ov::op::v0::Result; } // namespace v0 } // namespace op -NGRAPH_API_DEPRECATED -inline std::shared_ptr clone_function(const ngraph::Function& func, ngraph::NodeMap& node_map) { - OPENVINO_SUPPRESS_DEPRECATED_START - return ov::clone_model(func, node_map); - OPENVINO_SUPPRESS_DEPRECATED_END -} - -NGRAPH_API_DEPRECATED -inline std::shared_ptr clone_function(const ngraph::Function& func) { - OPENVINO_SUPPRESS_DEPRECATED_START - return ov::clone_model(func); - OPENVINO_SUPPRESS_DEPRECATED_END -} - using ov::compare_constants; using ov::replace_node; using ov::replace_node_update_name; diff --git a/src/core/include/openvino/core/graph_util.hpp b/src/core/include/openvino/core/graph_util.hpp index d0b8625241681d..454ed6a24922c4 100644 --- a/src/core/include/openvino/core/graph_util.hpp +++ b/src/core/include/openvino/core/graph_util.hpp @@ -270,22 +270,6 @@ std::vector> topological_sort(T root_nodes) { return result; } -// input Model is cloned and returned -// NodeMap input may contain default node mapping i.e. pre-cloned nodes -// NodeMap output (by reference) fully maps input and cloned Model ops -OPENVINO_DEPRECATED( - "This method is deprecated and will be removed in 2024.0 release. Please use ov::Model::clone() instead.") -OPENVINO_API -std::shared_ptr clone_model(const ov::Model& model, - std::unordered_map>& node_map); - -/// \brief input model is cloned and returned -/// \ingroup ov_model_cpp_api -OPENVINO_DEPRECATED( - "This method is deprecated and will be removed in 2024.0 release. Please use ov::Model::clone() instead.") -OPENVINO_API -std::shared_ptr clone_model(const ov::Model& model); - OPENVINO_API bool compare_constants(const std::shared_ptr& n1, const std::shared_ptr& n2); diff --git a/src/core/src/graph_util.cpp b/src/core/src/graph_util.cpp index 761293f194fd16..2de09440992736 100644 --- a/src/core/src/graph_util.cpp +++ b/src/core/src/graph_util.cpp @@ -243,18 +243,6 @@ std::shared_ptr clone_ov_model(const Model& func, std::unordered_map clone_model(const ov::Model& func) { - std::unordered_map> nm; - return clone_model(func, nm); -} - -std::shared_ptr clone_model(const ov::Model& func, - std::unordered_map>& node_map) { - return ov::clone_ov_model(func, node_map); -} -OPENVINO_SUPPRESS_DEPRECATED_END - bool compare_constants(const std::shared_ptr& n1, const std::shared_ptr& n2) { if (!(op::util::is_constant(n1) && op::util::is_constant(n2))) { return false; diff --git a/src/core/src/model.cpp b/src/core/src/model.cpp index edaf69edfff6e1..16138ae3765931 100644 --- a/src/core/src/model.cpp +++ b/src/core/src/model.cpp @@ -946,9 +946,8 @@ ov::Output ov::Model::add_output(const ov::Output& port) { } std::shared_ptr ov::Model::clone() const { - OPENVINO_SUPPRESS_DEPRECATED_START - return ov::clone_model(*this); - OPENVINO_SUPPRESS_DEPRECATED_END + std::unordered_map> node_map; + return ov::clone_ov_model(*this, node_map); } bool ov::Model::has_rt_info(const std::vector& args) const { diff --git a/src/inference/src/cnn_network_ngraph_impl.cpp b/src/inference/src/cnn_network_ngraph_impl.cpp index 78dce8f83bbc13..481cb7b6c1b382 100644 --- a/src/inference/src/cnn_network_ngraph_impl.cpp +++ b/src/inference/src/cnn_network_ngraph_impl.cpp @@ -194,7 +194,7 @@ CNNNetworkNGraphImpl::CNNNetworkNGraphImpl(const CNNNetwork& network) { IE_THROW() << "Cannot create CNNNetwork with nGraph from legacy network format!"; } - _ngraph_function = ngraph::clone_function(*network.getFunction()); + _ngraph_function = network.getFunction()->clone(); validateFunctionNames(); InputsDataMap inputs = network.getInputsInfo(); OutputsDataMap outputs = network.getOutputsInfo(); diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp index daff97d5077515..2dee8478ac6f19 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/classes/transpose.cpp @@ -66,7 +66,7 @@ void TransposeLayerCPUTest::SetUp() { const ov::ResultVector results{std::make_shared(transpose)}; function = std::make_shared(results, ov::ParameterVector{params}, "TransposeLayerCPUTest"); - functionRefs = ov::clone_model(*function); + functionRefs = function->clone(); } TEST_P(TransposeLayerCPUTest, CompareWithRefs) { diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp index 144e1485137031..336a4d06989d65 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/cum_sum.cpp @@ -61,7 +61,7 @@ class CumSumLayerCPUTest : public testing::WithParamInterface, auto cumSum = std::make_shared(params[0], axisNode, exclusive, reverse); function = std::make_shared(ov::NodeVector{cumSum}, params, "CumSumLayerCPUTest"); - functionRefs = ov::clone_model(*function); + functionRefs = function->clone(); } }; diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp index f9a7c941dbfb13..a0118f1a602fbb 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/matmul_sparse.cpp @@ -196,7 +196,7 @@ class MatMulSparseCPUTest : public testing::WithParamInterfaceclone(); convert_precisions.insert({ov::element::i8, ov::element::f32}); convert_precisions.insert({ov::element::u8, ov::element::f32}); } diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp index 52dd8e147e8210..7fd574feb01bf6 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp @@ -214,7 +214,7 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface(roi_pooling)}; function = makeNgraphFunction(netPrecision, params, roi_pooling, "ROIPooling"); - functionRefs = ov::clone_model(*function); + functionRefs = function->clone(); } }; diff --git a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp b/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp index c054a67aa57eb2..762a906f65bd2b 100644 --- a/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp +++ b/src/plugins/intel_cpu/tests/functional/test_utils/fusing_test_utils.cpp @@ -75,7 +75,7 @@ void CpuTestWithFusing::CheckPluginRelatedResultsImpl(const std::shared_ptr postFunctionMgr::addPostOps(const ov::element::Type &ngPrc, ov::ParameterVector ¶ms, const std::shared_ptr &lastNode) const { - auto clonedPostFunction = ov::clone_model(*_pFunction); + auto clonedPostFunction = _pFunction->clone(); clonedPostFunction->set_friendly_name(_pFunction->get_friendly_name()); clonedPostFunction->replace_node(clonedPostFunction->get_parameters()[0], lastNode); return clonedPostFunction->get_result()->get_input_node_shared_ptr(0); diff --git a/src/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp b/src/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp index 63dfb6f8a0c58e..9de885e087af11 100644 --- a/src/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp +++ b/src/tests/functional/plugin/shared/include/subgraph_tests/basic_lstm.hpp @@ -44,7 +44,7 @@ TEST_P(Basic_LSTM_S, CompareWithRefImpl_LowLatencyTransformation) { // Generate inputs GenerateInputs(); - functionRefs = ngraph::clone_function(*function); + functionRefs = function->clone(); LoadNetwork(); auto referenceOutputs = CalculateRefs(); auto states = inferRequest.QueryState(); diff --git a/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp b/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp index 6fc8270cbbe941..a9e655e859da0f 100644 --- a/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp +++ b/src/tests/functional/shared_test_classes/src/base/layer_test_utils.cpp @@ -63,7 +63,7 @@ void LayerTestsCommon::Run() { GTEST_SKIP() << "Disabled test due to configuration" << std::endl; if (functionRefs == nullptr) { - functionRefs = ngraph::clone_function(*function); + functionRefs = function->clone(); functionRefs->set_friendly_name("refFunction"); } @@ -507,7 +507,7 @@ void LayerTestsCommon::Compare(const std::vectorclone(); } auto expectedOutputs = CalculateRefs(); const auto &actualOutputs = GetOutputs(); diff --git a/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp b/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp index d8ed69769fc839..a572b99e197048 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/memory.cpp @@ -58,7 +58,7 @@ void MemoryTest::SetUp() { } void MemoryTest::Run() { - functionRefs = ngraph::clone_function(*function); + functionRefs = function->clone(); SKIP_IF_CURRENT_TEST_IS_DISABLED() using namespace LayerTestsUtils; auto crashHandler = [](int errCode) { diff --git a/src/tests/functional/shared_test_classes/src/subgraph/basic_lstm.cpp b/src/tests/functional/shared_test_classes/src/subgraph/basic_lstm.cpp index 27f062ecd7d5c5..421b8537c89bf8 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/basic_lstm.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/basic_lstm.cpp @@ -125,7 +125,7 @@ std::shared_ptr Basic_LSTM_S::GetNetwork(size_t thirdDimOut, void Basic_LSTM_S::GenerateInputs() { // Generate inputs can be called before actual network loading in case lf LowLatencyTransformation - auto inputs_function = ngraph::clone_function(*function); + auto inputs_function = function->clone(); auto inputsCnnNetwork = InferenceEngine::CNNNetwork{ inputs_function }; auto inputsExecutableNetwork = core->LoadNetwork(inputsCnnNetwork, targetDevice); const auto& inputsInfo = inputsExecutableNetwork.GetInputsInfo(); @@ -143,7 +143,7 @@ void Basic_LSTM_S::GenerateInputs() { void Basic_LSTM_S::Run() { SKIP_IF_CURRENT_TEST_IS_DISABLED() - functionRefs = ngraph::clone_function(*function); + functionRefs = function->clone(); LoadNetwork(); GenerateInputs();