Skip to main content

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:

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.

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