diff --git a/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp b/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp index 6ca061bd14c..5b1c3fa035f 100644 --- a/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp +++ b/src/common/transformations/src/transformations/smart_reshape/strided_slice_squeeze.cpp @@ -106,10 +106,8 @@ ngraph::pass::StridedSliceSqueeze::StridedSliceSqueeze() { shrink_axis_mask, ellipsis_mask); - replace_node(squeeze, new_slice); - new_slice->set_friendly_name(slice->get_friendly_name()); - copy_runtime_info(slice, new_slice); - return true; + return replace_output_update_name(squeeze->output(0), + new_slice->output(squeeze->input_value(0).get_index())); }; auto m = std::make_shared(squeeze_label /*, matcher_name */); register_matcher(m, callback); diff --git a/src/tests/functional/inference_engine/transformations/sr_mimicking_sbs.cpp b/src/tests/functional/inference_engine/transformations/sr_mimicking_sbs.cpp index f89f1f079f6..c2702aa581b 100644 --- a/src/tests/functional/inference_engine/transformations/sr_mimicking_sbs.cpp +++ b/src/tests/functional/inference_engine/transformations/sr_mimicking_sbs.cpp @@ -8,6 +8,8 @@ #include #include +#include "common_test_utils/ngraph_test_utils.hpp" + TEST(SmartReshapeTests, MimickingSBS) { std::shared_ptr f(nullptr); @@ -18,7 +20,11 @@ TEST(SmartReshapeTests, MimickingSBS) { } InferenceEngine::CNNNetwork network(f); + + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({12, 4})); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({2, 2, 3, 4})); @@ -33,7 +39,11 @@ TEST(SmartReshapeTests, MimickingSBS_1) { } InferenceEngine::CNNNetwork network(f); + + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({2, 24})); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({2, 2, 3, 4})); @@ -48,7 +58,11 @@ TEST(SmartReshapeTests, MimickingSBS_2) { } InferenceEngine::CNNNetwork network(f); + + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(1)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({6, 4})); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 2, 3, 4})); diff --git a/src/tests/functional/inference_engine/transformations/sr_proposal_scales.cpp b/src/tests/functional/inference_engine/transformations/sr_proposal_scales.cpp index 6824dc1014c..456911c1745 100644 --- a/src/tests/functional/inference_engine/transformations/sr_proposal_scales.cpp +++ b/src/tests/functional/inference_engine/transformations/sr_proposal_scales.cpp @@ -9,6 +9,7 @@ #include #include +#include "common_test_utils/ngraph_test_utils.hpp" TEST(SmartReshapeTests, Proposal1Scales) { std::shared_ptr f(nullptr); @@ -37,7 +38,10 @@ TEST(SmartReshapeTests, Proposal1Scales) { } InferenceEngine::CNNNetwork network(f); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({600, 5})); } @@ -68,6 +72,11 @@ TEST(SmartReshapeTests, Proposal4Scales) { } InferenceEngine::CNNNetwork network(f); + + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); + ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({600, 5})); } \ No newline at end of file diff --git a/src/tests/functional/inference_engine/transformations/sr_reshape_1d.cpp b/src/tests/functional/inference_engine/transformations/sr_reshape_1d.cpp index e22c5463617..c5195dd9a97 100644 --- a/src/tests/functional/inference_engine/transformations/sr_reshape_1d.cpp +++ b/src/tests/functional/inference_engine/transformations/sr_reshape_1d.cpp @@ -8,12 +8,13 @@ #include #include +#include "common_test_utils/ngraph_test_utils.hpp" + TEST(SmartReshapeTests, Reshape1d) { std::shared_ptr f(nullptr); { auto input = std::make_shared(ngraph::element::f32, ngraph::PartialShape::dynamic()); - input->set_friendly_name("input"); auto reshape = std::make_shared(input, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {5}), true); f = std::make_shared(ngraph::NodeVector{reshape}, ngraph::ParameterVector{input}); } @@ -23,7 +24,10 @@ TEST(SmartReshapeTests, Reshape1d) { ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible(ngraph::PartialShape::dynamic())); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({5})); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"input", {1, 3, 300, 300}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{f->get_parameters()[0]->get_friendly_name(), {1, 3, 300, 300}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({270000})); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 300, 300})); @@ -34,7 +38,6 @@ TEST(SmartReshapeTests, Reshape1d_negative) { { auto input = std::make_shared(ngraph::element::f32, ngraph::PartialShape::dynamic()); auto pattern = std::make_shared(ngraph::element::i64, ngraph::Shape{1}); - input->set_friendly_name("input"); auto reshape = std::make_shared(input, pattern, false); f = std::make_shared(ngraph::NodeVector{reshape}, ngraph::ParameterVector{input, pattern}); } @@ -44,7 +47,10 @@ TEST(SmartReshapeTests, Reshape1d_negative) { ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible(ngraph::PartialShape::dynamic())); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().is_dynamic()); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"input", {1, 3, 300, 300}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{f->get_parameters()[0]->get_friendly_name(), {1, 3, 300, 300}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({270000})); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 300, 300})); diff --git a/src/tests/functional/inference_engine/transformations/sr_strided_slice_squeeze.cpp b/src/tests/functional/inference_engine/transformations/sr_strided_slice_squeeze.cpp index 3e2ed56819b..5012a9878b3 100644 --- a/src/tests/functional/inference_engine/transformations/sr_strided_slice_squeeze.cpp +++ b/src/tests/functional/inference_engine/transformations/sr_strided_slice_squeeze.cpp @@ -8,6 +8,7 @@ #include #include +#include "common_test_utils/ngraph_test_utils.hpp" TEST(SmartReshapeTests, SS_Squeeze) { std::shared_ptr f(nullptr); @@ -20,17 +21,20 @@ TEST(SmartReshapeTests, SS_Squeeze) { ngraph::opset5::Constant::create(ngraph::element::i64, {2}, {1, 1}), std::vector{1, 1}, std::vector{1, 1}); auto squeeze = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0})); + auto relu = std::make_shared(squeeze); - f = std::make_shared(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input}); + f = std::make_shared(ngraph::NodeVector{relu}, ngraph::ParameterVector{input}); } InferenceEngine::CNNNetwork network(f); - ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3})); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); @@ -48,8 +52,9 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end_mask) { ngraph::opset5::Constant::create(ngraph::element::i64, {3}, {1, 1, 1}), std::vector{0}, std::vector{1}); // begin_mask.size() is no larger than axis that is going to be squeezed. auto squeeze = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {1})); + auto relu = std::make_shared(squeeze); - f = std::make_shared(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input}); + f = std::make_shared(ngraph::NodeVector{relu}, ngraph::ParameterVector{input}); } InferenceEngine::CNNNetwork network(f); @@ -58,8 +63,11 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end_mask) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 128, 768})); + auto unh = std::make_shared(); + init_unique_names(f, unh); auto inputname = network.getFunction()->get_parameters()[0]->get_friendly_name(); ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{inputname, {2, 128, 768}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({2, 768})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); @@ -78,8 +86,9 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end) { ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {1}), std::vector{1, 1, 1}, std::vector{1, 1, 1}); auto squeeze = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {1})); + auto relu = std::make_shared(squeeze); - f = std::make_shared(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input}); + f = std::make_shared(ngraph::NodeVector{relu}, ngraph::ParameterVector{input}); } InferenceEngine::CNNNetwork network(f); @@ -88,8 +97,11 @@ TEST(SmartReshapeTests, SS_Squeeze_partial_begin_end) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 1, 768})); + auto unh = std::make_shared(); + init_unique_names(f, unh); auto inputname = network.getFunction()->get_parameters()[0]->get_friendly_name(); ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{inputname, {2, 1, 768}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({2, 768})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); @@ -118,7 +130,10 @@ TEST(SmartReshapeTests, SS_Squeeze_mask_use_negative) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3})); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_ANY_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); } @@ -133,8 +148,9 @@ TEST(SmartReshapeTests, SS_Squeeze_negative_stride_negative) { ngraph::opset5::Constant::create(ngraph::element::i64, {2}, {-1, -1}), std::vector{1, 1}, std::vector{1, 1}); auto squeeze = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0})); + auto relu = std::make_shared(squeeze); - f = std::make_shared(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input}); + f = std::make_shared(ngraph::NodeVector{relu}, ngraph::ParameterVector{input}); } @@ -144,7 +160,10 @@ TEST(SmartReshapeTests, SS_Squeeze_negative_stride_negative) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3})); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_ANY_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); } TEST(SmartReshapeTests, SS_SharedSqueezes) { @@ -159,8 +178,9 @@ TEST(SmartReshapeTests, SS_SharedSqueezes) { std::vector{1, 1}, std::vector{1, 1}); auto squeeze_1 = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0})); auto squeeze_2 = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {1}, {0})); - - f = std::make_shared(ngraph::NodeVector{squeeze_1, squeeze_2}, ngraph::ParameterVector{input}); + auto relu_1 = std::make_shared(squeeze_1); + auto relu_2 = std::make_shared(squeeze_2); + f = std::make_shared(ngraph::NodeVector{relu_1, relu_2}, ngraph::ParameterVector{input}); } InferenceEngine::CNNNetwork network(f); @@ -169,7 +189,10 @@ TEST(SmartReshapeTests, SS_SharedSqueezes) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3})); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); @@ -188,8 +211,9 @@ TEST(SmartReshapeTests, SS_SqueezeNegativeAxes) { ngraph::opset5::Constant::create(ngraph::element::i64, {6}, {1, 1, 1, 1, 1, 1}), std::vector{1, 1, 1, 1, 1, 1}, std::vector{1, 1, 1, 1, 1, 1}); auto squeeze = std::make_shared(ss, ngraph::opset5::Constant::create(ngraph::element::i64, {3}, {-2, 0, -4})); + auto relu = std::make_shared(squeeze); - f = std::make_shared(ngraph::NodeVector{squeeze}, ngraph::ParameterVector{input}); + f = std::make_shared(ngraph::NodeVector{relu}, ngraph::ParameterVector{input}); } InferenceEngine::CNNNetwork network(f); @@ -198,7 +222,10 @@ TEST(SmartReshapeTests, SS_SqueezeNegativeAxes) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 1, 8, 1, 2})); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3, 8, 2})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); @@ -226,7 +253,10 @@ TEST(SmartReshapeTests, Squeeze_SSNegativeAxes) { network.getFunction()->get_results()[0]->get_output_partial_shape(0); ASSERT_TRUE(network.getFunction()->get_parameters()[0]->get_partial_shape().compatible({1, 3, 1, 8, 1, 2})); + auto unh = std::make_shared(); + init_unique_names(f, unh); ASSERT_NO_THROW(network.setBatchSize(2)); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({3, 8, 2})) << network.getFunction()->get_results()[0]->get_output_partial_shape(0); diff --git a/src/tests/functional/inference_engine/transformations/sr_sub_graph_ops.cpp b/src/tests/functional/inference_engine/transformations/sr_sub_graph_ops.cpp index f2282712d0b..5ec883380cb 100644 --- a/src/tests/functional/inference_engine/transformations/sr_sub_graph_ops.cpp +++ b/src/tests/functional/inference_engine/transformations/sr_sub_graph_ops.cpp @@ -8,8 +8,11 @@ #include #include +#include "common_test_utils/ngraph_test_utils.hpp" + using namespace ngraph; + TEST(SmartReshapeTests, TensorIteratorStaticParameters) { std::shared_ptr f(nullptr); { @@ -17,9 +20,6 @@ TEST(SmartReshapeTests, TensorIteratorStaticParameters) { auto X = std::make_shared(element::f32, Shape{1, 1, 1}); auto Y = std::make_shared(element::f32, Shape{1, 1, 1}); auto M = std::make_shared(element::f32, Shape{1, 1, 1}); - X->set_friendly_name("X"); - Y->set_friendly_name("Y"); - M->set_friendly_name("M"); // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters @@ -60,7 +60,13 @@ TEST(SmartReshapeTests, TensorIteratorStaticParameters) { ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible({1, 1, 1})); ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible({1, 1, 1})); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{ + {f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}}, + {f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}}, + {f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({})); ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10})); @@ -76,9 +82,6 @@ TEST(SmartReshapeTests, TensorIteratorDynamicParameters) { auto X = std::make_shared(element::f32, Shape{1, 1, 1}); auto Y = std::make_shared(element::f32, Shape{1, 1, 1}); auto M = std::make_shared(element::f32, Shape{1, 1, 1}); - X->set_friendly_name("X"); - Y->set_friendly_name("Y"); - M->set_friendly_name("M"); // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters @@ -119,7 +122,13 @@ TEST(SmartReshapeTests, TensorIteratorDynamicParameters) { ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible({1, 1, 1})); ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible({1, 1, 1})); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{ + {f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}}, + {f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}}, + {f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({})); ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10})); @@ -135,9 +144,6 @@ TEST(SmartReshapeTests, LoopStaticParameters) { auto X = std::make_shared(element::f32, PartialShape::dynamic()); auto Y = std::make_shared(element::f32, PartialShape::dynamic()); auto M = std::make_shared(element::f32, PartialShape::dynamic()); - X->set_friendly_name("X"); - Y->set_friendly_name("Y"); - M->set_friendly_name("M"); // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters @@ -184,7 +190,13 @@ TEST(SmartReshapeTests, LoopStaticParameters) { ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible(PartialShape::dynamic())); ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible(PartialShape::dynamic())); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{ + {f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}}, + {f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}}, + {f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({})); ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10})); @@ -200,9 +212,6 @@ TEST(SmartReshapeTests, LoopDynamicParameters) { auto X = std::make_shared(element::f32, PartialShape::dynamic()); auto Y = std::make_shared(element::f32, PartialShape::dynamic()); auto M = std::make_shared(element::f32, PartialShape::dynamic()); - X->set_friendly_name("X"); - Y->set_friendly_name("Y"); - M->set_friendly_name("M"); // Set up the cell body, a function from (Xi, Yi) -> (Zo) // Body parameters @@ -249,7 +258,13 @@ TEST(SmartReshapeTests, LoopDynamicParameters) { ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible(PartialShape::dynamic())); ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible(PartialShape::dynamic())); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {32, 10, 1}}, {"M", {32, 1, 10}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{ + {f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}}, + {f->get_parameters()[1]->get_friendly_name(), {32, 10, 1}}, + {f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({})); ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10})); @@ -267,9 +282,6 @@ TEST(SmartReshapeTests, LoopParentParametersUsedInBody) { auto add_Y = std::make_shared(Y, std::make_shared(ngraph::element::f32, ngraph::Shape{}, std::vector{0.f})); auto M = std::make_shared(element::f32, PartialShape::dynamic()); - X->set_friendly_name("X"); - Y->set_friendly_name("Y"); - M->set_friendly_name("M"); // Set up the cell body, a function from (Xi, add_Y) -> (Zo) // Body parameters @@ -317,7 +329,13 @@ TEST(SmartReshapeTests, LoopParentParametersUsedInBody) { ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible(PartialShape::dynamic())); ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible(PartialShape::dynamic())); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {4, 3, 2}}, {"Y", {4, 3, 2}}, {"M", {4, 3, 2}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{ + {f->get_parameters()[0]->get_friendly_name(), {4, 3, 2}}, + {f->get_parameters()[1]->get_friendly_name(), {4, 3, 2}}, + {f->get_parameters()[2]->get_friendly_name(), {4, 3, 2}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({})); ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({4, 3, 2})); @@ -335,9 +353,6 @@ TEST(SmartReshapeTests, TensorIteratorParentParameterUsedInBody) { auto add_Y = std::make_shared(Y, std::make_shared(ngraph::element::f32, ngraph::Shape{}, std::vector{0.f})); auto M = std::make_shared(element::f32, Shape{1, 1, 1}); - X->set_friendly_name("X"); - Y->set_friendly_name("Y"); - M->set_friendly_name("M"); // Set up the cell body, a function from (Xi, add_Y) -> (Zo) // Body parameters @@ -379,7 +394,13 @@ TEST(SmartReshapeTests, TensorIteratorParentParameterUsedInBody) { ASSERT_TRUE(network.getFunction()->get_results()[2]->get_output_partial_shape(0).compatible({1, 1, 1})); ASSERT_TRUE(network.getFunction()->get_results()[3]->get_output_partial_shape(0).compatible({1, 1, 1})); - ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{{"X", {32, 1, 10}}, {"Y", {1, 1, 1}}, {"M", {32, 1, 10}}})); + auto unh = std::make_shared(); + init_unique_names(f, unh); + ASSERT_NO_THROW(network.reshape(InferenceEngine::ICNNNetwork::InputShapes{ + {f->get_parameters()[0]->get_friendly_name(), {32, 1, 10}}, + {f->get_parameters()[1]->get_friendly_name(), {1, 1, 1}}, + {f->get_parameters()[2]->get_friendly_name(), {32, 1, 10}}})); + check_unique_names(f, unh); ASSERT_TRUE(network.getFunction()->get_results()[0]->get_output_partial_shape(0).compatible({})); ASSERT_TRUE(network.getFunction()->get_results()[1]->get_output_partial_shape(0).compatible({32, 1, 10})); diff --git a/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp b/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp index c479da63ddc..28e7959f65d 100644 --- a/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp +++ b/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.cpp @@ -244,3 +244,15 @@ void TransformationTestsF::accuracy_check(std::shared_ptr ref_functio GTEST_FATAL_FAILURE_("Unknown failure occurred."); } } + +void init_unique_names(std::shared_ptr f, const std::shared_ptr& unh) { + ngraph::pass::Manager manager; + manager.register_pass(unh); + manager.run_passes(f); +} + +void check_unique_names(std::shared_ptr f, const std::shared_ptr& unh) { + ngraph::pass::Manager manager; + manager.register_pass(unh, true); + manager.run_passes(f); +} diff --git a/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp b/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp index 40dd927b2e7..18af1703109 100644 --- a/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp +++ b/src/tests/ie_test_utils/common_test_utils/ngraph_test_utils.hpp @@ -90,3 +90,7 @@ private: bool m_soft_names_comparison{true}; bool m_enable_accuracy_check{false}; }; + +void init_unique_names(std::shared_ptr f, const std::shared_ptr& unh); + +void check_unique_names(std::shared_ptr f, const std::shared_ptr& unh);