mlir.extras.types

Attributes

Classes

Functions

i(width)

si(width)

ui(width)

complex(type)

opaque(dialect_namespace, type_data)

_shaped(*shape[, element_type, type_constructor])

vector(*shape[, element_type, scalable, scalable_dims])

tensor(*shape[, element_type, encoding])

memref(*shape[, element_type, memory_space, layout])

tuple(*elements)

function(*, inputs, results)

Module Contents

class mlir.extras.types.Attribute(cast_from_type: Attribute)
property _CAPIPtr: object

Gets a capsule wrapping the MlirAttribute.

static _CAPICreate(arg: object, /) Attribute

Creates an Attribute from a capsule wrapping MlirAttribute.

static parse(asm: str, context: Context | None = None) Attribute

Parses an attribute from an assembly form. Raises an MLIRError on failure.

property context: Context

Context that owns the Attribute.

property type: Type

Returns the type of the Attribute.

get_named(arg: str, /) NamedAttribute

Binds a name to the attribute, creating a NamedAttribute.

Parameters:

name – The name to bind to the Attribute.

Returns:

A NamedAttribute with the given name and this attribute.

__eq__(arg: Attribute, /) bool
__eq__(arg: object, /) bool

Compares attribute with non-attribute object (always returns False).

__hash__() int

Returns the hash value of the attribute.

dump() None

Dumps a debug representation of the object to stderr.

__str__() str

Returns the assembly form of the Attribute.

__repr__() str

Returns a string representation of the attribute.

property typeid: TypeID

Returns the TypeID of the attribute.

maybe_downcast() Attribute

Downcasts the attribute to a more specific attribute if possible.

class mlir.extras.types.BF16Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) BF16Type

Create a bf16 type.

class mlir.extras.types.ComplexType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(arg: Type, /) ComplexType

Create a complex type

property element_type: Type

Returns element type.

class mlir.extras.types.F16Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) F16Type

Create a f16 type.

class mlir.extras.types.F32Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) F32Type

Create a f32 type.

class mlir.extras.types.F64Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) F64Type

Create a f64 type.

class mlir.extras.types.Float4E2M1FNType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float4E2M1FNType

Create a float4_e2m1fn type.

class mlir.extras.types.Float6E2M3FNType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float6E2M3FNType

Create a float6_e2m3fn type.

class mlir.extras.types.Float6E3M2FNType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float6E3M2FNType

Create a float6_e3m2fn type.

class mlir.extras.types.Float8E3M4Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float8E3M4Type

Create a float8_e3m4 type.

class mlir.extras.types.Float8E4M3B11FNUZType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float8E4M3B11FNUZType

Create a float8_e4m3b11fnuz type.

class mlir.extras.types.Float8E4M3FNType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float8E4M3FNType

Create a float8_e4m3fn type.

class mlir.extras.types.Float8E4M3Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float8E4M3Type

Create a float8_e4m3 type.

class mlir.extras.types.Float8E5M2Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float8E5M2Type

Create a float8_e5m2 type.

class mlir.extras.types.Float8E8M0FNUType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) Float8E8M0FNUType

Create a float8_e8m0fnu type.

class mlir.extras.types.Float8E5M3FNUType(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

static get(context: Context | None = None) Float8E5M3FNUType

Create a float8_e5m3fnu type.

class mlir.extras.types.FloatTF32Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) FloatTF32Type

Create a tf32 type.

class mlir.extras.types.FunctionType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(inputs: collections.abc.Sequence[Type], results: collections.abc.Sequence[Type], context: Context | None = None) FunctionType

Gets a FunctionType from a list of input and result types

property inputs: list[Type]

Returns the list of input types in the FunctionType.

property results: list[Type]

Returns the list of result types in the FunctionType.

class mlir.extras.types.IndexType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) IndexType

Create a index type.

class mlir.extras.types.IntegerType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

class Signedness

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

