mlir._mlir_libs._mlir.ir

Classes

DiagnosticSeverity

Generic enumeration.

WalkOrder

Generic enumeration.

WalkResult

Generic enumeration.

Diagnostic

DiagnosticInfo

DiagnosticHandler

ThreadPool

Context

DialectDescriptor

Dialects

Dialect

DialectRegistry

Location

Module

_OperationBase

Operation

OpView

Region

Block

InsertionPoint

Attribute

NamedAttribute

Type

TypeID

Value

BlockArgument

OpResult

OpOperand

AsmState

SymbolTable

BlockArgumentList

BlockIterator

BlockList

BlockSuccessors

BlockPredecessors

OperationIterator

OperationList

OpAttributeMap

OpOperandIterator

OpOperandList

OpResultList

OpSuccessors

RegionIterator

RegionSequence

_GlobalDebug

AttrBuilder

AffineExpr

AffineConstantExpr

AffineDimExpr

AffineSymbolExpr

AffineBinaryExpr

AffineAddExpr

AffineMulExpr

AffineModExpr

AffineFloorDivExpr

AffineCeilDivExpr

AffineMap

AffineExprList

IntegerSet

IntegerSetConstraint

IntegerSetConstraintList

AffineMapAttr

DenseBoolArrayAttr

DenseBoolArrayIterator

DenseI8ArrayAttr

DenseI8ArrayIterator

DenseI16ArrayAttr

DenseI16ArrayIterator

DenseI32ArrayAttr

DenseI32ArrayIterator

DenseI64ArrayAttr

DenseI64ArrayIterator

DenseF32ArrayAttr

DenseF32ArrayIterator

DenseF64ArrayAttr

DenseF64ArrayIterator

ArrayAttr

ArrayAttributeIterator

BoolAttr

DenseElementsAttr

DenseFPElementsAttr

DenseIntElementsAttr

DenseResourceElementsAttr

DictAttr

SymbolRefAttr

FlatSymbolRefAttr

OpaqueAttr

FloatAttr

IntegerAttr

IntegerSetAttr

StringAttr

TypeAttr

UnitAttr

StridedLayoutAttr

InferTypeOpInterface

ShapedTypeComponents

InferShapedTypeOpInterface

IntegerType

FloatType

IndexType

Float4E2M1FNType

Float6E2M3FNType

Float6E3M2FNType

Float8E4M3FNType

Float8E5M2Type

Float8E4M3Type

Float8E4M3FNUZType

Float8E4M3B11FNUZType

Float8E5M2FNUZType

Float8E3M4Type

Float8E8M0FNUType

BF16Type

F16Type

FloatTF32Type

F32Type

F64Type

NoneType

ComplexType

ShapedType

VectorType

RankedTensorType

UnrankedTensorType

MemRefType

UnrankedMemRefType

TupleType

FunctionType

OpaqueType

Module Contents

class mlir._mlir_libs._mlir.ir.DiagnosticSeverity

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

_member_names_: list = ['ERROR', 'WARNING', 'NOTE', 'REMARK']
_member_map_: dict = Ellipsis
_value2member_map_: dict = Ellipsis
ERROR = 0
WARNING = 1
NOTE = 2
REMARK = 3
class mlir._mlir_libs._mlir.ir.WalkOrder

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

_member_names_: list = ['PRE_ORDER', 'POST_ORDER']
_member_map_: dict = Ellipsis
_value2member_map_: dict = Ellipsis
PRE_ORDER = 0
POST_ORDER = 1
class mlir._mlir_libs._mlir.ir.WalkResult

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

_member_names_: list = ['ADVANCE', 'INTERRUPT', 'SKIP']
_member_map_: dict = Ellipsis
_value2member_map_: dict = Ellipsis
ADVANCE = 0
INTERRUPT = 1
SKIP = 2
class mlir._mlir_libs._mlir.ir.Diagnostic
property severity: DiagnosticSeverity

Returns the severity of the diagnostic.

property location: Location

Returns the location associated with the diagnostic.

property message: str

Returns the message text of the diagnostic.

property notes: tuple

Returns a tuple of attached note diagnostics.

__str__() str

Returns the diagnostic message as a string.

class mlir._mlir_libs._mlir.ir.DiagnosticInfo(diag: Diagnostic)
property severity: DiagnosticSeverity

The severity level of the diagnostic.

property location: Location

The location associated with the diagnostic.

property message: str

The message text of the diagnostic.

property notes: list[DiagnosticInfo]

List of attached note diagnostics.

__str__() str

Returns the diagnostic message as a string.

class mlir._mlir_libs._mlir.ir.DiagnosticHandler
detach() None

Detaches the diagnostic handler from the context.

property attached: bool

Returns True if the handler is attached to a context.

property had_error: bool

Returns True if an error was encountered during diagnostic handling.

__enter__() object

Enters the diagnostic handler as a context manager.

__exit__(exc_type: object | None, exc_value: object | None, traceback: object | None) None

Exits the diagnostic handler context manager.

class mlir._mlir_libs._mlir.ir.ThreadPool
get_max_concurrency() int

Returns the maximum number of threads in the pool.

_mlir_thread_pool_ptr() str

Returns the raw pointer to the LLVM thread pool as a string.

class mlir._mlir_libs._mlir.ir.Context
static _get_live_count() int

Gets the number of live Context objects.

_get_context_again() Context

Gets another reference to the same context.

_get_live_module_count() int

Gets the number of live modules owned by this context.

property _CAPIPtr: object

Gets a capsule wrapping the MlirContext.

static _CAPICreate(arg: object, /) object

Creates a Context from a capsule wrapping MlirContext.

__enter__() object

Enters the context as a context manager.

__exit__(exc_type: object | None, exc_value: object | None, traceback: object | None) None

Exits the context manager.

current: Context | None = Ellipsis

Gets the Context bound to the current thread or returns None if no context is set.

property dialects: Dialects

Gets a container for accessing dialects by name.

property d: Dialects

Alias for dialects.

get_dialect_descriptor(dialect_name: str) DialectDescriptor

Gets or loads a dialect by name, returning its descriptor object.

property allow_unregistered_dialects: bool

Controls whether unregistered dialects are allowed in this context.

attach_diagnostic_handler(callback: object) object

Attaches a diagnostic handler that will receive callbacks.

enable_multithreading(enable: bool) None

Enables or disables multi-threading support in the context.

Parameters:

enable – Whether to enable (True) or disable (False) multi-threading.

set_thread_pool(arg: ThreadPool, /) None

Sets a custom thread pool for the context to use.

Parameters:

pool – A ThreadPool object to use for parallel operations.

Note

Multi-threading is automatically disabled before setting the thread pool.

get_num_threads() int

Gets the number of threads in the context’s thread pool.

_mlir_thread_pool_ptr() str

Gets the raw pointer to the LLVM thread pool as a string.

is_registered_operation(operation_name: str) bool

Checks whether an operation with the given name is registered.

Parameters:

operation_name – The fully qualified name of the operation (e.g., arith.addf).

Returns:

True if the operation is registered, False otherwise.

append_dialect_registry(registry: DialectRegistry) None

Appends the contents of a dialect registry to the context.

Parameters:

registry – A DialectRegistry containing dialects to append.

property emit_error_diagnostics: bool

