Skip to content

Commit

Permalink
[GPU] enabling more layer fusions (openvinotoolkit#26592)
Browse files Browse the repository at this point in the history
### Details:
 - added `gelu_tanh` to the list of activations supported by OneDNN
 - allowed `quantize` to be fused into `mvn`

### Tickets:
 - 151419
  • Loading branch information
e-ddykim authored Sep 25, 2024
1 parent aa6ae5d commit 1e3160d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
return does_support_fusings;
};

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

auto dts_supports_fusings = [](depth_to_space_node& node) -> bool {
Expand Down Expand Up @@ -896,7 +896,7 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
can_fuse_parents[i] = (parents[i].first->is_type<convolution>() &&
conv_supports_fusings(parents[i].first->as<convolution>())) ||
(parents[i].first->is_type<mvn>() &&
mvn_supports_fusings(parents[i].first->as<mvn>(), true)) ||
mvn_supports_fusings(parents[i].first->as<mvn>())) ||
(parents[i].first->is_type<group_normalization>()) ||
(parents[i].first->is_type<deconvolution>()) ||
(parents[i].first->is_type<permute>()) ||
Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_gpu/src/graph/impls/onednn/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ dnnl::algorithm convert_activation_func(cldnn::activation_func func) {
case cldnn::activation_func::relu: return dnnl::algorithm::eltwise_relu;
case cldnn::activation_func::relu_negative_slope: return dnnl::algorithm::eltwise_relu;
case cldnn::activation_func::gelu: return dnnl::algorithm::eltwise_gelu_erf;
case cldnn::activation_func::gelu_tanh: return dnnl::algorithm::eltwise_gelu_tanh;
case cldnn::activation_func::elu: return dnnl::algorithm::eltwise_elu;
case cldnn::activation_func::mish: return dnnl::algorithm::eltwise_mish;
case cldnn::activation_func::swish: return dnnl::algorithm::eltwise_swish;
Expand Down
34 changes: 16 additions & 18 deletions src/plugins/intel_gpu/tests/unit/fusions/mvn_fusion_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,14 @@ TEST_P(mvn_scale_quantize_i8, basic) {
}

INSTANTIATE_TEST_SUITE_P(fusings_gpu, mvn_scale_quantize_i8, ::testing::ValuesIn(std::vector<mvn_test_params>{
// Full fusing for fp input not supported yet, it may lead to output padding and non-optimal kernel
// mvn_test_params{ CASE_MVN_F32_1, 2, 4 },
// mvn_test_params{ CASE_MVN_F32_2, 2, 4 },
// mvn_test_params{ CASE_MVN_3D_F32_1, 2, 4 },
// mvn_test_params{ CASE_MVN_3D_F32_2, 2, 4 },
// mvn_test_params{ CASE_MVN_F16_1, 2, 4 },
// mvn_test_params{ CASE_MVN_F16_2, 2, 4 },
// mvn_test_params{ CASE_MVN_3D_F16_1, 2, 4 },
// mvn_test_params{ CASE_MVN_3D_F16_2, 2, 4 },
mvn_test_params{ CASE_MVN_F32_1, 2, 2, 4 },
mvn_test_params{ CASE_MVN_F32_2, 2, 2, 4 },
mvn_test_params{ CASE_MVN_3D_F32_1, 2, 2, 4 },
mvn_test_params{ CASE_MVN_3D_F32_2, 2, 2, 4 },
mvn_test_params{ CASE_MVN_F16_1, 2, 2, 4 },
mvn_test_params{ CASE_MVN_F16_2, 2, 2, 4 },
mvn_test_params{ CASE_MVN_3D_F16_1, 2, 2, 4 },
mvn_test_params{ CASE_MVN_3D_F16_2, 2, 2, 4 },
mvn_test_params{ CASE_MVN_I8_1, 2, 2, 4 },
mvn_test_params{ CASE_MVN_I8_2, 2, 2, 4 },
mvn_test_params{ CASE_MVN_I8_3, 2, 2, 4 },
Expand Down Expand Up @@ -207,15 +206,14 @@ TEST_P(mvn_scale_activation_eltwise_fp32_quantize_i8, basic) {
}

INSTANTIATE_TEST_SUITE_P(fusings_gpu, mvn_scale_activation_eltwise_fp32_quantize_i8, ::testing::ValuesIn(std::vector<mvn_test_params>{
// Full using for fp input not supported yet, it may lead to output padding and non-optimal kernel
// mvn_test_params{ CASE_MVN_F32_1, 2, 7 },
// mvn_test_params{ CASE_MVN_F32_2, 2, 7 },
// mvn_test_params{ CASE_MVN_3D_F32_1, 2, 7 },
// mvn_test_params{ CASE_MVN_3D_F32_2, 2, 7 },
// mvn_test_params{ CASE_MVN_F16_1, 2, 7 },
// mvn_test_params{ CASE_MVN_F16_2, 2, 7 },
// mvn_test_params{ CASE_MVN_3D_F16_1, 2, 7 },
// mvn_test_params{ CASE_MVN_3D_F16_2, 2, 7 },
mvn_test_params{ CASE_MVN_F32_1, 2, 4, 6 },
mvn_test_params{ CASE_MVN_F32_2, 2, 4, 6 },
mvn_test_params{ CASE_MVN_3D_F32_1, 2, 4, 6 },
mvn_test_params{ CASE_MVN_3D_F32_2, 2, 4, 6 },
mvn_test_params{ CASE_MVN_F16_1, 2, 4, 6 },
mvn_test_params{ CASE_MVN_F16_2, 2, 4, 6 },
mvn_test_params{ CASE_MVN_3D_F16_1, 2, 4, 6 },
mvn_test_params{ CASE_MVN_3D_F16_2, 2, 4, 6 },
mvn_test_params{ CASE_MVN_I8_1, 2, 4, 6 },
mvn_test_params{ CASE_MVN_I8_2, 2, 4, 6 },
mvn_test_params{ CASE_MVN_I8_3, 2, 4, 6 },
Expand Down

0 comments on commit 1e3160d

Please sign in to comment.