Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[GPU] Fix move per channel eltwise pass (#26154)

Vladimir Paramuzovbd7dc80242ee
diff --git a/src/common/transformations/src/transformations/common_optimizations/move_eltwise_up_data_movement.cpp b/src/common/transformations/src/transformations/common_optimizations/move_eltwise_up_data_movement.cpp
index fd9e7417261..82efb3699b2 100644
--- a/src/common/transformations/src/transformations/common_optimizations/move_eltwise_up_data_movement.cpp
+++ b/src/common/transformations/src/transformations/common_optimizations/move_eltwise_up_data_movement.cpp
@@ -167,7 +167,8 @@ ov::pass::MoveEltwiseUpThroughDataMovPerChannel::MoveEltwiseUpThroughDataMovPerC
};
auto eltw_data_flow_in =
- ov::pass::pattern::wrap_type<ov::op::v1::Reshape, ov::op::v0::Squeeze, ov::op::v0::Unsqueeze>();
+ ov::pass::pattern::wrap_type<ov::op::v1::Reshape, ov::op::v0::Squeeze, ov::op::v0::Unsqueeze>(
+ pattern::consumers_count(1));
auto eltw_const_in = ov::pass::pattern::wrap_type<ov::op::v0::Constant>(const_predicate);
auto eltwise_pattern =
ov::pass::pattern::wrap_type<ov::op::util::BinaryElementwiseArithmetic>({eltw_data_flow_in, eltw_const_in},
diff --git a/src/common/transformations/tests/common_optimizations/move_eltwise_up_data_movement_test.cpp b/src/common/transformations/tests/common_optimizations/move_eltwise_up_data_movement_test.cpp
index 374cd208fef..07eb3ec2b3e 100644
--- a/src/common/transformations/tests/common_optimizations/move_eltwise_up_data_movement_test.cpp
+++ b/src/common/transformations/tests/common_optimizations/move_eltwise_up_data_movement_test.cpp
@@ -446,6 +446,26 @@ TEST_F(MoveEltwiseUpThroughDataMovTest, PerChannelEltwiseSqueezeIllegal_1) {
manager.register_pass<ov::pass::MoveEltwiseUpThroughDataMov>();
}
+TEST_F(MoveEltwiseUpThroughDataMovTest, PerChannelEltwiseSqueezeIllegal_2) {
+ const ov::Shape shape{10, 20, 1, 1};
+ // Data movement op with multiple consumers is not applicable
+ auto input = std::make_shared<ov::opset8::Parameter>(ov::element::f32, shape);
+
+ auto squeeze_const = ov::opset8::Constant::create(ov::element::i64, ov::Shape{}, {2}); // {10, 20, 1}
+ auto squeeze = std::make_shared<ov::op::v0::Squeeze>(input, squeeze_const);
+
+ auto per_channel_const1 = ov::opset8::Constant::create(ov::element::f32, {10, 1, 1}, {0.5});
+ auto add1 = std::make_shared<ov::opset8::Add>(squeeze, per_channel_const1);
+
+ auto per_channel_const2 = ov::opset8::Constant::create(ov::element::f32, {10, 1, 1}, {0.5});
+ auto add2 = std::make_shared<ov::opset8::Add>(squeeze, per_channel_const2);
+
+ auto add3 = std::make_shared<ov::opset8::Add>(add1, add2);
+
+ model = std::make_shared<ov::Model>(ov::NodeVector{add3}, ov::ParameterVector{input});
+ manager.register_pass<ov::pass::MoveEltwiseUpThroughDataMov>();
+}
+
TEST_F(MoveEltwiseUpThroughDataMovTest, PerChannelReshapeMultiply) {
const ov::Shape shape{1, 3, 20};
const std::vector<int64_t> target_shape = {1, 3, 4, 5};
diff --git a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
index f5cb6783d4b..fc62f68af2f 100644
--- a/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
+++ b/src/plugins/intel_gpu/src/plugin/transformations_pipeline.cpp
@@ -794,7 +794,7 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
ov::op::v1::Broadcast::get_type_info_static(),
ov::op::v3::Broadcast::get_type_info_static(),
};
- manager.register_pass<ov::pass::MoveEltwiseUpThroughDataMov>(allowed_data_movement_ops);
+ manager.register_pass<ov::pass::MoveEltwiseUpThroughDataMovScalar>(allowed_data_movement_ops);
manager.register_pass<ov::intel_gpu::ClampFP16Output>();
manager.register_pass<ov::intel_gpu::ConvertMatMulToFullyConnected>();
@@ -842,6 +842,10 @@ void TransformationsPipeline::apply(std::shared_ptr<ov::Model> func) {
manager.register_pass<ov::intel_gpu::SwiGLUFusion>();
manager.register_pass<ov::intel_gpu::IndirectKVCache>();
manager.register_pass<ov::intel_gpu::ConvertConvolutionToInternal>();
+
+ // This pass should be done after asymmetric quantization matching as it can move zp subtraction upper in the graph
+ manager.register_pass<ov::pass::MoveEltwiseUpThroughDataMovPerChannel>();
+
manager.register_pass<ov::intel_gpu::ConvertStridedSlicesToVariadicSplit>();
const size_t zp_pad_size = device_info.supports_immad ? 16 : 32;