From a82ed83792e962096ecae7b278be209f08765921 Mon Sep 17 00:00:00 2001 From: Luwei Zhou Date: Sat, 16 Sep 2023 01:06:28 +0800 Subject: [PATCH] [Fix] [Feature] Apply WA to remove gemm legacy on avx512. [FORK][FEATURE] cpu: remove gemm legacy on avx512. --- src/cpu/rnn/ref_rnn.hpp | 11 ++++++++--- src/cpu/x64/gemm/gemm_info.cpp | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cpu/rnn/ref_rnn.hpp b/src/cpu/rnn/ref_rnn.hpp index 7198f8b432f..8abbddbe930 100644 --- a/src/cpu/rnn/ref_rnn.hpp +++ b/src/cpu/rnn/ref_rnn.hpp @@ -305,12 +305,17 @@ struct _ref_rnn_common_t : public primitive_t { (rnn_.is_bf16_conf() || rnn_.is_f32_conf())); if (!ok) return status::unimplemented; - +#if !__BUILD_GEMM_AVX512 + // WA: enable gru brgemm on avx512 f32 to avoid dien.xml regression when removing gemm legacy on avx512. + const auto enable_brgemm_gru = mayiuse(avx512_core) && rnn_.is_cell_dt_f32(); +#else + const auto enable_brgemm_gru = false; +#endif // Support for GRU / AUGRU cell in BRGEMM-based implementation is // limited by forward_inference pass for now, all_f32 is disabled - // due to performance degradation. + // due to performance degradation except the case GEMM legacy is removed on avx512 core. // TODO: Improve GRU / AUGRU coverage in BRGEMM-based implementation - ok = IMPLICATION(rnn_.is_orig_gru, + ok = IMPLICATION(rnn_.is_orig_gru && !enable_brgemm_gru, this->desc()->prop_kind == forward_inference && !rnn_.is_cell_dt_f32()); if (!ok) return status::unimplemented; diff --git a/src/cpu/x64/gemm/gemm_info.cpp b/src/cpu/x64/gemm/gemm_info.cpp index acab57ca9eb..eef0772d89b 100644 --- a/src/cpu/x64/gemm/gemm_info.cpp +++ b/src/cpu/x64/gemm/gemm_info.cpp @@ -360,6 +360,7 @@ void gemm_info_t::jit_init(void) { static std::once_flag initialized; static std::atomic st(dnnl_success); std::call_once(initialized, [&, um] { + MAYBE_UNUSED(um); #if __BUILD_GEMM_AVX512 const bool b_is_s8 = data_traits::data_type == data_type::s8; #endif