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

AlgebraicDim

AlgebraicDim

class max.graph.AlgebraicDim(value)

source

Bases: Dim

A dimension defined by an expression over symbolic dimensions.

Arithmetic on symbolic dimensions produces an AlgebraicDim:

from max.graph import AlgebraicDim, Dim

isinstance(Dim("batch") * 5, AlgebraicDim)  # True

Equivalent expressions simplify to the same form:

from max.graph import Dim

Dim("x") + 1 + 1 == Dim("x") + 2  # True

Converts valid input values to Dim.

Parameters:

attr (ParamOperatorAttr)

apply()

classmethod apply(op, *operands)

source

Applies a parametric operator to operands and returns the resulting dimension.

Parameters:

attr

attr: ParamOperatorAttr

source

from_mlir()

static from_mlir(attr)

source

Constructs an AlgebraicDim from a kgen.ParamOperatorAttr.

Parameters:

attr (TypedAttr) – The kgen.ParamOperatorAttr to parse into an AlgebraicDim.

Returns:

The AlgebraicDim represented by the kgen.ParamOperatorAttr.

Return type:

AlgebraicDim

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.

Substitutes into each operand, then reapplies the operator, so substitution to static values folds through the compiler’s own attribute evaluation rather than being recomputed in Python.

Parameters:

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

Returns:

The dim with substitutions applied, re-folded by the compiler.

Raises:

ZeroDivisionError – If substitution produces a zero divisor.

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:

ParamOperatorAttr