Skip to content

Commit

Permalink
[Remove API] remove ov::clone_model() replace by ov::model:;clone() (o…
Browse files Browse the repository at this point in the history
…penvinotoolkit#22283)

* [Remove API] remove ov::clone_model() replace by ov::model:;clone()

Signed-off-by: Zhai, Xuejun <[email protected]>

* clean code

Signed-off-by: Zhai, Xuejun <[email protected]>

---------

Signed-off-by: Zhai, Xuejun <[email protected]>
  • Loading branch information
zhaixuejun1993 authored Jan 23, 2024
1 parent edd5e9a commit ac99cc8
Show file tree
Hide file tree
Showing 14 changed files with 14 additions and 57 deletions.
14 changes: 0 additions & 14 deletions src/core/include/ngraph/graph_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ using ov::op::v0::Result;
} // namespace v0
} // namespace op

NGRAPH_API_DEPRECATED
inline std::shared_ptr<ngraph::Function> 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<ngraph::Function> 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;
Expand Down
16 changes: 0 additions & 16 deletions src/core/include/openvino/core/graph_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,22 +270,6 @@ std::vector<std::shared_ptr<Node>> 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<ov::Model> clone_model(const ov::Model& model,
std::unordered_map<Node*, std::shared_ptr<Node>>& 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<ov::Model> clone_model(const ov::Model& model);

OPENVINO_API
bool compare_constants(const std::shared_ptr<Node>& n1, const std::shared_ptr<Node>& n2);

Expand Down
12 changes: 0 additions & 12 deletions src/core/src/graph_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,6 @@ std::shared_ptr<Model> clone_ov_model(const Model& func, std::unordered_map<Node
return result;
}

OPENVINO_SUPPRESS_DEPRECATED_START
std::shared_ptr<ov::Model> clone_model(const ov::Model& func) {
std::unordered_map<ov::Node*, std::shared_ptr<ov::Node>> nm;
return clone_model(func, nm);
}

std::shared_ptr<ov::Model> clone_model(const ov::Model& func,
std::unordered_map<Node*, std::shared_ptr<Node>>& node_map) {
return ov::clone_ov_model(func, node_map);
}
OPENVINO_SUPPRESS_DEPRECATED_END

bool compare_constants(const std::shared_ptr<Node>& n1, const std::shared_ptr<Node>& n2) {
if (!(op::util::is_constant(n1) && op::util::is_constant(n2))) {
return false;
Expand Down
5 changes: 2 additions & 3 deletions src/core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,9 +946,8 @@ ov::Output<ov::Node> ov::Model::add_output(const ov::Output<ov::Node>& port) {
}

std::shared_ptr<ov::Model> ov::Model::clone() const {
OPENVINO_SUPPRESS_DEPRECATED_START
return ov::clone_model(*this);
OPENVINO_SUPPRESS_DEPRECATED_END
std::unordered_map<ov::Node*, std::shared_ptr<ov::Node>> node_map;
return ov::clone_ov_model(*this, node_map);
}

bool ov::Model::has_rt_info(const std::vector<std::string>& args) const {
Expand Down
2 changes: 1 addition & 1 deletion src/inference/src/cnn_network_ngraph_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void TransposeLayerCPUTest::SetUp() {
const ov::ResultVector results{std::make_shared<ov::op::v0::Result>(transpose)};

function = std::make_shared<ov::Model>(results, ov::ParameterVector{params}, "TransposeLayerCPUTest");
functionRefs = ov::clone_model(*function);
functionRefs = function->clone();
}

TEST_P(TransposeLayerCPUTest, CompareWithRefs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CumSumLayerCPUTest : public testing::WithParamInterface<cumSumParams>,
auto cumSum = std::make_shared<ov::op::v0::CumSum>(params[0], axisNode, exclusive, reverse);

function = std::make_shared<ov::Model>(ov::NodeVector{cumSum}, params, "CumSumLayerCPUTest");
functionRefs = ov::clone_model(*function);
functionRefs = function->clone();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class MatMulSparseCPUTest : public testing::WithParamInterface<MatMulSparseParam

checkFusingPosition = false;

functionRefs = ov::clone_model(*function);
functionRefs = function->clone();
convert_precisions.insert({ov::element::i8, ov::element::f32});
convert_precisions.insert({ov::element::u8, ov::element::f32});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface<ROIPoolingCPUT
ov::ResultVector results{std::make_shared<ov::op::v0::Result>(roi_pooling)};

function = makeNgraphFunction(netPrecision, params, roi_pooling, "ROIPooling");
functionRefs = ov::clone_model(*function);
functionRefs = function->clone();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CpuTestWithFusing::CheckPluginRelatedResultsImpl(const std::shared_ptr<cons

std::shared_ptr<ov::Node>
postFunctionMgr::addPostOps(const ov::element::Type &ngPrc, ov::ParameterVector &params, const std::shared_ptr<ov::Node> &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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down Expand Up @@ -507,7 +507,7 @@ void LayerTestsCommon::Compare(const std::vector<std::pair<ngraph::element::Type

void LayerTestsCommon::Validate() {
if (functionRefs == nullptr) {
functionRefs = ngraph::clone_function(*function);
functionRefs = function->clone();
}
auto expectedOutputs = CalculateRefs();
const auto &actualOutputs = GetOutputs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ std::shared_ptr<ov::Model> 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();
Expand All @@ -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();
Expand Down

0 comments on commit ac99cc8

Please sign in to comment.