{"record":{"id":"4a8faeeb061e2c33","repo":"jax-ml/jax","slug":"symbolic-dimension-operation-name-not-supported","errorCode":null,"errorMessage":"Symbolic dimension {operation_name} not supported for {p}.","messagePattern":"Symbolic dimension (.+?) not supported for (.+?)\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/export/shape_poly.py","lineNumber":1220,"sourceCode":"core.pytype_aval_mappings[_DimExpr] = _DimExpr._get_aval\ndtypes.register_weak_scalar_type(_DimExpr)\n\ndef _convertible_to_int(p: Any) -> TypeGuard[SupportsIndex]:\n  try:\n    op.index(p)\n    return True\n  except:\n    return False\n\ndef _ensure_poly(p: DimSize,\n                 operation_name: str,\n                 scope: SymbolicScope) -> _DimExpr:\n  if isinstance(p, _DimExpr):\n    scope._check_same_scope(p, when=f\"for operation {operation_name}\")\n    return p\n  if _convertible_to_int(p):\n    return _DimExpr(((_DimTerm_one, op.index(p)),), scope)\n  raise TypeError(f\"Symbolic dimension {operation_name} not supported for {p}.\")\n\ndef _convertible_to_poly(p: Any) -> bool:\n  return isinstance(p, _DimExpr) or _convertible_to_int(p)\n\ndef is_symbolic_dim(p: DimSize) -> TypeGuard[_DimExpr]:\n  \"\"\"Checks if a dimension is symbolic.\n  \"\"\"\n  return isinstance(p, _DimExpr)\n\n\ndef symbolic_dim_bounds(\n    dimension: DimSize | SupportsIndex,\n) -> tuple[float, float]:\n  \"\"\"Returns inclusive bounds that JAX can prove for a dimension expression.\n\n  The returned bounds are conservative and may not be tight. Infinite bounds\n  mean that JAX could not establish a finite bound; they do not prove that the\n  dimension is unbounded.","sourceCodeStart":1202,"sourceCodeEnd":1238,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/export/shape_poly.py#L1202-L1238","documentation":"Internal coercion turning a value into a symbolic dimension polynomial accepts only existing _DimExpr (same scope) or integers. Anything else — float, None, string, numpy float scalar — cannot become a dim and raises TypeError naming the operation.","triggerScenarios":"Arithmetic like dim * 2.0, dim + np.float32(1), or None propagating into shape arithmetic during polymorphic export; operations named in the message (e.g. 'mul', 'parse_constraint').","commonSituations":"Mixing float scalars (e.g. mean factors like 0.5 * dim for downsampling) with dimension expressions; None from an optional config leaking into shape math.","solutions":["Use integer constants in shape arithmetic (int(2.0) or //2 instead of *0.5)","Check for None before shape computations","Keep all shape arithmetic in ints or existing symbolic dims"],"exampleFix":"# before\nnew_dim = old_dim * 0.5\n# after\nnew_dim = old_dim // 2  # integer shape arithmetic","handlingStrategy":"type-guard","validationCode":"assert isinstance(v, (int,)) or is_symbolic_dim(v), f'bad operand in shape math: {v!r}'","typeGuard":"def dim_arith_ok(p) -> bool:\n    return isinstance(p, int) or is_symbolic_dim(p)","tryCatchPattern":"try:\n    d = dim * factor\nexcept TypeError as e:\n    if 'not supported' in str(e): d = dim * int(factor)","preventionTips":["Keep all shape arithmetic integral (use //2, not *0.5)","Guard optional values against None before shape math"],"tags":["jax","shape-polymorphism","type-error","coercion"],"backgroundTag":"invalid-type-in-shape-arithmetic","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}