SIGNLESS = 0
SIGNED = 1
UNSIGNED = 2
SIGNLESS: IntegerType
SIGNED: IntegerType
UNSIGNED: IntegerType
static get_signless(width: int, context: Context | None = None) IntegerType

Create a signless integer type

static get_signed(width: int, context: Context | None = None) IntegerType

Create a signed integer type

static get_unsigned(width: int, context: Context | None = None) IntegerType

Create an unsigned integer type

static get(width: int, signedness: IntegerType = IntegerType.Signedness.SIGNLESS, context: Context | None = None) IntegerType

Create an integer type

property signedness: IntegerType
property width: int

Returns the width of the integer type

property is_signless: bool

Returns whether this is a signless integer

property is_signed: bool

Returns whether this is a signed integer

property is_unsigned: bool

Returns whether this is an unsigned integer

class mlir.extras.types.MemRefType(cast_from_type: Type)

Bases: ShapedType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(shape: collections.abc.Sequence[int], element_type: Type, layout: Attribute | None = None, memory_space: Attribute | None = None, loc: Location | None = None) MemRefType

Create a memref type

static get_unchecked(shape: collections.abc.Sequence[int], element_type: Type, layout: Attribute | None = None, memory_space: Attribute | None = None, context: Context | None = None) MemRefType

Create a memref type

property layout: Attribute

The layout of the MemRef type.

get_strides_and_offset() tuple[list[int], int]

The strides and offset of the MemRef type.

property affine_map: AffineMap

The layout of the MemRef type as an affine map.

property memory_space: Attribute | None

Returns the memory space of the given MemRef type.

class mlir.extras.types.NoneType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) NoneType

Create a none type.

class mlir.extras.types.OpaqueType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(dialect_namespace: str, buffer: str, context: Context | None = None) OpaqueType

Create an unregistered (opaque) dialect type.

property dialect_namespace: str

Returns the dialect namespace for the Opaque type as a string.

property data: str

Returns the data for the Opaque type as a string.

class mlir.extras.types.RankedTensorType(cast_from_type: Type)

Bases: ShapedType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(shape: collections.abc.Sequence[int], element_type: Type, encoding: Attribute | None = None, loc: Location | None = None) RankedTensorType

Create a ranked tensor type

static get_unchecked(shape: collections.abc.Sequence[int], element_type: Type, encoding: Attribute | None = None, context: Context | None = None) RankedTensorType

Create a ranked tensor type

property encoding: Attribute | None
class mlir.extras.types.StridedLayoutAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

attr_name: str = Ellipsis

(arg: object, /) -> str

static get(offset: int, strides: collections.abc.Sequence[int], context: Context | None = None) StridedLayoutAttr

Gets a strided layout attribute.

static get_fully_dynamic(rank: int, context: Context | None = None) StridedLayoutAttr

Gets a strided layout attribute with dynamic offset and strides of a given rank.

property offset: int

Returns the value of the float point attribute

property strides: list[int]

Returns the value of the float point attribute

class mlir.extras.types.StringAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

attr_name: str = Ellipsis

(arg: object, /) -> str

static get(value: str, context: Context | None = None) StringAttr
static get(value: bytes, context: Context | None = None) StringAttr
static get_typed(type: Type, value: str) StringAttr

Gets a uniqued string attribute associated to a type

property value: str

Returns the value of the string attribute

property value_bytes: bytes

Returns the value of the string attribute as bytes

class mlir.extras.types.TupleType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get_tuple(elements: collections.abc.Sequence[Type], context: Context | None = None) TupleType

Create a tuple type

get_type(pos: int) Type

Returns the pos-th type in the tuple type.

property num_types: int

Returns the number of types contained in a tuple.

class mlir.extras.types.Type(cast_from_type: Type)
property _CAPIPtr: object

Gets a capsule wrapping the MlirType.

static _CAPICreate(arg: object, /) Type

Creates a Type from a capsule wrapping MlirType.

static parse(asm: str, context: Context | None = None) Type

Parses the assembly form of a type.