Controls whether error diagnostics are emitted to diagnostic handlers.

By default, error diagnostics are captured and reported through MLIRError exceptions.

load_all_available_dialects() None

Loads all dialects available in the registry into the context.

This eagerly loads all dialects that have been registered, making them immediately available for use.

class mlir._mlir_libs._mlir.ir.DialectDescriptor
property namespace: str

Returns the namespace of the dialect.

__repr__() str

Returns a string representation of the dialect descriptor.

class mlir._mlir_libs._mlir.ir.Dialects
__getitem__(arg: str, /) object

Gets a dialect by name using subscript notation.

__getattr__(arg: str, /) object

Gets a dialect by name using attribute notation.

class mlir._mlir_libs._mlir.ir.Dialect(descriptor: object)
property descriptor: object

Returns the DialectDescriptor for this dialect.

__repr__() str

Returns a string representation of the dialect.

class mlir._mlir_libs._mlir.ir.DialectRegistry
property _CAPIPtr: object

Gets a capsule wrapping the MlirDialectRegistry.

static _CAPICreate(arg: object, /) DialectRegistry

Creates a DialectRegistry from a capsule wrapping MlirDialectRegistry.

class mlir._mlir_libs._mlir.ir.Location
property _CAPIPtr: object

Gets a capsule wrapping the MlirLocation.

static _CAPICreate(arg: object, /) Location

Creates a Location from a capsule wrapping MlirLocation.

__enter__() object

Enters the location as a context manager.

__exit__(exc_type: object | None, exc_value: object | None, traceback: object | None) None

Exits the location context manager.

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

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

current: Location | None = Ellipsis

Gets the Location bound to the current thread or raises ValueError.

static unknown(context: Context | None = None) Location

Gets a Location representing an unknown location.

static callsite(callee: Location, frames: collections.abc.Sequence[Location], context: Context | None = None) Location

Gets a Location representing a caller and callsite.

is_a_callsite() bool

Returns True if this location is a CallSiteLoc.

property callee: Location

Gets the callee location from a CallSiteLoc.

property caller: Location

Gets the caller location from a CallSiteLoc.

static file(filename: str, line: int, col: int, context: Context | None = None) Location
static file(filename: str, start_line: int, start_col: int, end_line: int, end_col: int, context: Context | None = None) Location

Gets a Location representing a file, line and column range.

is_a_file() bool

Returns True if this location is a FileLineColLoc.

property filename: str

Gets the filename from a FileLineColLoc.

property start_line: int

Gets the start line number from a FileLineColLoc.

property start_col: int

Gets the start column number from a FileLineColLoc.

property end_line: int

Gets the end line number from a FileLineColLoc.

property end_col: int

Gets the end column number from a FileLineColLoc.

static fused(locations: collections.abc.Sequence[Location], metadata: Attribute | None = None, context: Context | None = None) Location

Gets a Location representing a fused location with optional metadata.

is_a_fused() bool

Returns True if this location is a FusedLoc.

property locations: list[Location]

Gets the list of locations from a FusedLoc.

static name(name: str, childLoc: Location | None = None, context: Context | None = None) Location

Gets a Location representing a named location with optional child location.

is_a_name() bool

Returns True if this location is a NameLoc.

property name_str: str

Gets the name string from a NameLoc.

property child_loc: Location

Gets the child location from a NameLoc.

static from_attr(attribute: Attribute, context: Context | None = None) Location

Gets a Location from a LocationAttr.

property context: Context

Context that owns the Location.

property attr: Attribute

Get the underlying LocationAttr.

emit_error(message: str) None

Emits an error diagnostic at this location.

Parameters:

message – The error message to emit.

__repr__() str

Returns the assembly representation of the location.

class mlir._mlir_libs._mlir.ir.Module
property _CAPIPtr: object

Gets a capsule wrapping the MlirModule.

static _CAPICreate(arg: object, /) object

Creates a Module from a MlirModule wrapped by a capsule (i.e. module._CAPIPtr).

This returns a new object BUT _clear_mlir_module(module) must be called to prevent double-frees (of the underlying mlir::Module).

_clear_mlir_module() None

Clears the internal MLIR module reference.

This is used internally to prevent double-free when ownership is transferred via the C API capsule mechanism. Not intended for normal use.

static parse(asm: str, context: Context | None = None) Module
static parse(asm: bytes, context: Context | None = None) Module
static parseFile(path: str, context: Context | None = None) Module

Parses a module’s assembly format from a string.

Returns a new MlirModule or raises an MLIRError if the parsing fails.

See also: https://mlir.llvm.org/docs/LangRef/

static create(loc: Location | None = None) Module

Creates an empty module.

property context: Context

Context that created the Module.

property operation: Operation

Accesses the module as an operation.

property body: Block

Return the block for this module.

dump() None

Dumps a debug representation of the object to stderr.

__str__() str

Gets the assembly form of the operation with default options.

If more advanced control over the assembly formatting or I/O options is needed, use the dedicated print or get_asm method, which supports keyword arguments to customize behavior.

__eq__(other: Module) bool

Compares two modules for equality.

__hash__() int

Returns the hash value of the module.

class mlir._mlir_libs._mlir.ir._OperationBase
property _CAPIPtr: object

Gets a capsule wrapping the MlirOperation.

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

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

__hash__() int

Returns the hash value of the operation.

property attributes: OpAttributeMap

Returns a dictionary-like map of operation attributes.

property context: Context

Context that owns the operation.

property name: str

Returns the fully qualified name of the operation.

property operands: OpOperandList

Returns the list of operation operands.

property regions: RegionSequence

Returns the list of operation regions.

property results: OpResultList

Returns the list of Operation results.

property result: OpResult

Shortcut to get an op result if it has only one (throws an error otherwise).

property location: Location

Returns the source location the operation was defined or derived from.

property parent: Operation | None

Returns the parent operation, or None if at top level.

__str__() str

Returns the assembly form of the operation.

print(state: AsmState, file: object | None = None, binary: bool = False) None
print(large_elements_limit: int | None = None, large_resource_limit: int | None = None, enable_debug_info: bool = False, pretty_debug_info: bool = False, print_generic_op_form: bool = False, use_local_scope: bool = False, use_name_loc_as_prefix: bool = False, assume_verified: bool = False, file: object | None = None, binary: bool = False, skip_regions: bool = False) None

Prints the assembly form of the operation to a file like object.

Parameters:
  • large_elements_limit – Whether to elide elements attributes above this number of elements. Defaults to None (no limit).

  • large_resource_limit – Whether to elide resource attributes above this number of characters. Defaults to None (no limit). If large_elements_limit is set and this is None, the behavior will be to use large_elements_limit as large_resource_limit.

  • enable_debug_info – Whether to print debug/location information. Defaults to False.

  • pretty_debug_info – Whether to format debug information for easier reading by a human (warning: the result is unparseable). Defaults to False.

  • print_generic_op_form – Whether to print the generic assembly forms of all ops. Defaults to False.

  • use_local_scope – Whether to print in a way that is more optimized for multi-threaded access but may not be consistent with how the overall module prints.

  • use_name_loc_as_prefix – Whether to use location attributes (NameLoc) as prefixes for the SSA identifiers. Defaults to False.

  • assume_verified – By default, if not printing generic form, the verifier will be run and if it fails, generic form will be printed with a comment about failed verification. While a reasonable default for interactive use, for systematic use, it is often better for the caller to verify explicitly and report failures in a more robust fashion. Set this to True if doing this in order to avoid running a redundant verification. If the IR is actually invalid, behavior is undefined.

  • file – The file like object to write to. Defaults to sys.stdout.

  • binary – Whether to write bytes (True) or str (False). Defaults to False.

  • skip_regions – Whether to skip printing regions. Defaults to False.

