{"record":{"id":"fe19ea4e5fcd2747","repo":"jax-ml/jax","slug":"reshape-ref-with-dynamic-size-is-not-supported","errorCode":null,"errorMessage":"Reshape ref with dynamic size is not supported.","messagePattern":"Reshape ref with dynamic size is not supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"jax/_src/state/types.py","lineNumber":364,"sourceCode":"  T = property(lambda self: self.transpose(tuple(reversed(range(self.ndim)))))\n\n  @property\n  def at(self) -> RefIndexer:\n    return RefIndexer(self)\n\n  def bitcast(self, dtype):\n    if self.is_dynamic_size:\n      raise NotImplementedError(\n          \"Bitcast ref with dynamic size is not supported.\"\n      )\n    dtype = dtypes.dtype(dtype)\n    if self.multiref:\n      return TransformedRef(self, (BitcastTransform(dtype),))\n    return TransformedRef(self.ref, (*self.transforms, BitcastTransform(dtype)))\n\n  def reshape(self, *shape):\n    if self.is_dynamic_size:\n      raise NotImplementedError(\n          \"Reshape ref with dynamic size is not supported.\"\n      )\n    if len(shape) == 1 and isinstance(shape[0], tuple):\n      shape = shape[0]\n    input_shape = tuple(operator.index(s) for s in self.shape)\n    shape = _canonicalize_reshape(input_shape, shape)\n    if self.multiref:\n      return TransformedRef(self, (ReshapeTransform(shape),))\n    return TransformedRef(self.ref, (*self.transforms, ReshapeTransform(shape)))\n\n  def transpose(self, permutation: Sequence[int]):\n    if self.multiref:\n      raise NotImplementedError(\"Transpose with multiref is not supported.\")\n    transposer = TransposeTransform(tuple(permutation))\n    if self.multiref:\n      return TransformedRef(self, (transposer,))\n    return TransformedRef(self.ref, (*self.transforms, transposer))\n","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/state/types.py#L346-L382","documentation":"TransformedRef.reshape raises NotImplementedError when the ref has a dynamic size, since canonicalizing the reshape requires concrete input and output shapes.","triggerScenarios":"Calling .reshape(...) on a ref with symbolic/dynamic dimensions.","commonSituations":"Reshaping buffers inside shape-polymorphic code paths.","solutions":["Move the reshape outside the dynamic region","Use static shapes for the buffer","Allocate the target shape directly instead of reshaping"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if ref.is_dynamic_size:\n    raise RuntimeError(\"reshape unsupported here; use static shapes\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Allocate target shapes directly instead of reshaping","Isolate reshapes from polymorphic-shape code"],"tags":["jax","reshape","dynamic-shape"],"backgroundTag":"unsupported-dynamic-shape-operation","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}