jax-ml/jax · error · NotImplementedError
out argument of {self.__name__}.accumulate()
Error message
out argument of {self.__name__}.accumulate() What it means
ufunc.accumulate's out parameter is accepted for numpy compatibility but unsupported because JAX arrays are immutable. A non-None out raises NotImplementedError naming the ufunc.
Source
Thrown at jax/_src/numpy/ufunc_api.py:376
[ 4, 20, 120]], dtype=int32)
>>> jnp.cumprod(x, axis=1)
Array([[ 1, 2, 6],
[ 4, 20, 120]], dtype=int32)
For other binary ufuncs, the accumulation is an operation not available
via standard APIs. For example, :meth:`jax.numpy.bitwise_or.accumulate`
is essentially a bitwise cumulative ``any``:
>>> jnp.bitwise_or.accumulate(x, axis=1)
Array([[1, 3, 3],
[4, 5, 7]], dtype=int32)
"""
if self.nin != 2:
raise ValueError("accumulate only supported for binary ufuncs")
if self.nout != 1:
raise ValueError("accumulate only supported for functions returning a single value")
if out is not None:
raise NotImplementedError(f"out argument of {self.__name__}.accumulate()")
accumulate = self.__static_props['accumulate'] or self._accumulate_via_scan
return accumulate(a, axis=axis, dtype=dtype)
def _accumulate_via_scan(self, arr: ArrayLike, axis: int = 0,
dtype: DTypeLike | None = None) -> Array:
assert self.nin == 2 and self.nout == 1
check_arraylike(f"{self.__name__}.accumulate", arr)
arr = lax.asarray(arr)
if dtype is None:
dtype = api.eval_shape(self._func, lax._one(arr), lax._one(arr)).dtype
if axis is None or isinstance(axis, tuple):
raise ValueError("accumulate does not allow multiple axes")
axis = canonicalize_axis(axis, np.ndim(arr))
if arr.size == 0:
return lax.full(arr.shape, 0, dtype)View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Drop out= and use the returned array
- Rely on jit + buffer donation for memory efficiency instead of out=
Example fix
// before jnp.add.accumulate(x, out=cum) // after cum = jnp.add.accumulate(x)
Defensive patterns
Strategy: type-guard
Validate before calling
assert out is None, 'accumulate does not support out='
Prevention
- Drop out= when porting cumsum-style numpy calls
When it happens
Trigger: jnp.add.accumulate(x, out=buf).
Common situations: Ported numpy code that used out= with cumsum-like operations for buffer reuse.
Related errors
- out argument of {self}
- out argument of {self.__name__}.reduce()
- accumulate only supported for binary ufuncs
- accumulate only supported for functions returning a single v
- accumulate does not allow multiple axes
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/098b658b3fb1a997.
Report an issue: GitHub.