[GPU] Disable oneDNN post-op Prelu in FC,gemm (#17084)
* [GPU] Disable oneDNN post-op relu Only disable Prelu fusion in Fc, gemm - check additional data input Signed-off-by: hyunback <hyunback.kim@intel.com>
This commit is contained in:
@@ -692,7 +692,8 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
|
||||
};
|
||||
|
||||
auto fuse_activation_f = [&](activation_node& activation_node) {
|
||||
if (supports_immad && activation_node.get_primitive()->activation_function == cldnn::activation_func::hyperbolic_tan) {
|
||||
auto activation_func = activation_node.get_primitive()->activation_function;
|
||||
if (supports_immad && activation_func == cldnn::activation_func::hyperbolic_tan) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -706,12 +707,17 @@ void prepare_primitive_fusing::fuse_simple_primitives(program &p) {
|
||||
if (_lo.get_optimization_attributes().use_onednn_impls) {
|
||||
if (input.is_type<reshape>() || input.is_type<concatenation>())
|
||||
return;
|
||||
|
||||
auto additional_params_input = activation_node.get_primitive()->additional_params_input;
|
||||
if (activation_func == cldnn::activation_func::relu_negative_slope && !additional_params_input.empty() &&
|
||||
(input.is_type<fully_connected>() || input.is_type<gemm>())) {
|
||||
// prelu fusion is not implemented in oneDNN3.1 (CVS-108233)
|
||||
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
|
||||
try {
|
||||
onednn::convert_activation_func(activation_node.get_primitive()->activation_function);
|
||||
onednn::convert_activation_func(activation_func);
|
||||
} catch (...) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -617,4 +617,44 @@ INSTANTIATE_TEST_SUITE_P(fusings_gpu, fc_fp16_eltwise_sum, ::testing::ValuesIn(s
|
||||
fully_connected_test_params{ CASE_FC_FP16_3D_2, 2, 3 },
|
||||
}));
|
||||
|
||||
class fc_fp32_activation_prelu : public FullyConnectedFusingTestOneDNN {};
|
||||
TEST_P(fc_fp32_activation_prelu, basic) {
|
||||
auto p = GetParam();
|
||||
create_topologies(
|
||||
input_layout("input", get_input_layout(p)),
|
||||
data("weights", get_mem(get_weights_layout(p))),
|
||||
data("bias", get_mem(get_bias_layout(p))),
|
||||
data("data", get_mem(get_bias_layout(p))),
|
||||
fully_connected("fc_prim", input_info("input"), "weights", "bias", padding(), get_output_dim_size(p), get_input_weights_rank(p)),
|
||||
activation("activation", input_info("fc_prim"), "data", activation_func::relu_negative_slope),
|
||||
reorder("reorder_bfyx", input_info("activation"), p.default_format, data_types::f32)
|
||||
);
|
||||
|
||||
tolerance = 1e-5f;
|
||||
execute(p);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(fusings_gpu, fc_fp32_activation_prelu, ::testing::ValuesIn(std::vector<fully_connected_test_params>{
|
||||
fully_connected_test_params{ CASE_FC_FP32_1, 3, 3 }
|
||||
}));
|
||||
|
||||
class fc_fp32_activation_relu : public FullyConnectedFusingTestOneDNN {};
|
||||
TEST_P(fc_fp32_activation_relu, basic) {
|
||||
auto p = GetParam();
|
||||
create_topologies(
|
||||
input_layout("input", get_input_layout(p)),
|
||||
data("weights", get_mem(get_weights_layout(p))),
|
||||
data("bias", get_mem(get_bias_layout(p))),
|
||||
fully_connected("fc_prim", input_info("input"), "weights", "bias", padding(), get_output_dim_size(p), get_input_weights_rank(p)),
|
||||
activation("activation", input_info("fc_prim"), activation_func::relu_negative_slope),
|
||||
reorder("reorder_bfyx", input_info("activation"), p.default_format, data_types::f32)
|
||||
);
|
||||
|
||||
tolerance = 1e-5f;
|
||||
execute(p);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(fusings_gpu, fc_fp32_activation_relu, ::testing::ValuesIn(std::vector<fully_connected_test_params>{
|
||||
fully_connected_test_params{ CASE_FC_FP32_1, 2, 3 }
|
||||
}));
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user