{"record":{"id":"7719e65c20f1b3f6","repo":"jax-ml/jax","slug":"the-out-argument-to-jnp-round-is-not-supported","errorCode":null,"errorMessage":"The 'out' argument to jnp.round is not supported.","messagePattern":"The 'out' argument to jnp\\.round is not supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/lax_numpy.py","lineNumber":3477,"sourceCode":"      nearest integer towards zero.\n\n  Examples:\n    >>> x = jnp.array([1.532, 3.267, 6.149])\n    >>> jnp.round(x)\n    Array([2., 3., 6.], dtype=float32)\n    >>> jnp.round(x, decimals=2)\n    Array([1.53, 3.27, 6.15], dtype=float32)\n\n    For values exactly halfway between rounded values:\n\n    >>> x1 = jnp.array([10.5, 21.5, 12.5, 31.5])\n    >>> jnp.round(x1)\n    Array([10., 22., 12., 32.], dtype=float32)\n  \"\"\"\n  a = util.ensure_arraylike(\"round\", a)\n  decimals = core.concrete_or_error(operator.index, decimals, \"'decimals' argument of jnp.round\")\n  if out is not None:\n    raise NotImplementedError(\"The 'out' argument to jnp.round is not supported.\")\n  dtype = a.dtype\n  if issubdtype(dtype, np.integer):\n    if decimals < 0:\n      raise NotImplementedError(\n        \"integer np.round not implemented for decimals < 0\")\n    return a  # no-op on integer types\n\n  def _round_float(x: ArrayLike) -> Array:\n    if decimals == 0:\n      return lax.round(x, lax.RoundingMethod.TO_NEAREST_EVEN)\n\n    # TODO(phawkins): the strategy of rescaling the value isn't necessarily a\n    # good one since we may be left with an incorrectly rounded value at the\n    # end due to precision problems. As a workaround for float16, convert to\n    # float32,\n    x = lax.convert_element_type(x, np.float32) if dtype == np.float16 else x\n    factor = lax._const(x, 10 ** decimals)\n    out = lax.div(lax.round(lax.mul(x, factor),","sourceCodeStart":3459,"sourceCodeEnd":3495,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/lax_numpy.py#L3459-L3495","documentation":"JAX arrays are immutable, so in-place output buffers like NumPy's out parameter are not supported. jnp.round raises NotImplementedError when out is passed.","triggerScenarios":"Calling jnp.round(a, decimals=0, out=buf) — typically code ported from NumPy that reuses a preallocated output array.","commonSituations":"Translating performance-tuned NumPy code that uses out= to avoid allocations; generic wrapper functions forwarding **kwargs including out.","solutions":["Remove out= and use the return value: a = jnp.round(a)","If you need buffer semantics, work with a mutable container (e.g. Python list or a numpy array via device_get) and assign back","Strip out from kwargs before forwarding to jnp.round"],"exampleFix":"// before\nnp.round(a, out=buf)\n// after\nbuf = jnp.round(a)","handlingStrategy":"validation","validationCode":"kwargs.pop('out', None)  # before forwarding to jnp.round","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Strip out= from kwargs when porting NumPy code","Remember JAX arrays are immutable; no buffer reuse APIs"],"tags":["jax","round","out-parameter","notimplementederror"],"backgroundTag":"unsupported-out-parameter","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}