Skip to main content

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.