Skip to content

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

Resolve accuracy issue from fusing prelu (#29754)

Min, Byungil89c9c7ae8edc
diff --git a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp
index 538688d7272..466019c386c 100644
--- a/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp
+++ b/src/plugins/intel_gpu/src/graph/graph_optimizer/prepare_primitive_fusing.cpp
@@ -742,6 +742,15 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
// prelu fusion is not implemented in oneDNN3.1 (CVS-108233)
return;
}
+
+ // Fusing prelu to multi batch onednn conv caused an accuracy issue. Blocked fusing of the case.
+ auto input_layout = input.get_output_layout();
+ if (input.is_type<convolution>() && (lo.get_preferred_impl_type(input, format::any /*dummy*/) == impl_types::onednn) &&
+ activation_func == cldnn::activation_func::relu_negative_slope &&
+ input_layout.is_static() && input_layout.batch() > 1) {
+ return;
+ }
+
// Activation should not be fused if oneDNN does NOT support it
if (lo.is_primitive_implemented_for_onednn(input)) {
#ifdef ENABLE_ONEDNN_FOR_GPU
diff --git a/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp b/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp
index c64f64906d8..64aff8b8568 100644
--- a/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp
+++ b/src/plugins/intel_gpu/tests/unit/fusions/convolution_fusion_test.cpp
@@ -527,6 +527,14 @@ public:
#define CASE_CONV_ELTW_i8_4 { 1, 16, 1, 4 }, { 1, 16, 1, 2 }, { 1, 16, 1, 1 }, { 16, 16, 1, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::i8, format::b_fs_yx_fsv16, data_types::i8, format::os_is_yx_osv16_isv16, data_types::f32, format::bfyx
#define CASE_CONV_ELTW_i8_5 { 1, 16, 1, 4, 1 }, { 1, 16, 1, 2, 1 }, { 1, 16, 2, 1, 1 }, { 16, 16, 1, 3, 1 }, { 1, 1, 1 }, { 0, 0, 0 }, { 1, 1, 1 }, 1, data_types::i8, format::bfzyx, data_types::i8, format::oizyx, data_types::f32, format::bfzyx
+#define CASE_MUL_BATCH_CONV_FP16_1 { 20, 15, 4, 5 }, { 20, 30, 2, 3 }, { 30, 15, 3, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::f16, format::bfyx, data_types::f16, format::bfyx, data_types::f16, format::bfyx
+#define CASE_MUL_BATCH_CONV_FP16_2 { 32, 16, 5, 5 }, { 32, 32, 3, 3 }, { 32, 16, 3, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::f16, format::bs_fs_yx_bsv16_fsv16, data_types::f16, format::os_is_yx_osv16_isv16, data_types::f16, format::bfyx
+#define CASE_MUL_BATCH_CONV_U8S8_1 { 32, 15, 4, 5 }, { 32, 30, 2, 3 }, { 30, 15, 3, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::u8, format::bfyx, data_types::i8, format::bfyx, data_types::f32, format::bfyx
+#define CASE_MUL_BATCH_CONV_U8S8_2 { 20, 15, 5, 5 }, { 20, 30, 3, 3 }, { 30, 15, 3, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::u8, format::bs_fs_yx_bsv16_fsv16, data_types::i8, format::os_is_yx_osv16_isv16, data_types::f32, format::bfyx
+#define CASE_MUL_BATCH_CONV_S8S8_1 { 32, 15, 4, 5 }, { 32, 30, 2, 3 }, { 30, 15, 3, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::i8, format::bfyx, data_types::i8, format::bfyx, data_types::f32, format::bfyx
+#define CASE_MUL_BATCH_CONV_S8S8_2 { 20, 15, 5, 5 }, { 20, 30, 3, 3 }, { 30, 15, 3, 3 }, { 1, 1 }, { 0, 0 }, { 1, 1 }, 1, data_types::i8, format::bs_fs_yx_bsv16_fsv16, data_types::i8, format::os_is_yx_osv16_isv16, data_types::f32, format::bfyx
+
+
/* ----------------------------------------------------------------------------------------------------- */
/* ---------------------------------------- FP32 convolution cases ------------------------------------- */
/* ----------------------------------------------------------------------------------------------------- */
@@ -1755,7 +1763,7 @@ TEST_P(conv_fp32_activation_eltwise_in_u8_fp32, basic) {
data("bias", get_mem(get_per_channel_layout(p))),
data("eltwise_data", get_mem(layout{ p.out_shape, data_types::i8, p.input_format })),
convolution("conv_prim", input_info("input"), "weights", "bias", p.groups, p.stride, p.dilation, p.pad, p.pad, format::is_grouped(get_weights_layout(p).format)),
- activation("activation", input_info("conv_prim"), activation_func::relu_negative_slope),
+ activation("activation", input_info("conv_prim"), activation_func::relu),
eltwise("sum", { input_info("activation"), input_info("eltwise_data") }, eltwise_mode::sum, data_types::f32),
reorder("reorder_bfyx", input_info("sum"), p.default_format, data_types::f32)
);
@@ -3119,6 +3127,11 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, conv_fp16_prelu_onednn, ::testing::ValuesI
convolution_test_params{ CASE_CONV_FP16_1, 2, 2, 4 },
}));
+INSTANTIATE_TEST_SUITE_P(fusings_gpu_multi_batch, conv_fp16_prelu_onednn, ::testing::ValuesIn(std::vector<convolution_test_params>{
+ convolution_test_params{ CASE_MUL_BATCH_CONV_FP16_1, 4, 4, 4 },
+ convolution_test_params{ CASE_MUL_BATCH_CONV_FP16_2, 4, 4, 4 },
+}));
+
class conv_int8_eltwise_onednn : public WeightsPrimitiveFusingTestOneDNN {};
TEST_P(conv_int8_eltwise_onednn, u8_eltwise_sum_out) {
auto p = GetParam();
@@ -3813,18 +3826,18 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, post_ops_optimizations_onednn_eltw_any_sum
convolution_test_params{ CASE_CONV_S8S8_3, 2, 2, 5 },
// cases with batch = 16
- convolution_test_params{ CASE_CONV_U8S8_10, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_S8S8_10, 2, 2, 5 },
+ convolution_test_params{ CASE_CONV_U8S8_10, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_S8S8_10, 2, 4, 5 },
// cases with batch = 32
- convolution_test_params{ CASE_CONV_U8S8_11, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_U8S8_12, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_U8S8_13, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_U8S8_14, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_S8S8_12, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_S8S8_13, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_S8S8_14, 2, 2, 5 },
- convolution_test_params{ CASE_CONV_S8S8_15, 2, 2, 5 },
+ convolution_test_params{ CASE_CONV_U8S8_11, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_U8S8_12, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_U8S8_13, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_U8S8_14, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_S8S8_12, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_S8S8_13, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_S8S8_14, 2, 4, 5 },
+ convolution_test_params{ CASE_CONV_S8S8_15, 2, 4, 5 },
}));
// Input range uses in 2 cases: not per-tensor output range or out_lo > out_hi