Mojo 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
Methodsβ
__init__
β
__init__(inout self: Self, t: TensorType)
Constructs a type from a tensor type.
Args:
- βt (
TensorType
): The tensor type.
__init__(inout self: Self, t: ListType)
Constructs a type from a list type.
Args:
- βt (
ListType
): The list type.
__init__(inout self: Self, t: _OpaqueType)
Constructs a type from an opaque typ.
Args:
- βt (
_OpaqueType
): The opaque type.
list
β
list(self: 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: 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: Self) -> List[Dim, 0]
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: 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!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?