Returns a Type object or raises an MLIRError if the type cannot be parsed.

See also: https://mlir.llvm.org/docs/LangRef/#type-system

property context: Context

Context that owns the Type.

__eq__(arg: Type, /) bool
__eq__(other: object | None) bool

Compares type with non-type object (always returns False).

__hash__() int

Returns the hash value of the Type.

dump() None

Dumps a debug representation of the object to stderr.

__str__() str

Returns the assembly form of the Type.

__repr__() str

Returns a string representation of the Type.

maybe_downcast() Type

Downcasts the Type to a more specific Type if possible.

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

class mlir.extras.types.UnrankedMemRefType(cast_from_type: Type)

Bases: ShapedType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(element_type: Type, memory_space: Attribute | None, loc: Location | None = None) UnrankedMemRefType

Create a unranked memref type

static get_unchecked(element_type: Type, memory_space: Attribute | None, context: Context | None = None) UnrankedMemRefType

Create a unranked memref type

property memory_space: Attribute | None

Returns the memory space of the given Unranked MemRef type.

class mlir.extras.types.UnrankedTensorType(cast_from_type: Type)

Bases: ShapedType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(element_type: Type, loc: Location | None = None) UnrankedTensorType

Create a unranked tensor type

static get_unchecked(element_type: Type, context: Context | None = None) UnrankedTensorType

Create a unranked tensor type

class mlir.extras.types.VectorType(cast_from_type: Type)

Bases: ShapedType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(shape: collections.abc.Sequence[int], element_type: Type, *, scalable: collections.abc.Sequence | None = None, scalable_dims: collections.abc.Sequence[int] | None = None, loc: Location | None = None) VectorType

Create a vector type

static get_unchecked(shape: collections.abc.Sequence[int], element_type: Type, *, scalable: collections.abc.Sequence | None = None, scalable_dims: collections.abc.Sequence[int] | None = None, context: Context | None = None) VectorType

Create a vector type

property scalable: bool
property scalable_dims: list[bool]
mlir.extras.types.index
mlir.extras.types.i(width)
mlir.extras.types.si(width)
mlir.extras.types.ui(width)
mlir.extras.types.bool
mlir.extras.types.i8
mlir.extras.types.i16
mlir.extras.types.i32
mlir.extras.types.i64
mlir.extras.types.si8
mlir.extras.types.si16
mlir.extras.types.si32
mlir.extras.types.si64
mlir.extras.types.ui8
mlir.extras.types.ui16
mlir.extras.types.ui32
mlir.extras.types.ui64
mlir.extras.types.f16
mlir.extras.types.f32
mlir.extras.types.tf32
mlir.extras.types.f64
mlir.extras.types.bf16
mlir.extras.types.f8E5M2
mlir.extras.types.f8E4M3
mlir.extras.types.f8E4M3FN
mlir.extras.types.f8E4M3B11FNUZ
mlir.extras.types.f8E3M4
mlir.extras.types.f4E2M1FN
mlir.extras.types.f6E2M3FN
mlir.extras.types.f6E3M2FN
mlir.extras.types.f8E8M0FNU
mlir.extras.types.f8E5M3FNU
mlir.extras.types.none
mlir.extras.types.complex(type)
mlir.extras.types.opaque(dialect_namespace, type_data)
mlir.extras.types._shaped(*shape, element_type: mlir.ir.Type = None, type_constructor=None)
mlir.extras.types.vector(*shape, element_type: mlir.ir.Type = None, scalable: List[bool] | None = None, scalable_dims: List[int] | None = None)
mlir.extras.types.tensor(*shape, element_type: mlir.ir.Type = None, encoding: str | None = None)
mlir.extras.types.memref(*shape, element_type: mlir.ir.Type = None, memory_space: int | None = None, layout: mlir.ir.StridedLayoutAttr | None = None)
mlir.extras.types.tuple(*elements)
mlir.extras.types.function(*, inputs, results)