From 1ceb9729e949e56b43b70d32ec6c7b7f606a4ac4 Mon Sep 17 00:00:00 2001 From: Vladislav Golubev Date: Mon, 28 Feb 2022 14:06:17 +0300 Subject: [PATCH] [CPU] friendly name duplication fixed for the TypeRelaxed case (#10486) --- .../move_eltwise_up_data_movement.cpp | 3 ++ .../move_eltwise_up_data_movement_test.cpp | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/plugins/intel_cpu/src/ngraph_transformations/move_eltwise_up_data_movement.cpp b/src/plugins/intel_cpu/src/ngraph_transformations/move_eltwise_up_data_movement.cpp index 74eb8dc90cb..ab5717900f4 100644 --- a/src/plugins/intel_cpu/src/ngraph_transformations/move_eltwise_up_data_movement.cpp +++ b/src/plugins/intel_cpu/src/ngraph_transformations/move_eltwise_up_data_movement.cpp @@ -95,6 +95,9 @@ ov::intel_cpu::MoveEltwiseUpThroughDataMov::MoveEltwiseUpThroughDataMov() { ngraph::OutputVector eltwiseInputs = eltwise->input_values(); eltwiseInputs[0] = child->input_value(0); auto newEltwise = eltwise->clone_with_new_inputs(eltwiseInputs); + // WA: it's necessary to set empty friendly name here + // to avoid name duplication in TypeRelaxed cases + newEltwise->set_friendly_name(""); ngraph::copy_runtime_info(eltwise, newEltwise); ngraph::OutputVector childInputs = child->input_values(); diff --git a/src/tests/unit/cpu/ngraph_transformations/move_eltwise_up_data_movement_test.cpp b/src/tests/unit/cpu/ngraph_transformations/move_eltwise_up_data_movement_test.cpp index 1358440ec98..969aa008c98 100644 --- a/src/tests/unit/cpu/ngraph_transformations/move_eltwise_up_data_movement_test.cpp +++ b/src/tests/unit/cpu/ngraph_transformations/move_eltwise_up_data_movement_test.cpp @@ -6,6 +6,7 @@ #include #include +#include "ngraph_ops/type_relaxed.hpp" #include #include @@ -49,6 +50,38 @@ TEST_F(MoveEltwiseUpThroughDataMovTest, SingleUnaryEltwise) { } } +TEST_F(MoveEltwiseUpThroughDataMovTest, TypeRelaxedEltwise) { + const ngraph::Shape shape{1, 3, 224, 224}; + const std::vector input_order = {3, 2, 1, 0}; + { + auto input = std::make_shared(ngraph::element::f32, shape); + auto intermediate_op = std::make_shared(input, 0, 6); + + auto transpose_const = + ngraph::opset8::Constant::create(ngraph::element::i64, ngraph::Shape{input_order.size()}, input_order); + auto transpose = std::make_shared(intermediate_op, transpose_const); + + auto mul_const = ngraph::opset8::Constant::create(ngraph::element::f32, {}, {2.f}); + auto multiply = std::make_shared>(transpose, mul_const); + + function = std::make_shared(ngraph::NodeVector{multiply}, ngraph::ParameterVector{input}); + manager.register_pass(); + } + { + auto input = std::make_shared(ngraph::element::f32, shape); + auto intermediate_op = std::make_shared(input, 0, 6); + + auto mul_const = ngraph::opset8::Constant::create(ngraph::element::f32, {}, {2.f}); + auto multiply = std::make_shared>(intermediate_op, mul_const); + + auto transpose_const = ngraph::opset8::Constant::create(ngraph::element::i64, ngraph::Shape{input_order.size()}, input_order); + auto transpose = std::make_shared(multiply, transpose_const); + + function_ref = + std::make_shared(ngraph::NodeVector{transpose}, ngraph::ParameterVector{input}); + } +} + TEST_F(MoveEltwiseUpThroughDataMovTest, EltwiseSequence) { const ngraph::Shape shape{1, 3, 224, 224}; const std::vector input_order = {1, 2, 0, 3};