write_bytecode(file: object, desired_version: int | None = None) None

Write the bytecode form of the operation to a file like object.

Parameters:
  • file – The file like object to write to.

  • desired_version – Optional version of bytecode to emit.

Returns:

The bytecode writer status.

get_asm(binary: bool = False, large_elements_limit: int | None = None, large_resource_limit: int | None = None, enable_debug_info: bool = False, pretty_debug_info: bool = False, print_generic_op_form: bool = False, use_local_scope: bool = False, use_name_loc_as_prefix: bool = False, assume_verified: bool = False, skip_regions: bool = False) object

Gets the assembly form of the operation with all options available.

Parameters:
  • binary – Whether to return a bytes (True) or str (False) object. Defaults to False.

  • ... (... others) – See the print() method for common keyword arguments for configuring the printout.

Returns:

Either a bytes or str object, depending on the setting of the binary argument.

verify() bool

Verify the operation. Raises MLIRError if verification fails, and returns true otherwise.

move_after(other: _OperationBase) None

Puts self immediately after the other operation in its parent block.

move_before(other: _OperationBase) None

Puts self immediately before the other operation in its parent block.

is_before_in_block(other: _OperationBase) bool

Checks if this operation is before another in the same block.

Parameters:

other – Another operation in the same parent block.

Returns:

True if this operation is before other in the operation list of the parent block.

clone(ip: object | None = None) Operation

Creates a deep copy of the operation.

Parameters:

ip – Optional insertion point where the cloned operation should be inserted. If None, the current insertion point is used. If False, the operation remains detached.

Returns:

A new Operation that is a clone of this operation.

detach_from_parent() OpView

Detaches the operation from its parent block.

property attached: bool

Reports if the operation is attached to its parent block.

erase() None

Erases the operation and frees its memory.

Note: After erasing, any Python references to the operation become invalid.

walk(callback: collections.abc.Callable[[Operation], WalkResult], walk_order: WalkOrder) None

Walks the operation tree with a callback function.

Parameters:
  • callback – A callable that takes an Operation and returns a WalkResult.

  • walk_order – The order of traversal (PRE_ORDER or POST_ORDER).

class mlir._mlir_libs._mlir.ir.Operation

Bases: _OperationBase

static create(name: str, results: collections.abc.Sequence[Type] | None = None, operands: collections.abc.Sequence[Value] | None = None, attributes: dict | None = None, successors: collections.abc.Sequence[Block] | None = None, regions: int = 0, loc: Location | None = None, ip: object | None = None, infer_type: bool = False) Operation

Creates a new operation.

Parameters:
  • name – Operation name (e.g. dialect.operation).

  • results – Optional sequence of Type representing op result types.

  • operands – Optional operands of the operation.

  • attributes – Optional Dict of {str: Attribute}.

  • successors – Optional List of Block for the operation’s successors.

  • regions – Number of regions to create (default = 0).

  • location – Optional Location object (defaults to resolve from context manager).

  • ip – Optional InsertionPoint (defaults to resolve from context manager or set to False to disable insertion, even with an insertion point set in the context manager).

  • infer_type – Whether to infer result types (default = False).

Returns:

A new detached Operation object. Detached operations can be added to blocks, which causes them to become attached.

static parse(source: str, *, source_name: str = '', context: Context | None = None) OpView

Parses an operation. Supports both text assembly format and binary bytecode format.

property _CAPIPtr: object

Gets a capsule wrapping the MlirOperation.

static _CAPICreate(arg: object, /) object

Creates an Operation from a capsule wrapping MlirOperation.

property operation: Operation

Returns self (the operation).

property opview: OpView

Returns an OpView of this operation.

Note: If the operation has a registered and loaded dialect then this OpView will be concrete wrapper class.

property block: Block

Returns the block containing this operation.

property successors: OpSuccessors

Returns the list of Operation successors.

_set_invalid() None

Invalidate the operation.

class mlir._mlir_libs._mlir.ir.OpView(operation: Operation)
class mlir._mlir_libs._mlir.ir.OpView(name: str, opRegionSpec: tuple[int, bool], operandSegmentSpecObj: object | None = None, resultSegmentSpecObj: object | None = None, results: list | None = None, operands: list | None = None, attributes: dict | None = None, successors: collections.abc.Sequence[Block] | None = None, regions: int | None = None, loc: Location | None = None, ip: object | None = None)

Bases: _OperationBase

property operation: Operation
property opview: OpView
__str__() str

Returns the assembly form of the operation.

property successors: OpSuccessors

Returns the list of Operation successors.

_set_invalid() None

Invalidate the operation.

_ODS_REGIONS: tuple = (0, True)
_ODS_OPERAND_SEGMENTS: None = None
_ODS_RESULT_SEGMENTS: None = None
classmethod build_generic(**kwargs) Any

(cls: object, results: list | None = None, operands: list | None = None, attributes: dict | None = None, successors: collections.abc.Sequence[_mlir.ir.Block] | None = None, regions: int | None = None, loc: _mlir.ir.Location | None = None, ip: object | None = None) -> object

Builds a specific, generated OpView based on class level attributes.

classmethod parse(**kwargs) Any

(cls: object, source: str, *, source_name: str = ‘’, context: Context | None = None) -> _mlir.ir.OpView

Parses a specific, generated OpView based on class level attributes.

class mlir._mlir_libs._mlir.ir.Region
property blocks: BlockList

Returns a forward-optimized sequence of blocks.

property owner: OpView

Returns the operation owning this region.

__iter__() BlockIterator

Iterates over blocks in the region.

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

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

class mlir._mlir_libs._mlir.ir.Block
property _CAPIPtr: object

Gets a capsule wrapping the MlirBlock.

property owner: OpView

Returns the owning operation of this block.

property region: Region

Returns the owning region of this block.

property arguments: BlockArgumentList

Returns a list of block arguments.

add_argument(type: Type, loc: Location) BlockArgument

Appends an argument of the specified type to the block.

Parameters:
  • type – The type of the argument to add.

  • loc – The source location for the argument.

Returns:

The newly added block argument.

erase_argument(index: int) None

Erases the argument at the specified index.

Parameters:

index – The index of the argument to erase.

property operations: OperationList

Returns a forward-optimized sequence of operations.

static create_at_start(parent: Region, arg_types: collections.abc.Sequence = [], arg_locs: collections.abc.Sequence | None = None) Block

Creates and returns a new Block at the beginning of the given region (with given argument types and locations).

append_to(region: Region) None

Appends this block to a region.

Transfers ownership if the block is currently owned by another region.

Parameters:

region – The region to append the block to.

create_before(*arg_types, arg_locs: collections.abc.Sequence | None = None) Block

Creates and returns a new Block before this block (with given argument types and locations).

create_after(*arg_types, arg_locs: collections.abc.Sequence | None = None) Block

