{"record":{"id":"098b658b3fb1a997","repo":"jax-ml/jax","slug":"out-argument-of-self-name-accumulate","errorCode":null,"errorMessage":"out argument of {self.__name__}.accumulate()","messagePattern":"out argument of (.+?)\\.accumulate\\(\\)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/ufunc_api.py","lineNumber":376,"sourceCode":"             [  4,  20, 120]], dtype=int32)\n      >>> jnp.cumprod(x, axis=1)\n      Array([[  1,   2,   6],\n             [  4,  20, 120]], dtype=int32)\n\n      For other binary ufuncs, the accumulation is an operation not available\n      via standard APIs. For example, :meth:`jax.numpy.bitwise_or.accumulate`\n      is essentially a bitwise cumulative ``any``:\n\n      >>> jnp.bitwise_or.accumulate(x, axis=1)\n      Array([[1, 3, 3],\n             [4, 5, 7]], dtype=int32)\n    \"\"\"\n    if self.nin != 2:\n      raise ValueError(\"accumulate only supported for binary ufuncs\")\n    if self.nout != 1:\n      raise ValueError(\"accumulate only supported for functions returning a single value\")\n    if out is not None:\n      raise NotImplementedError(f\"out argument of {self.__name__}.accumulate()\")\n    accumulate = self.__static_props['accumulate'] or self._accumulate_via_scan\n    return accumulate(a, axis=axis, dtype=dtype)\n\n  def _accumulate_via_scan(self, arr: ArrayLike, axis: int = 0,\n                           dtype: DTypeLike | None = None) -> Array:\n    assert self.nin == 2 and self.nout == 1\n    check_arraylike(f\"{self.__name__}.accumulate\", arr)\n    arr = lax.asarray(arr)\n\n    if dtype is None:\n      dtype = api.eval_shape(self._func, lax._one(arr), lax._one(arr)).dtype\n\n    if axis is None or isinstance(axis, tuple):\n      raise ValueError(\"accumulate does not allow multiple axes\")\n    axis = canonicalize_axis(axis, np.ndim(arr))\n\n    if arr.size == 0:\n      return lax.full(arr.shape, 0, dtype)","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/ufunc_api.py#L358-L394","documentation":"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.","triggerScenarios":"jnp.add.accumulate(x, out=buf).","commonSituations":"Ported numpy code that used out= with cumsum-like operations for buffer reuse.","solutions":["Drop out= and use the returned array","Rely on jit + buffer donation for memory efficiency instead of out="],"exampleFix":"// before\njnp.add.accumulate(x, out=cum)\n// after\ncum = jnp.add.accumulate(x)","handlingStrategy":"type-guard","validationCode":"assert out is None, 'accumulate does not support out='","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drop out= when porting cumsum-style numpy calls"],"tags":["jax","ufunc","accumulate","immutable-arrays"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}