Skip to content

Commit a157fbe

Browse files
committed
cpu: x64: brgemm: fix assertion due to invalid EVEX offset
1 parent 2382350 commit a157fbe

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/cpu/x64/brgemm/brgemm.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,21 @@ status_t brgemm_desc_init(brgemm_desc_t *brg, cpu_isa_t isa,
252252

253253
if (M <= 0 || N <= 0 || K <= 0) return status::invalid_arguments;
254254

255+
// Upper bound, this can likely be improved by accounting for blocking
256+
dim_t max_a_stride = brg->LDA * types::data_type_size(brg->dt_a)
257+
* (brg->layout == brgemm_col_major ? K : M);
258+
dim_t max_b_stride = brg->LDB * types::data_type_size(brg->dt_b)
259+
* (brg->layout == brgemm_col_major ? N : K);
260+
dim_t max_c_stride = brg->LDC * types::data_type_size(brg->dt_c)
261+
* (brg->layout == brgemm_col_major ? N : M);
262+
263+
// Required for EVEX encoding for offsets
264+
const dim_t max_stride = std::numeric_limits<int32_t>::max();
265+
if ((max_a_stride > max_stride && !brg->is_runtime_lda)
266+
|| (max_b_stride > max_stride && !brg->is_runtime_ldb)
267+
|| (max_c_stride >= max_stride && !brg->is_runtime_ldc))
268+
return status::unimplemented;
269+
255270
if (utils::everyone_is(false, brg->is_int8, brg->is_bf16, brg->is_f32,
256271
brg->is_f16, brg->is_fp8))
257272
return status::unimplemented;

0 commit comments

Comments
 (0)