Mojo struct
Type
struct Type
Represents any possible type for Graph Symbol values.
Every Symbol has a Type, and that type is represented by an Type. This type may be inspected to get finer-grained types and learn more about an individual Value.
Fields
- type (
Variant[TensorType, ListType, _OpaqueType]
): The type data.
Implemented traits
AnyType
,
CollectionElement
,
Copyable
,
Movable
,
UnknownDestructibility
Methods
__init__
@implicit
__init__(out self, t: TensorType)
Constructs a type from a tensor type.
Args:
- t (
TensorType
): The tensor type.
@implicit
__init__(out self, t: ListType)
Constructs a type from a list type.
Args:
- t (
ListType
): The list type.
@implicit
__init__(out self, t: _OpaqueType)
Constructs a type from an opaque typ.
Args:
- t (
_OpaqueType
): The opaque type.
list
list(self) -> ListType
Extracts the type as a list type.
This doesn't have any impact at graph execution time, it just retrieves the underlying list type for a type which is a list.
Returns:
The underlying type specifically as a list type.
Raises:
If the type is some other data type besides a list.
tensor
tensor(self) -> TensorType
Extracts the type as a tensor type.
This doesn't have any impact at graph execution time, it just retrieves the underlying tensor type for a type which is a tensor.
Returns:
The underlying type specifically as a tensor type.
Raises:
If the type is some other data type besides a tensor.
dims
dims(self) -> List[Dim]
Returns a list of all dims referenced by the type.
This doesn't have any impact at graph execution time, it just retrieves the list of referenced dimensions.
This will only return a result if the underlying type is a TensorType.
Returns:
The dims referenced.
to_mlir
to_mlir(self, ctx: Context) -> Type
Converts to an _mlir.Type instance.
Args:
- ctx (
Context
): The mlir.Context in which to create the type.
Returns:
An _mlir.Type in the specified Context.
from_mlir
static from_mlir(t: Type) -> Self
Constructs a type from an _mlir type.
Args:
- t (
Type
): The _mlir Type object to parse into a type.
Returns:
The type represented by the _mlir Type value.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!