Skip to content

Commit 2cd9b08

Browse files
committed
Fix dim_stride_overlap for axes with length 1
1 parent 58d9a55 commit 2cd9b08

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/dimension.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ fn stride_is_positive(stride: Ix) -> bool {
3636
pub fn dim_stride_overlap<D: Dimension>(dim: &D, strides: &D) -> bool {
3737
let order = strides._fastest_varying_stride_order();
3838

39+
let dim = dim.slice();
40+
let strides = strides.slice();
3941
let mut prev_offset = 1;
40-
for &index in order.slice().iter() {
41-
let s = strides.slice()[index];
42-
if (s as isize) < prev_offset {
42+
for &index in order.slice() {
43+
let d = dim[index];
44+
let s = strides[index];
45+
// any stride is ok if dimension is 1
46+
if d != 1 && (s as isize) < prev_offset {
4347
return true;
4448
}
45-
prev_offset = stride_offset(dim.slice()[index], s);
49+
prev_offset = stride_offset(d, s);
4650
}
4751
false
4852
}

0 commit comments

Comments
 (0)