IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).

Python class

SymbolicDim

SymbolicDim​

class max.graph.SymbolicDim(value)

source

Bases: Dim

A symbolic tensor dimension with an unknown size identified by name.

When you don’t know a dimension value at compile time, you can use a symbolic dimension. This helps you identify dimensions by name and lets the compiler optimize operations when two or more dimensions share the same name.

The following example creates a symbolic dimension implicitly passing the strings "batch" and "x" to TensorType:

from max.dtype import DType
from max.graph import DeviceRef, TensorType

tensor_type = TensorType(DType.float32, ("batch", "x", 10), device=DeviceRef.CPU())

Converts valid input values to Dim.

Parameters:

name (str)

from_mlir()​

static from_mlir(attr)

source

Constructs a SymbolicDim from a kgen.ParamDeclRefAttr.

Parameters:

attr (TypedAttr) – The kgen.ParamDeclRefAttr to parse into a SymbolicDim.

Returns:

The SymbolicDim represented by the kgen.ParamDeclRefAttr.

Return type:

SymbolicDim

name​

name: str

source

The name of the dimension.

parameters​

property parameters: Iterable[SymbolicDim]

source

Lists the symbolic dimension names on which this dim depends.

substitute()​

substitute(mapping)

source

Returns this dim with named symbols replaced per mapping.

Parameters:

mapping (Mapping[str, int | str | Dim | integer | TypedAttr]) – A mapping from symbolic dimension name to the replacement dim (or dim-like value).

Returns:

Dim(mapping[self.name]) if self.name is in mapping, otherwise this dim unchanged.

Return type:

Dim

to_mlir()​

to_mlir()

source

Creates an mlir.Attribute representing this dimension.

This is used internally when constructing tensor MLIR types.

Returns:

An mlir.Attribute in the context representing the dimension.

Return type:

ParamDeclRefAttr