Creates and returns a new Block after this block (with given argument types and locations).

__iter__() OperationIterator

Iterates over operations in the block.

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

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

__hash__() int

Returns the hash value of the block.

__str__() str

Returns the assembly form of the block.

append(operation: _OperationBase) None

Appends an operation to this block.

If the operation is currently in another block, it will be moved.

Parameters:

operation – The operation to append to the block.

property successors: BlockSuccessors

Returns the list of Block successors.

property predecessors: BlockPredecessors

Returns the list of Block predecessors.

class mlir._mlir_libs._mlir.ir.InsertionPoint(block: Block)
class mlir._mlir_libs._mlir.ir.InsertionPoint(beforeOperation: _OperationBase)
__enter__() object

Enters the insertion point as a context manager.

__exit__(exc_type: object | None, exc_value: object | None, traceback: object | None) None

Exits the insertion point context manager.

current: InsertionPoint = Ellipsis

Gets the InsertionPoint bound to the current thread or raises ValueError if none has been set.

static at_block_begin(block: Block) InsertionPoint

Creates an insertion point at the beginning of a block.

Parameters:

block – The block at whose beginning operations should be inserted.

Returns:

An InsertionPoint at the block’s beginning.

static at_block_terminator(block: Block) InsertionPoint

Creates an insertion point before a block’s terminator.

Parameters:

block – The block whose terminator to insert before.

Returns:

An InsertionPoint before the terminator.

Raises:

ValueError – If the block has no terminator.

static after(operation: _OperationBase) InsertionPoint

Creates an insertion point immediately after an operation.

Parameters:

operation – The operation after which to insert.

Returns:

An InsertionPoint after the operation.

insert(operation: _OperationBase) None

Inserts an operation at this insertion point.

Parameters:

operation – The operation to insert.

property block: Block

Returns the block that this InsertionPoint points to.

property ref_operation: Operation | None

The reference operation before which new operations are inserted, or None if the insertion point is at the end of the block.

class mlir._mlir_libs._mlir.ir.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._mlir_libs._mlir.ir.NamedAttribute
__repr__() str

Returns a string representation of the named attribute.

property name: str

The name of the NamedAttribute binding.

property attr: Attribute

The underlying generic attribute of the NamedAttribute binding.

class mlir._mlir_libs._mlir.ir.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._mlir_libs._mlir.ir.TypeID
property _CAPIPtr: object

Gets a capsule wrapping the MlirTypeID.

static _CAPICreate(arg: object, /) TypeID

Creates a TypeID from a capsule wrapping MlirTypeID.

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

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

__hash__() int

Returns the hash value of the TypeID.

class mlir._mlir_libs._mlir.ir.Value(value: Value)
property _CAPIPtr: object

Gets a capsule wrapping the MlirValue.

static _CAPICreate(arg: object, /) Value

Creates a Value from a capsule wrapping MlirValue.

property context: Context

Context in which the value lives.

dump() None

Dumps a debug representation of the object to stderr.

property owner: object

Returns the owner of the value (Operation for results, Block for arguments).

property uses: OpOperandIterator

Returns an iterator over uses of this value.

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

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

__hash__() int

Returns the hash value of the value.

__str__() str

Returns the string form of the value.

If the value is a block argument, this is the assembly form of its type and the position in the argument list. If the value is an operation result, this is equivalent to printing the operation that produced it.

get_name(use_local_scope: bool = False, use_name_loc_as_prefix: bool = False) str
get_name(state: AsmState) str

Returns the string form of value as an operand (i.e., the ValueID).

property type: Type

Returns the type of the value.

set_type(type: Type) None

Sets the type of the value.

replace_all_uses_with(arg: Value, /) None

Replace all uses of value with the new value, updating anything in the IR that uses self to use the other value instead.

replace_all_uses_except(with_: Value, exceptions: Operation) None
replace_all_uses_except(with_: Value, exceptions: list) None
replace_all_uses_except(with_: Value, exceptions: Operation) None
replace_all_uses_except(with_: Value, exceptions: collections.abc.Sequence[Operation]) None
maybe_downcast() Value

Downcasts the Value to a more specific kind if possible.

property location: Location

Returns the source location of the value.

class mlir._mlir_libs._mlir.ir.BlockArgument(value: Value)

Bases: Value

static isinstance(other_value: Value) bool
maybe_downcast() BlockArgument

Downcasts the Value to a more specific kind if possible.

property owner: Block

Returns the block that owns this argument.

property arg_number: int

Returns the position of this argument in the block’s argument list.

set_type(type: Type) None

Sets the type of this block argument.

class mlir._mlir_libs._mlir.ir.OpResult(value: Value)

Bases: Value

static isinstance(other_value: Value) bool
maybe_downcast() OpResult

Downcasts the Value to a more specific kind if possible.

property owner: Operation

Returns the operation that produces this result.

property result_number: int

Returns the position of this result in the operation’s result list.

class mlir._mlir_libs._mlir.ir.OpOperand
property owner: OpView

Returns the operation that owns this operand.

property operand_number: int

Returns the operand number in the owning operation.

class mlir._mlir_libs._mlir.ir.AsmState(value: Value, use_local_scope: bool = False)
class mlir._mlir_libs._mlir.ir.AsmState(op: _OperationBase, use_local_scope: bool = False)
class mlir._mlir_libs._mlir.ir.SymbolTable(arg: _OperationBase, /)
__getitem__(arg: str, /) OpView

Looks up a symbol by name in the symbol table.

Parameters:

name – The name of the symbol to look up.

Returns:

The operation defining the symbol.

Raises:

KeyError – If the symbol is not found.

insert(operation: _OperationBase) StringAttr

Inserts a symbol operation into the symbol table.

Parameters:

operation – An operation with a symbol name to insert.

Returns:

The symbol name attribute of the inserted operation.

Raises:

ValueError – If the operation does not have a symbol name.

erase(operation: _OperationBase) None

Erases a symbol operation from the symbol table.

Parameters:

operation – The symbol operation to erase.

Note

The operation is also erased from the IR and invalidated.

__delitem__(arg: str, /) None

Deletes a symbol by name from the symbol table.

__contains__(arg: str, /) bool

Checks if a symbol with the given name exists in the table.

static set_symbol_name(symbol: _OperationBase, name: str) None

Sets the symbol name for a symbol operation.

static get_symbol_name(symbol: _OperationBase) StringAttr

Gets the symbol name from a symbol operation.

static get_visibility(symbol: _OperationBase) StringAttr

Gets the visibility attribute of a symbol operation.

static set_visibility(symbol: _OperationBase, visibility: str) None

Sets the visibility attribute of a symbol operation.

static replace_all_symbol_uses(old_symbol: str, new_symbol: str, from_op: _OperationBase) None

Replaces all uses of a symbol with a new symbol name within the given operation.

static walk_symbol_tables(from_op: _OperationBase, all_sym_uses_visible: bool, callback: object) None

Walks symbol tables starting from an operation with a callback function.

class mlir._mlir_libs._mlir.ir.BlockArgumentList
__add__(arg: BlockArgumentList, /) list[BlockArgument]
property types: list[Type]

Returns a list of types for all arguments in this argument list.

class mlir._mlir_libs._mlir.ir.BlockIterator
__iter__() BlockIterator

Returns an iterator over the blocks in the operation’s region.

