From 5bab17c967e4550f7168943605cdd8b93833d564 Mon Sep 17 00:00:00 2001 From: Dmitrii Zarukin Date: Tue, 13 Jul 2021 19:13:14 -0700 Subject: [PATCH] cpu: x64: fix applying non-zero offset to null pointer --- .../x64/jit_avx512_common_1x1_convolution.cpp | 5 +++-- src/cpu/x64/jit_brgemm_inner_product.cpp | 15 ++++++++------- .../x64/lrn/lrn_avx512_blocked_executor.hpp | 18 +++++++++--------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/cpu/x64/jit_avx512_common_1x1_convolution.cpp b/src/cpu/x64/jit_avx512_common_1x1_convolution.cpp index c503dd52214..3afd03aa75f 100644 --- a/src/cpu/x64/jit_avx512_common_1x1_convolution.cpp +++ b/src/cpu/x64/jit_avx512_common_1x1_convolution.cpp @@ -193,8 +193,9 @@ void jit_avx512_common_1x1_convolution_fwd_twith_groups() ? weights_d.blk_off(g, ocb, icb) diff --git a/src/cpu/x64/jit_brgemm_inner_product.cpp b/src/cpu/x64/jit_brgemm_inner_product.cpp index db034178ec1..0f19502c174 100644 --- a/src/cpu/x64/jit_brgemm_inner_product.cpp +++ b/src/cpu/x64/jit_brgemm_inner_product.cpp @@ -1131,13 +1131,14 @@ void brgemm_inner_product_bwd_weights_t::compute_diff_weights_and_bias( + a_buf_idx) * jbgp.gemm_batch_size * jbgp.os_block * jbgp.ic_block); - char *b_buffer = b_buffer_global - + types::data_type_size(jbgp.dst_dt) - * ((ti->ithr * os_chunks_per_thr + b_buf_idx) - * jbgp.gemm_batch_size * jbgp.os_block - * jbgp.LDB - + (ocb_l_idx % jbgp.nb_oc_blocking) - * jbgp.oc_block); + char *b_buffer = b_buffer_global ? b_buffer_global + + types::data_type_size(jbgp.dst_dt) + * ((ti->ithr * os_chunks_per_thr + b_buf_idx) + * jbgp.gemm_batch_size + * jbgp.os_block * jbgp.LDB + + (ocb_l_idx % jbgp.nb_oc_blocking) + * jbgp.oc_block) + : nullptr; char *wsp_tile = is_amx_bf16 ? wsp_tile_global + ti->ithr * tile_size : nullptr; diff --git a/src/cpu/x64/lrn/lrn_avx512_blocked_executor.hpp b/src/cpu/x64/lrn/lrn_avx512_blocked_executor.hpp index 78572f583b9..c6d85b9cc63 100644 --- a/src/cpu/x64/lrn/lrn_avx512_blocked_executor.hpp +++ b/src/cpu/x64/lrn/lrn_avx512_blocked_executor.hpp @@ -109,8 +109,8 @@ class lrn_avx512_blocked_executor_fwd_t : public i_lrn_executor_t { d_type>::jit_args_fwd_t args; args.src = &src[offset]; args.dst = &dst[offset]; - args.ws0 = &ws[ws_offset0]; - args.ws1 = &ws[ws_offset1]; + args.ws0 = ws ? &ws[ws_offset0] : nullptr; + args.ws1 = ws ? &ws[ws_offset1] : nullptr; if (C16 == 1) (*ker)(&args); @@ -136,8 +136,8 @@ class lrn_avx512_blocked_executor_fwd_t : public i_lrn_executor_t { d_type>::jit_args_fwd_t args; args.src = &src[offset]; args.dst = &dst[offset]; - args.ws0 = &ws[ws_offset0]; - args.ws1 = &ws[ws_offset1]; + args.ws0 = ws ? &ws[ws_offset0] : nullptr; + args.ws1 = ws ? &ws[ws_offset1] : nullptr; if (C16 == 1) (*ker)(&args); @@ -248,8 +248,8 @@ class lrn_avx512_blocked_executor_bwd_t : public i_lrn_executor_t { d_type>::jit_args_bwd_t args; args.src = &src[offset]; args.diff_dst = &diff_dst[offset]; - args.ws0 = &ws[ws_offset0]; - args.ws1 = &ws[ws_offset1]; + args.ws0 = ws ? &ws[ws_offset0] : nullptr; + args.ws1 = ws ? &ws[ws_offset1] : nullptr; args.diff_src = &diff_src[offset]; if (C16 == 1) @@ -276,8 +276,8 @@ class lrn_avx512_blocked_executor_bwd_t : public i_lrn_executor_t { d_type>::jit_args_bwd_t args; args.src = &src[offset]; args.diff_dst = &diff_dst[offset]; - args.ws0 = &ws[ws_offset0]; - args.ws1 = &ws[ws_offset1]; + args.ws0 = ws ? &ws[ws_offset0] : nullptr; + args.ws1 = ws ? &ws[ws_offset1] : nullptr; args.diff_src = &diff_src[offset]; if (C16 == 1) @@ -314,4 +314,4 @@ class lrn_avx512_blocked_executor_bwd_t : public i_lrn_executor_t { } // namespace impl } // namespace dnnl -#endif \ No newline at end of file +#endif