OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[GPU] fix the wrong pattern of reshape sinking (#29084)
yanlan song2f356f206978
diff --git a/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cpp b/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cppindex 871631c37b0..98a4552e60b 100644--- a/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cpp+++ b/src/plugins/intel_gpu/src/plugin/transformations/sink_reshape.cpp@@ -73,7 +73,7 @@ SinkReshape::SinkReshape() {return is_suitable_reshape(reshape) && is_suitable_parent(reshape->get_input_node_shared_ptr(0));};- auto reshape_m = wrap_type<v1::Reshape>(reshape_predicate);+ auto reshape_m = wrap_type<v1::Reshape>(reshape_predicate && consumers_count(1));auto transpose_const_m = wrap_type<v0::Constant>();auto transpose_m = wrap_type<v1::Transpose>({reshape_m, transpose_const_m});diff --git a/src/plugins/intel_gpu/tests/unit/transformations/sink_reshape_test.cpp b/src/plugins/intel_gpu/tests/unit/transformations/sink_reshape_test.cppindex 2cc594b1d31..52570de5d92 100644--- a/src/plugins/intel_gpu/tests/unit/transformations/sink_reshape_test.cpp+++ b/src/plugins/intel_gpu/tests/unit/transformations/sink_reshape_test.cpp@@ -123,3 +123,35 @@ INSTANTIATE_TEST_SUITE_P(smoke_TransformationTests_reshape_transpose, SinkReshap::testing::ValuesIn(eligible_rotation),::testing::ValuesIn(eligible_reshape)),SinkReshapeTests::get_test_case_name);++TEST_F(TransformationTestsF, SinkReshapeFalsePattern) {+ ov::Strides strides{1, 1};+ ov::Strides dilations{1, 1};+ ov::CoordinateDiff pads_begin{0, 0};+ ov::CoordinateDiff pads_end{0, 0};+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, ov::PartialShape{ 2, 3, 12, 12 });+ auto weights_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{ 4, 3, 3, 3 }, { 1 });+ auto conv = std::make_shared<ov::op::v1::Convolution>(input,+ weights_const,+ strides,+ pads_begin,+ pads_end,+ dilations,+ ov::op::PadType::EXPLICIT);+ auto reshape_const = ov::opset1::Constant::create(ov::element::i32, {3}, std::vector<int>{2, 4, 100});+ auto reshape = std::make_shared<ov::opset1::Reshape>(conv, reshape_const, true);+ auto transpose_const = ov::opset1::Constant::create(ov::element::i32, {3}, std::vector<int>{0 ,2, 1});+ auto transpose = std::make_shared<ov::opset1::Transpose>(reshape, transpose_const);+ auto softmax = std::make_shared<ov::op::v8::Softmax>(transpose);+ auto input2 = ov::opset1::Constant::create(ov::element::f32, ov::Shape{ 2, 100, 4 }, { 1 });+ auto matmul = std::make_shared<ov::opset1::MatMul>(reshape, input2, false, false);+ model = std::make_shared<ov::Model>(ov::NodeVector{softmax, matmul}, ov::ParameterVector{input});+ ov::pass::Manager manager;+ manager.register_pass<ConvertConvolutionToInternal>();+ manager.register_pass<SinkReshape>();+ OV_ASSERT_NO_THROW(manager.run_passes(model));+ model_ref = std::make_shared<ov::Model>(ov::NodeVector{softmax, matmul}, ov::ParameterVector{input});+ ov::pass::Manager manager_ref;+ manager_ref.register_pass<ConvertConvolutionToInternal>();+ manager.run_passes(model_ref);+}