__next__() Block

Returns the next block in the iteration.

class mlir._mlir_libs._mlir.ir.BlockList
__getitem__(arg: int, /) Block

Returns the block at the specified index.

__iter__() BlockIterator

Returns an iterator over blocks in the operation’s region.

__len__() int

Returns the number of blocks in the operation’s region.

append(*args, arg_locs: collections.abc.Sequence | None = None) Block

Appends a new block, with argument types as positional args.

Returns:

The created block.

class mlir._mlir_libs._mlir.ir.BlockSuccessors
__add__(arg: BlockSuccessors, /) list[Block]
class mlir._mlir_libs._mlir.ir.BlockPredecessors
__add__(arg: BlockPredecessors, /) list[Block]
class mlir._mlir_libs._mlir.ir.OperationIterator
__iter__() OperationIterator

Returns an iterator over the operations in an operation’s block.

__next__() OpView

Returns the next operation in the iteration.

class mlir._mlir_libs._mlir.ir.OperationList
__getitem__(arg: int, /) OpView

Returns the operation at the specified index.

__iter__() OperationIterator

Returns an iterator over operations in the list.

__len__() int

Returns the number of operations in the list.

class mlir._mlir_libs._mlir.ir.OpAttributeMap
__contains__(name: str) bool

Checks if an attribute with the given name exists in the map.

__len__() int

Returns the number of attributes in the map.

__getitem__(name: str) Attribute
__getitem__(index: int) NamedAttribute

Gets a named attribute by index.

__setitem__(name: str, attr: Attribute) None

Sets an attribute with the given name.

__delitem__(name: str) None

Deletes an attribute with the given name.

__iter__() collections.abc.Iterator

Iterates over attribute names.

keys() list

Returns a list of attribute names.

values() list

Returns a list of attribute values.

items() list

Returns a list of (name, attribute) tuples.

class mlir._mlir_libs._mlir.ir.OpOperandIterator
__iter__() OpOperandIterator

Returns an iterator over operands.

__next__() OpOperand

Returns the next operand in the iteration.

class mlir._mlir_libs._mlir.ir.OpOperandList
__add__(arg: OpOperandList, /) list[Value]
__setitem__(index: int, value: Value) None

Sets the operand at the specified index to a new value.

class mlir._mlir_libs._mlir.ir.OpResultList
__add__(arg: OpResultList, /) list[OpResult]
property types: list[Type]

Returns a list of types for all results in this result list.

property owner: OpView

Returns the operation that owns this result list.

class mlir._mlir_libs._mlir.ir.OpSuccessors
__add__(arg: OpSuccessors, /) list[Block]
__setitem__(index: int, block: Block) None

Sets the successor block at the specified index.

class mlir._mlir_libs._mlir.ir.RegionIterator
__iter__() RegionIterator

Returns an iterator over the regions in the operation.

__next__() Region

Returns the next region in the iteration.

class mlir._mlir_libs._mlir.ir.RegionSequence
__add__(arg: RegionSequence, /) list[Region]
__iter__() RegionIterator

Returns an iterator over the regions in the sequence.

class mlir._mlir_libs._mlir.ir._GlobalDebug
flag: bool = Ellipsis

LLVM-wide debug flag.

static set_types(types: str) None
static set_types(types: collections.abc.Sequence[str]) None

Sets multiple specific debug types to be produced by LLVM.

class mlir._mlir_libs._mlir.ir.AttrBuilder
static contains(attribute_kind: str) bool

Checks whether an attribute builder is registered for the given attribute kind.

static get(attribute_kind: str) collections.abc.Callable

Gets the registered attribute builder for the given attribute kind.

static insert(attribute_kind: str, attr_builder: collections.abc.Callable, replace: bool = False) None

Register an attribute builder for building MLIR attributes from Python values.

class mlir._mlir_libs._mlir.ir.AffineExpr
property _CAPIPtr: object
_CAPICreate() AffineExpr
__add__(arg: AffineExpr, /) AffineAddExpr
__add__(arg: int, /) AffineAddExpr
__radd__(arg: int, /) AffineAddExpr
__mul__(arg: AffineExpr, /) AffineMulExpr
__mul__(arg: int, /) AffineMulExpr
__rmul__(arg: int, /) AffineMulExpr
__mod__(arg: AffineExpr, /) AffineModExpr
__mod__(arg: int, /) AffineModExpr
__rmod__(arg: int, /) AffineModExpr
__sub__(arg: AffineExpr, /) AffineAddExpr
__sub__(arg: int, /) AffineAddExpr
__rsub__(arg: int, /) AffineAddExpr
__eq__(arg: AffineExpr, /) bool
__eq__(arg: object, /) bool
__str__() str
__repr__() str
__hash__() int
property context: Context
compose(arg: AffineMap, /) AffineExpr
shift_dims(num_dims: int, shift: int, offset: int = 0) AffineExpr
shift_symbols(num_symbols: int, shift: int, offset: int = 0) AffineExpr
static simplify_affine_expr(expr: AffineExpr, num_dims: int, num_symbols: int) AffineExpr

Simplify an affine expression by flattening and some amount of simple analysis.

static get_add(arg0: AffineExpr, arg1: AffineExpr, /) AffineAddExpr
static get_add(arg0: int, arg1: AffineExpr, /) AffineAddExpr
static get_add(arg0: AffineExpr, arg1: int, /) AffineAddExpr

Gets an affine expression containing a sum of an expression and a constant.

static get_mul(arg0: AffineExpr, arg1: AffineExpr, /) AffineMulExpr
static get_mul(arg0: int, arg1: AffineExpr, /) AffineMulExpr
static get_mul(arg0: AffineExpr, arg1: int, /) AffineMulExpr

Gets an affine expression containing a product of an expression and a constant.

static get_mod(arg0: AffineExpr, arg1: AffineExpr, /) AffineModExpr
static get_mod(arg0: int, arg1: AffineExpr, /) AffineModExpr
static get_mod(arg0: AffineExpr, arg1: int, /) AffineModExpr

Gets an affine expression containing the module of dividingan expression by a constant.

static get_floor_div(arg0: AffineExpr, arg1: AffineExpr, /) AffineFloorDivExpr
static get_floor_div(arg0: int, arg1: AffineExpr, /) AffineFloorDivExpr
static get_floor_div(arg0: AffineExpr, arg1: int, /) AffineFloorDivExpr

Gets an affine expression containing the rounded-down result of dividing an expression by a constant.

static get_ceil_div(arg0: AffineExpr, arg1: AffineExpr, /) AffineCeilDivExpr
static get_ceil_div(arg0: int, arg1: AffineExpr, /) AffineCeilDivExpr
static get_ceil_div(arg0: AffineExpr, arg1: int, /) AffineCeilDivExpr

Gets an affine expression containing the rounded-up result of dividing an expression by a constant.

static get_constant(value: int, context: Context | None = None) AffineConstantExpr

Gets a constant affine expression with the given value.

static get_dim(position: int, context: Context | None = None) AffineDimExpr

Gets an affine expression of a dimension at the given position.

static get_symbol(position: int, context: Context | None = None) AffineSymbolExpr

Gets an affine expression of a symbol at the given position.

dump() None

Dumps a debug representation of the object to stderr.

class mlir._mlir_libs._mlir.ir.AffineConstantExpr(expr: AffineExpr)

