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

Type

Type​

class max.graph.Type

source

Bases: Generic[MlirType]

The type of any value in a MAX graph.

Every value in the graph has a type, and that type is represented by a Type. This type may be inspected to get finer-grained types and learn more about an individual Value.

The following example shows how to inspect a tensor type:

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

tensor_type = TensorType(DType.float32, [2, 3], device=DeviceRef.CPU())
print(f"Tensor element type: {tensor_type.dtype}")  # Outputs: DType.float32
print(f"Tensor shape: {tensor_type.shape}")  # Outputs: [Dim(2), Dim(3)]

from_mlir()​

static from_mlir(t)

source

Constructs a type from an MLIR type.

Parameters:

t (MlirType) – The MLIR Type object to parse into a type.

Returns:

The type represented by the MLIR Type value.

Return type:

Type[Any]

to_mlir()​

to_mlir()

source

Converts to an mlir.Type instance.

Returns:

An mlir.Type in the specified Context.

Return type:

MlirType