Python class
Type
Typeβ
class max.graph.Type
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 work with types in a graph:
from max.graph import Graph, TensorType
from max.dtype import DType
with Graph() as g:
# Create a tensor constant with a specific type
tensor_type = TensorType(DType.float32, [2, 3])
# The type can be inspected to get information about the value
print(f"Tensor element type: {tensor_type.dtype}") # Outputs: DType.float32
print(f"Tensor shape: {tensor_type.shape}") # Outputs: [2, 3]from_mlir()β
static from_mlir(t)
Constructs a type from an MLIR type.
to_mlir()β
to_mlir()
Converts to an mlir.Type instance.
-
Returns:
-
An
mlir.Typein the specified Context. -
Return type:
-
MlirType
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!