Bases: AffineExpr

static isinstance(other: AffineExpr) bool
static get(value: int, context: Context | None = None) AffineConstantExpr
property value: int
class mlir._mlir_libs._mlir.ir.AffineDimExpr(expr: AffineExpr)

Bases: AffineExpr

static isinstance(other: AffineExpr) bool
static get(position: int, context: Context | None = None) AffineDimExpr
property position: int
class mlir._mlir_libs._mlir.ir.AffineSymbolExpr(expr: AffineExpr)

Bases: AffineExpr

static isinstance(other: AffineExpr) bool
static get(position: int, context: Context | None = None) AffineSymbolExpr
property position: int
class mlir._mlir_libs._mlir.ir.AffineBinaryExpr(expr: AffineExpr)

Bases: AffineExpr

static isinstance(other: AffineExpr) bool
property lhs: AffineExpr
property rhs: AffineExpr
class mlir._mlir_libs._mlir.ir.AffineAddExpr(expr: AffineExpr)

Bases: AffineBinaryExpr

static isinstance(other: AffineExpr) bool
static get(arg0: AffineExpr, arg1: AffineExpr, /) AffineAddExpr
class mlir._mlir_libs._mlir.ir.AffineMulExpr(expr: AffineExpr)

Bases: AffineBinaryExpr

static isinstance(other: AffineExpr) bool
static get(arg0: AffineExpr, arg1: AffineExpr, /) AffineMulExpr
class mlir._mlir_libs._mlir.ir.AffineModExpr(expr: AffineExpr)

Bases: AffineBinaryExpr

static isinstance(other: AffineExpr) bool
static get(arg0: AffineExpr, arg1: AffineExpr, /) AffineModExpr
class mlir._mlir_libs._mlir.ir.AffineFloorDivExpr(expr: AffineExpr)

Bases: AffineBinaryExpr

static isinstance(other: AffineExpr) bool
static get(arg0: AffineExpr, arg1: AffineExpr, /) AffineFloorDivExpr
class mlir._mlir_libs._mlir.ir.AffineCeilDivExpr(expr: AffineExpr)

Bases: AffineBinaryExpr

static isinstance(other: AffineExpr) bool
static get(arg0: AffineExpr, arg1: AffineExpr, /) AffineCeilDivExpr
class mlir._mlir_libs._mlir.ir.AffineMap
property _CAPIPtr: object
_CAPICreate() AffineMap
__eq__(arg: AffineMap, /) bool
__eq__(arg: object, /) bool
__str__() str
__repr__() str
__hash__() int
static compress_unused_symbols(arg0: list, arg1: Context, /) list[AffineMap]
property context: Context

Context that owns the Affine Map

dump() None

Dumps a debug representation of the object to stderr.

static get(dim_count: int, symbol_count: int, exprs: list, context: Context | None = None) AffineMap

Gets a map with the given expressions as results.

static get_constant(value: int, context: Context | None = None) AffineMap

Gets an affine map with a single constant result

static get_empty(context: Context | None = None) AffineMap

Gets an empty affine map.

static get_identity(n_dims: int, context: Context | None = None) AffineMap

Gets an identity map with the given number of dimensions.

static get_minor_identity(n_dims: int, n_results: int, context: Context | None = None) AffineMap

Gets a minor identity map with the given number of dimensions and results.

static get_permutation(permutation: collections.abc.Sequence[int], context: Context | None = None) AffineMap

Gets an affine map that permutes its inputs.

get_submap(result_positions: collections.abc.Sequence[int]) AffineMap
get_major_submap(n_results: int) AffineMap
get_minor_submap(n_results: int) AffineMap
replace(expr: AffineExpr, replacement: AffineExpr, n_result_dims: int, n_result_syms: int) AffineMap
property is_permutation: bool
property is_projected_permutation: bool
property n_dims: int
property n_inputs: int
property n_symbols: int
property results: AffineExprList
class mlir._mlir_libs._mlir.ir.AffineExprList
__add__(arg: AffineExprList, /) list[AffineExpr]
class mlir._mlir_libs._mlir.ir.IntegerSet
property _CAPIPtr: object
_CAPICreate() IntegerSet
__eq__(arg: IntegerSet, /) bool
__eq__(arg: object, /) bool
__str__() str
__repr__() str
__hash__() int
property context: Context
dump() None

Dumps a debug representation of the object to stderr.

static get(num_dims: int, num_symbols: int, exprs: list, eq_flags: collections.abc.Sequence[bool], context: Context | None = None) IntegerSet
static get_empty(num_dims: int, num_symbols: int, context: Context | None = None) IntegerSet
get_replaced(dim_exprs: list, symbol_exprs: list, num_result_dims: int, num_result_symbols: int) IntegerSet
property is_canonical_empty: bool
property n_dims: int
property n_symbols: int
property n_inputs: int
property n_equalities: int
property n_inequalities: int
property constraints: IntegerSetConstraintList
class mlir._mlir_libs._mlir.ir.IntegerSetConstraint
property expr: AffineExpr
property is_eq: bool
class mlir._mlir_libs._mlir.ir.IntegerSetConstraintList
__add__(arg: IntegerSetConstraintList, /) list[IntegerSetConstraint]
class mlir._mlir_libs._mlir.ir.AffineMapAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(affine_map: AffineMap) AffineMapAttr

Gets an attribute wrapping an AffineMap.

property value: AffineMap

Returns the value of the AffineMap attribute

class mlir._mlir_libs._mlir.ir.DenseBoolArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence, context: Context | None = None) DenseBoolArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) bool
__len__() int
__iter__() DenseBoolArrayIterator
__add__(arg: list, /) DenseBoolArrayAttr
class mlir._mlir_libs._mlir.ir.DenseBoolArrayIterator
__iter__() DenseBoolArrayIterator
__next__() bool
class mlir._mlir_libs._mlir.ir.DenseI8ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence[int], context: Context | None = None) DenseI8ArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) int
__len__() int
__iter__() DenseI8ArrayIterator
__add__(arg: list, /) DenseI8ArrayAttr
class mlir._mlir_libs._mlir.ir.DenseI8ArrayIterator
__iter__() DenseI8ArrayIterator
__next__() int
class mlir._mlir_libs._mlir.ir.DenseI16ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence[int], context: Context | None = None) DenseI16ArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) int
__len__() int
__iter__() DenseI16ArrayIterator
__add__(arg: list, /) DenseI16ArrayAttr
class mlir._mlir_libs._mlir.ir.DenseI16ArrayIterator
__iter__() DenseI16ArrayIterator
__next__() int
class mlir._mlir_libs._mlir.ir.DenseI32ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence[int], context: Context | None = None) DenseI32ArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) int
__len__() int
__iter__() DenseI32ArrayIterator
__add__(arg: list, /) DenseI32ArrayAttr
class mlir._mlir_libs._mlir.ir.DenseI32ArrayIterator
__iter__() DenseI32ArrayIterator
__next__() int
class mlir._mlir_libs._mlir.ir.DenseI64ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence[int], context: Context | None = None) DenseI64ArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) int
__len__() int
__iter__() DenseI64ArrayIterator
__add__(arg: list, /) DenseI64ArrayAttr
class mlir._mlir_libs._mlir.ir.DenseI64ArrayIterator
__iter__() DenseI64ArrayIterator
__next__() int
class mlir._mlir_libs._mlir.ir.DenseF32ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence[float], context: Context | None = None) DenseF32ArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) float
__len__() int
__iter__() DenseF32ArrayIterator
__add__(arg: list, /) DenseF32ArrayAttr
class mlir._mlir_libs._mlir.ir.DenseF32ArrayIterator
__iter__() DenseF32ArrayIterator
__next__() float
class mlir._mlir_libs._mlir.ir.DenseF64ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(values: collections.abc.Sequence[float], context: Context | None = None) DenseF64ArrayAttr

