#4573·mlx

Incorrect sum for overlapping as_strided views

Author: sofinvaleryCreated Sep 27, 2026Updated Sep 27, 2026

Regression from #3475. Noticed it while prepping for an interview:) This returns 140 on CPU and Metal instead of the expected 152.

python
import mlx.core as mx
x = mx.arange(16, dtype=mx.float32) ** 2
y = mx.as_strided(x, (2, 2, 2), (1, 1, 5))
print(mx.sum(y).item())

The element count equals the memory span, but the view has overlaps and gaps. It is incorrectly marked contiguous, so the reduction sums addresses 0–7.