From baac903cdc273f7771805c1179cf405f9df0b743 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Tue, 15 Sep 2020 14:01:43 +0300 Subject: [PATCH] Fixed output names for case with redundant ops before result (#2210) --- .../cnn_network/cnn_ngraph_impl_tests.cpp | 126 +++++++++++++++++++++ ngraph/core/src/graph_util.cpp | 2 + 2 files changed, 128 insertions(+) diff --git a/inference-engine/tests/functional/inference_engine/cnn_network/cnn_ngraph_impl_tests.cpp b/inference-engine/tests/functional/inference_engine/cnn_network/cnn_ngraph_impl_tests.cpp index 370c6a1..a1d2f6c 100644 --- a/inference-engine/tests/functional/inference_engine/cnn_network/cnn_ngraph_impl_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/cnn_network/cnn_ngraph_impl_tests.cpp @@ -17,6 +17,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -955,4 +959,126 @@ TEST(CNNNGraphImplTests, AddOutputToExperimentalOp) { auto outputs = network.getOutputsInfo(); ASSERT_NE(outputs.find("exp.0"), outputs.end()); } + +TEST(CNNNGraphImplTests, SaveOriginalResultNameForMultiOutputOp) { + std::string model = R"V0G0N( + + + + + + + 1 + 3 + 22 + 22 + + + + + + + 1 + 3 + 22 + 22 + + + + + 1 + 3 + 22 + 22 + + + + + + + + 1 + 1 + 1 + 1 + + + + + + + 1 + 3 + 22 + 22 + + + 1 + 1 + 1 + 1 + + + + + 1 + 3 + 22 + 22 + + + + + + + 1 + 3 + 22 + 22 + + + + + + + + + + + +)V0G0N"; + InferenceEngine::Core core; + Blob::Ptr data = make_shared_blob(TensorDesc(Precision::FP32, {4}, Layout::C)); + data->allocate(); + { + auto lockData = data->buffer(); + float *dataPtr = lockData.as(); + + for (size_t i = 0; i < 4; ++i) { + dataPtr[i] = 0; + } + } + CNNNetwork network = core.ReadNetwork(model, data); + { + auto outputs = network.getOutputsInfo(); + ASSERT_NE(outputs.find("text_features"), outputs.end()); + } + + auto nGraphFunc = network.getFunction(); + // Disable shape inference (WA for generic operations) + ngraph::op::GenericIE::DisableReshape noReshape(nGraphFunc); + + ngraph::pass::Manager manager; + + manager.register_pass(); + + manager.run_passes(nGraphFunc); + + auto clonedNetwork = InferenceEngine::details::convertFunctionToICNNNetwork(nGraphFunc, network); + { + OutputsDataMap outputs; + clonedNetwork->getOutputsInfo(outputs); + ASSERT_NE(outputs.find("text_features"), outputs.end()); + } +} IE_SUPPRESS_DEPRECATED_END diff --git a/ngraph/core/src/graph_util.cpp b/ngraph/core/src/graph_util.cpp index d9c0f44..0bb6e8b 100644 --- a/ngraph/core/src/graph_util.cpp +++ b/ngraph/core/src/graph_util.cpp @@ -902,6 +902,8 @@ bool ngraph::replace_output_update_name(Output output, const Output& if (has_result_output && !is_type(replacement.get_node())) { replacement.get_node()->set_friendly_name(output.get_node()->get_friendly_name()); + // Update output tensor name + replacement.get_tensor().set_name(output.get_node()->get_friendly_name()); } output.replace(replacement); copy_runtime_info({replacement.get_node_shared_ptr(), output.get_node_shared_ptr()}, -- 2.7.4