Skip to content

Commit 8f69351

Browse files
maxnickazhai219
authored andcommitted
[FIX] Desc similar_to routine consider start stride
1 parent 32f7820 commit 8f69351

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/common/memory_desc_wrapper.hpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,11 @@ inline bool memory_desc_wrapper::similar_to(const memory_desc_wrapper &rhs,
626626
return false;
627627

628628
const int ds = dim_start;
629-
if (stride_start == -1)
629+
if (stride_start == -1) {
630630
stride_start = ds;
631+
} else if (stride_start > ndims()) {
632+
stride_start = ndims();
633+
}
631634
const auto &blk = blocking_desc();
632635
const auto &r_blk = rhs.blocking_desc();
633636

@@ -636,7 +639,7 @@ inline bool memory_desc_wrapper::similar_to(const memory_desc_wrapper &rhs,
636639
&& format_kind() == rhs.format_kind()
637640
&& IMPLICATION(with_data_type, data_type() == rhs.data_type())
638641
&& custom_cpm(dims() + ds, rhs.dims() + ds, ndims() - ds)
639-
&& custom_cpm(blk.strides + ds, r_blk.strides + ds, ndims() - ds)
642+
&& custom_cpm(blk.strides + stride_start, r_blk.strides + stride_start, ndims() - stride_start)
640643
&& blk.inner_nblks == r_blk.inner_nblks
641644
&& array_cmp(blk.inner_blks, r_blk.inner_blks, blk.inner_nblks)
642645
&& array_cmp(blk.inner_idxs, r_blk.inner_idxs, blk.inner_nblks)

0 commit comments

Comments
 (0)