You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cumsum with exclusive=True crashes when constant-folded (TypeError: Cannot construct a dtype from an array) #2759
File ".../mil/ops/defs/iOS15/tensor_operation.py", line 158, in value_inference
data = np.concatenate((np.zeros(zero_shape, data)), axis=axis)
TypeError: Cannot construct a dtype from an array
Cause
In cumsum.value_inference, np.zeros(zero_shape, data) passes the data ndarray as np.zeros' dtype argument, and (np.zeros(...)) is a single array rather than a tuple for np.concatenate. So any exclusive=True cumsum on a constant-foldable input aborts conversion — this is reachable from real frontends (e.g. tf.cumsum(..., exclusive=True) on a foldable tensor). Even setting the crash aside, the exclusive prefix sum is never computed: data (the inclusive cumsum) is returned without being shifted.
Expected
Exclusive cumsum of [1, 2, 3, 4] is [0, 1, 3, 6] (out[0] = 0, out[i] = sum(x[:i])).
I'll open a PR that mirrors the exclusive semantics and adds value-inference coverage across axis/reverse combinations.
Activity