mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Fix slice data size (#1394)
* fix slice data size and add tests * fix contiguous flag * simplify stride and perform copy for non-contiguous arrays * fix cpu * comment
This commit is contained in:
@@ -615,6 +615,10 @@ inline auto normalize_slice(
|
||||
|
||||
out_shape[i] = (stop[i] - start[i] + strides[i] - 1) / strides[i];
|
||||
}
|
||||
// Simplify the stride if it's unused
|
||||
if (out_shape[i] == 1) {
|
||||
strides[i] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(has_neg_strides, out_shape);
|
||||
|
||||
Reference in New Issue
Block a user