Skip to content

Commit 1e3160d

Browse files
authored
[GPU] enabling more layer fusions (openvinotoolkit#26592)
### Details: - added `gelu_tanh` to the list of activations supported by OneDNN - allowed `quantize` to be fused into `mvn` ### Tickets: - 151419
1 parent aa6ae5d commit 1e3160d

File tree

3 files changed

+20
-21
lines changed

3 files changed

+20
-21
lines changed

src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -534,11 +534,11 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
534534
return does_support_fusings;
535535
};
536536

537-
auto mvn_supports_fusings = [](mvn_node& node, bool for_eltwise = false) -> bool {
537+
auto mvn_supports_fusings = [](mvn_node& node) -> bool {
538538
auto in_layout = node.get_input_layout(0);
539539
if (node.get_primitive()->requires_alignment(in_layout.get_partial_shape()))
540540
return false;
541-
return data_type_traits::is_i8_u8(in_layout.data_type) || for_eltwise;
541+
return true;
542542
};
543543

544544
auto dts_supports_fusings = [](depth_to_space_node& node) -> bool {
@@ -896,7 +896,7 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
896896
can_fuse_parents[i] = (parents[i].first->is_type<convolution>() &&
897897
conv_supports_fusings(parents[i].first->as<convolution>())) ||
898898
(parents[i].first->is_type<mvn>() &&
899-
mvn_supports_fusings(parents[i].first->as<mvn>(), true)) ||
899+
mvn_supports_fusings(parents[i].first->as<mvn>())) ||
900900
(parents[i].first->is_type<group_normalization>()) ||
901901
(parents[i].first->is_type<deconvolution>()) ||
902902
(parents[i].first->is_type<permute>()) ||

src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ dnnl::algorithm convert_activation_func(cldnn::activation_func func) {
447447
case cldnn::activation_func::relu: return dnnl::algorithm::eltwise_relu;
448448
case cldnn::activation_func::relu_negative_slope: return dnnl::algorithm::eltwise_relu;
449449
case cldnn::activation_func::gelu: return dnnl::algorithm::eltwise_gelu_erf;
450+
case cldnn::activation_func::gelu_tanh: return dnnl::algorithm::eltwise_gelu_tanh;
450451
case cldnn::activation_func::elu: return dnnl::algorithm::eltwise_elu;
451452
case cldnn::activation_func::mish: return dnnl::algorithm::eltwise_mish;
452453
case cldnn::activation_func::swish: return dnnl::algorithm::eltwise_swish;

src/plugins/intel_gpu/tests/unit/fusions/mvn_fusion_test.cpp

+16-18
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,14 @@ TEST_P(mvn_scale_quantize_i8, basic) {
158158
}
159159

160160
INSTANTIATE_TEST_SUITE_P(fusings_gpu, mvn_scale_quantize_i8, ::testing::ValuesIn(std::vector<mvn_test_params>{
161-
// Full fusing for fp input not supported yet, it may lead to output padding and non-optimal kernel
162-
// mvn_test_params{ CASE_MVN_F32_1, 2, 4 },
163-
// mvn_test_params{ CASE_MVN_F32_2, 2, 4 },
164-
// mvn_test_params{ CASE_MVN_3D_F32_1, 2, 4 },
165-
// mvn_test_params{ CASE_MVN_3D_F32_2, 2, 4 },
166-
// mvn_test_params{ CASE_MVN_F16_1, 2, 4 },
167-
// mvn_test_params{ CASE_MVN_F16_2, 2, 4 },
168-
// mvn_test_params{ CASE_MVN_3D_F16_1, 2, 4 },
169-
// mvn_test_params{ CASE_MVN_3D_F16_2, 2, 4 },
161+
mvn_test_params{ CASE_MVN_F32_1, 2, 2, 4 },
162+
mvn_test_params{ CASE_MVN_F32_2, 2, 2, 4 },
163+
mvn_test_params{ CASE_MVN_3D_F32_1, 2, 2, 4 },
164+
mvn_test_params{ CASE_MVN_3D_F32_2, 2, 2, 4 },
165+
mvn_test_params{ CASE_MVN_F16_1, 2, 2, 4 },
166+
mvn_test_params{ CASE_MVN_F16_2, 2, 2, 4 },
167+
mvn_test_params{ CASE_MVN_3D_F16_1, 2, 2, 4 },
168+
mvn_test_params{ CASE_MVN_3D_F16_2, 2, 2, 4 },
170169
mvn_test_params{ CASE_MVN_I8_1, 2, 2, 4 },
171170
mvn_test_params{ CASE_MVN_I8_2, 2, 2, 4 },
172171
mvn_test_params{ CASE_MVN_I8_3, 2, 2, 4 },
@@ -207,15 +206,14 @@ TEST_P(mvn_scale_activation_eltwise_fp32_quantize_i8, basic) {
207206
}
208207

209208
INSTANTIATE_TEST_SUITE_P(fusings_gpu, mvn_scale_activation_eltwise_fp32_quantize_i8, ::testing::ValuesIn(std::vector<mvn_test_params>{
210-
// Full using for fp input not supported yet, it may lead to output padding and non-optimal kernel
211-
// mvn_test_params{ CASE_MVN_F32_1, 2, 7 },
212-
// mvn_test_params{ CASE_MVN_F32_2, 2, 7 },
213-
// mvn_test_params{ CASE_MVN_3D_F32_1, 2, 7 },
214-
// mvn_test_params{ CASE_MVN_3D_F32_2, 2, 7 },
215-
// mvn_test_params{ CASE_MVN_F16_1, 2, 7 },
216-
// mvn_test_params{ CASE_MVN_F16_2, 2, 7 },
217-
// mvn_test_params{ CASE_MVN_3D_F16_1, 2, 7 },
218-
// mvn_test_params{ CASE_MVN_3D_F16_2, 2, 7 },
209+
mvn_test_params{ CASE_MVN_F32_1, 2, 4, 6 },
210+
mvn_test_params{ CASE_MVN_F32_2, 2, 4, 6 },
211+
mvn_test_params{ CASE_MVN_3D_F32_1, 2, 4, 6 },
212+
mvn_test_params{ CASE_MVN_3D_F32_2, 2, 4, 6 },
213+
mvn_test_params{ CASE_MVN_F16_1, 2, 4, 6 },
214+
mvn_test_params{ CASE_MVN_F16_2, 2, 4, 6 },
215+
mvn_test_params{ CASE_MVN_3D_F16_1, 2, 4, 6 },
216+
mvn_test_params{ CASE_MVN_3D_F16_2, 2, 4, 6 },
219217
mvn_test_params{ CASE_MVN_I8_1, 2, 4, 6 },
220218
mvn_test_params{ CASE_MVN_I8_2, 2, 4, 6 },
221219
mvn_test_params{ CASE_MVN_I8_3, 2, 4, 6 },

0 commit comments

Comments
 (0)