Gets a uniqued dense array attribute

__getitem__(arg: int, /) float
__len__() int
__iter__() DenseF64ArrayIterator
__add__(arg: list, /) DenseF64ArrayAttr
class mlir._mlir_libs._mlir.ir.DenseF64ArrayIterator
__iter__() DenseF64ArrayIterator
__next__() float
class mlir._mlir_libs._mlir.ir.ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(attributes: list, context: Context | None = None) ArrayAttr

Gets a uniqued Array attribute

__getitem__(arg: int, /) Attribute
__len__() int
__iter__() ArrayAttributeIterator
__add__(arg: list, /) ArrayAttr
class mlir._mlir_libs._mlir.ir.ArrayAttributeIterator
__iter__() ArrayAttributeIterator
__next__() Attribute
class mlir._mlir_libs._mlir.ir.BoolAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(value: bool, context: Context | None = None) BoolAttr

Gets an uniqued bool attribute

property value: bool

Returns the value of the bool attribute

__bool__() bool

Converts the value of the bool attribute to a Python bool

class mlir._mlir_libs._mlir.ir.DenseElementsAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

__len__() int
static get(array: typing_extensions.Buffer, signless: bool = True, type: Type | None = None, shape: collections.abc.Sequence[int] | None = None, context: Context | None = None) DenseElementsAttr
static get(attrs: list, type: Type | None = None, context: Context | None = None) DenseElementsAttr

Gets a DenseElementsAttr from a Python list of attributes.

Note that it can be expensive to construct attributes individually. For a large number of elements, consider using a Python buffer or array instead.

Parameters:
  • attrs – A list of attributes.

  • type – The desired shape and type of the resulting DenseElementsAttr. If not provided, the element type is determined based on the type of the 0th attribute and the shape is [len(attrs)].

  • context – Explicit context, if not from context manager.

Returns:

DenseElementsAttr on success.

Raises:

ValueError – If the type of the attributes does not match the type specified by shaped_type.

static get_splat(shaped_type: Type, element_attr: Attribute) DenseElementsAttr

Gets a DenseElementsAttr where all values are the same

property is_splat: bool
get_splat_value() Attribute
class mlir._mlir_libs._mlir.ir.DenseFPElementsAttr(cast_from_attr: Attribute)

Bases: DenseElementsAttr

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

__getitem__(arg: int, /) float
class mlir._mlir_libs._mlir.ir.DenseIntElementsAttr(cast_from_attr: Attribute)

Bases: DenseElementsAttr

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

__getitem__(arg: int, /) int
class mlir._mlir_libs._mlir.ir.DenseResourceElementsAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get_from_buffer(array: typing_extensions.Buffer, name: str, type: Type, alignment: int | None = None, is_mutable: bool = False, context: Context | None = None) DenseResourceElementsAttr

Gets a DenseResourceElementsAttr from a Python buffer or array.

This function does minimal validation or massaging of the data, and it is up to the caller to ensure that the buffer meets the characteristics implied by the shape.

The backing buffer and any user objects will be retained for the lifetime of the resource blob. This is typically bounded to the context but the resource can have a shorter lifespan depending on how it is used in subsequent processing.

Parameters:
  • buffer – The array or buffer to convert.

  • name – Name to provide to the resource (may be changed upon collision).

  • type – The explicit ShapedType to construct the attribute with.

  • context – Explicit context, if not from context manager.

Returns:

DenseResourceElementsAttr on success.

Raises:

ValueError – If the type of the buffer or array cannot be matched to an MLIR type or if the buffer does not meet expectations.

class mlir._mlir_libs._mlir.ir.DictAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

__contains__(arg: str, /) bool
__len__() int
static get(value: dict = {}, context: Context | None = None) DictAttr

Gets an uniqued dict attribute

__getitem__(arg: str, /) Attribute
__getitem__(arg: int, /) NamedAttribute
class mlir._mlir_libs._mlir.ir.SymbolRefAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(symbols: collections.abc.Sequence[str], context: Context | None = None) SymbolRefAttr

Gets a uniqued SymbolRef attribute from a list of symbol names

property value: list[str]

Returns the value of the SymbolRef attribute as a list[str]

class mlir._mlir_libs._mlir.ir.FlatSymbolRefAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(value: str, context: Context | None = None) FlatSymbolRefAttr

Gets a uniqued FlatSymbolRef attribute

property value: str

Returns the value of the FlatSymbolRef attribute as a string

class mlir._mlir_libs._mlir.ir.OpaqueAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(dialect_namespace: str, buffer: typing_extensions.Buffer, type: Type, context: Context | None = None) OpaqueAttr

Gets an Opaque attribute.

property dialect_namespace: str

Returns the dialect namespace for the Opaque attribute as a string

property data: bytes

Returns the data for the Opaqued attributes as bytes

class mlir._mlir_libs._mlir.ir.FloatAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(type: Type, value: float, loc: Location | None = None) FloatAttr

Gets an uniqued float point attribute associated to a type

static get_unchecked(type: Type, value: float, context: Context | None = None) FloatAttr

Gets an uniqued float point attribute associated to a type

static get_f32(value: float, context: Context | None = None) FloatAttr

Gets an uniqued float point attribute associated to a f32 type

static get_f64(value: float, context: Context | None = None) FloatAttr

Gets an uniqued float point attribute associated to a f64 type

property value: float

Returns the value of the float attribute

__float__() float

Converts the value of the float attribute to a Python float

class mlir._mlir_libs._mlir.ir.IntegerAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(type: Type, value: int) IntegerAttr

Gets an uniqued integer attribute associated to a type

property value: int

Returns the value of the integer attribute

__int__() int

Converts the value of the integer attribute to a Python int

class mlir._mlir_libs._mlir.ir.IntegerSetAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(integer_set: IntegerSet) IntegerSetAttr

Gets an attribute wrapping an IntegerSet.

class mlir._mlir_libs._mlir.ir.StringAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

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._mlir_libs._mlir.ir.TypeAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(value: Type, context: Context | None = None) TypeAttr

Gets a uniqued Type attribute

property value: Type
class mlir._mlir_libs._mlir.ir.UnitAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

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

Create a Unit attribute.

class mlir._mlir_libs._mlir.ir.StridedLayoutAttr(cast_from_attr: Attribute)

Bases: Attribute

static isinstance(other: Attribute) bool
property type: Type

Returns the type of the Attribute.

static_typeid: TypeID = Ellipsis

static_typeid(/) -> TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

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._mlir_libs._mlir.ir.InferTypeOpInterface(object: InferTypeOpInterface.__init__.object, context: Context | None = None)
property operation: Operation

Returns an Operation for which the interface was constructed.

property opview: OpView

Returns an OpView subclass instance for which the interface was constructed

inferReturnTypes(operands: list | None = None, attributes: Attribute | None = None, properties: typing_extensions.CapsuleType | None = None, regions: collections.abc.Sequence[Region] | None = None, context: Context | None = None, loc: Location | None = None) list[Type]

Given the arguments required to build an operation, attempts to infer its return types. Raises ValueError on failure.

class mlir._mlir_libs._mlir.ir.ShapedTypeComponents
property element_type: Type

Returns the element type of the shaped type components.

static get(element_type: Type) ShapedTypeComponents
static get(shape: list, element_type: Type) ShapedTypeComponents
static get(shape: list, element_type: Type, attribute: Attribute) ShapedTypeComponents

Create a ranked shaped type components object with attribute.

property has_rank: bool

Returns whether the given shaped type component is ranked.

property rank: int | None

Returns the rank of the given ranked shaped type components. If the shaped type components does not have a rank, None is returned.

property shape: list | None

Returns the shape of the ranked shaped type components as a list of integers. Returns none if the shaped type component does not have a rank.

class mlir._mlir_libs._mlir.ir.InferShapedTypeOpInterface(object: InferShapedTypeOpInterface.__init__.object, context: Context | None = None)
property operation: Operation

Returns an Operation for which the interface was constructed.

property opview: OpView

Returns an OpView subclass instance for which the interface was constructed

inferReturnTypeComponents(operands: list | None = None, attributes: Attribute | None = None, regions: typing_extensions.CapsuleType | None = None, properties: collections.abc.Sequence[Region] | None = None, context: Context | None = None, loc: Location | None = None) list[ShapedTypeComponents]

Given the arguments required to build an operation, attempts to infer its return shaped type components. Raises ValueError on failure.

class mlir._mlir_libs._mlir.ir.IntegerType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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_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

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._mlir_libs._mlir.ir.FloatType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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.

property width: int

Returns the width of the floating-point type

class mlir._mlir_libs._mlir.ir.IndexType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) IndexType

Create a index type.

class mlir._mlir_libs._mlir.ir.Float4E2M1FNType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float4E2M1FNType

Create a float4_e2m1fn type.

class mlir._mlir_libs._mlir.ir.Float6E2M3FNType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float6E2M3FNType

Create a float6_e2m3fn type.

class mlir._mlir_libs._mlir.ir.Float6E3M2FNType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float6E3M2FNType

Create a float6_e3m2fn type.

class mlir._mlir_libs._mlir.ir.Float8E4M3FNType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E4M3FNType

Create a float8_e4m3fn type.

class mlir._mlir_libs._mlir.ir.Float8E5M2Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E5M2Type

Create a float8_e5m2 type.

class mlir._mlir_libs._mlir.ir.Float8E4M3Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E4M3Type

Create a float8_e4m3 type.

class mlir._mlir_libs._mlir.ir.Float8E4M3FNUZType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E4M3FNUZType

Create a float8_e4m3fnuz type.

class mlir._mlir_libs._mlir.ir.Float8E4M3B11FNUZType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E4M3B11FNUZType

Create a float8_e4m3b11fnuz type.

class mlir._mlir_libs._mlir.ir.Float8E5M2FNUZType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E5M2FNUZType

Create a float8_e5m2fnuz type.

class mlir._mlir_libs._mlir.ir.Float8E3M4Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E3M4Type

Create a float8_e3m4 type.

class mlir._mlir_libs._mlir.ir.Float8E8M0FNUType(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) Float8E8M0FNUType

Create a float8_e8m0fnu type.

class mlir._mlir_libs._mlir.ir.BF16Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) BF16Type

Create a bf16 type.

class mlir._mlir_libs._mlir.ir.F16Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) F16Type

Create a f16 type.

class mlir._mlir_libs._mlir.ir.FloatTF32Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) FloatTF32Type

Create a tf32 type.

class mlir._mlir_libs._mlir.ir.F32Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) F32Type

Create a f32 type.

class mlir._mlir_libs._mlir.ir.F64Type(cast_from_type: Type)

Bases: FloatType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) F64Type

Create a f64 type.

class mlir._mlir_libs._mlir.ir.NoneType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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) NoneType

Create a none type.

class mlir._mlir_libs._mlir.ir.ComplexType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(arg: Type, /) ComplexType

Create a complex type

property element_type: Type

Returns element type.

class mlir._mlir_libs._mlir.ir.ShapedType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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.

property element_type: Type

Returns the element type of the shaped type.

property has_rank: bool

Returns whether the given shaped type is ranked.

property rank: int

Returns the rank of the given ranked shaped type.

property has_static_shape: bool

Returns whether the given shaped type has a static shape.

is_dynamic_dim(dim: int) bool

Returns whether the dim-th dimension of the given shaped type is dynamic.

is_static_dim(dim: int) bool

Returns whether the dim-th dimension of the given shaped type is static.

get_dim_size(dim: int) int

Returns the dim-th dimension of the given ranked shaped type.

static is_dynamic_size(dim_size: int) bool

Returns whether the given dimension size indicates a dynamic dimension.

static is_static_size(dim_size: int) bool

Returns whether the given dimension size indicates a static dimension.

is_dynamic_stride_or_offset(dim_size: int) bool

Returns whether the given value is used as a placeholder for dynamic strides and offsets in shaped types.

is_static_stride_or_offset(dim_size: int) bool

Returns whether the given shaped type stride or offset value is statically-sized.

property shape: list[int]

Returns the shape of the ranked shaped type as a list of integers.

static get_dynamic_size() int

Returns the value used to indicate dynamic dimensions in shaped types.

static get_dynamic_stride_or_offset() int

Returns the value used to indicate dynamic strides or offsets in shaped types.

class mlir._mlir_libs._mlir.ir.VectorType(cast_from_type: Type)

Bases: ShapedType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(shape: collections.abc.Sequence[int], element_type: Type, *, scalable: list | 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: list | 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]
class mlir._mlir_libs._mlir.ir.RankedTensorType(cast_from_type: Type)

Bases: ShapedType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(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._mlir_libs._mlir.ir.UnrankedTensorType(cast_from_type: Type)

Bases: ShapedType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(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._mlir_libs._mlir.ir.MemRefType(cast_from_type: Type)

Bases: ShapedType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(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._mlir_libs._mlir.ir.UnrankedMemRefType(cast_from_type: Type)

Bases: ShapedType

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(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._mlir_libs._mlir.ir.TupleType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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_tuple(elements: collections.abc.Sequence[Type], context: Context | None = None) TupleType
static get_tuple(elements: collections.abc.Sequence[Type], context: Context | None = None) TupleType
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._mlir_libs._mlir.ir.FunctionType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(inputs: collections.abc.Sequence[Type], results: collections.abc.Sequence[Type], context: Context | None = None) FunctionType
static get(inputs: collections.abc.Sequence[Type], results: collections.abc.Sequence[Type], context: Context | None = None) FunctionType
property inputs: list

Returns the list of input types in the FunctionType.

property results: list

Returns the list of result types in the FunctionType.

class mlir._mlir_libs._mlir.ir.OpaqueType(cast_from_type: Type)

Bases: Type

static isinstance(other: Type) bool
static_typeid: TypeID = Ellipsis

static_typeid(/) -> 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(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.