mlir._mlir_libs._mlir.dialects.transform

Classes

Package Contents

class mlir._mlir_libs._mlir.dialects.transform.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.dialects.transform.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__(/) → Context

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.

is_dialect_loaded(dialect_name: str) → bool

Checks if a dialect is loaded in the context.

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_remarks(*, policy: RemarkPolicy = RemarkPolicy.ALL, output_file: str | None = None, format: RemarkFormat = RemarkFormat.YAML, all_filter: str = '', passed_filter: str = '', missed_filter: str = '', analysis_filter: str = '', failed_filter: str = '', callback: object | None = None, print_as_emit_remarks: bool | None = None) → None

Enables the optimization remark engine on this context.

Remarks are reported by passes (and by Location.emit_remark) and selected by the category filters, regular expressions anchored by the engine: all_filter applies to every kind, the other filters to one kind each; a kind without a matching filter is not reported.

The sink is selected by the arguments: output_file streams the remarks to a file in format, callback delivers them to Python, and without either they are emitted as MLIR remark diagnostics.

Parameters:
  • policy – RemarkPolicy.ALL reports remarks as they are emitted; RemarkPolicy.FINAL postpones them until finalize_remarks() and reports the final set, grouping related remarks under their parents.

  • output_file – Path of the remark file, written on finalize_remarks().

  • format – The serialization format of output_file.

  • all_filter – Category regex applied to every remark kind.

  • passed_filter – Category regex for passed remarks.

  • missed_filter – Category regex for missed remarks.

  • analysis_filter – Category regex for analysis remarks.

  • failed_filter – Category regex for failed remarks.

  • callback – A callable receiving one Remark per reported remark; the remark is only valid during the call.

  • print_as_emit_remarks – Also emit every remark as an MLIR remark diagnostic; defaults to True only without an output file or callback.

Raises:

ValueError – When both an output file and a callback are given, when remarks are already enabled, or when the output file cannot be written.

finalize_remarks() → None

Finalizes and removes the remark engine of this context.

Postponed remarks (policy “final”) are reported, the output file is written and the callback is released. Does nothing when no engine is enabled; enable_remarks may be called again afterwards.

property remarks_enabled: bool

Returns True if a remark engine is enabled on this context.

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.

begin_transient_scope() → None

Begins a transient scope on the context, freezing the base layer.

All subsequently allocated types, attributes, and unregistered operations are treated as transient and will be deallocated with end_transient_scope(). Raises a ValueError if the context is already in a transient scope.

end_transient_scope() → None

Ends the transient scope and resets the context to the base state.

Prunes all transient types, attributes, affine expressions, distinct attributes, and unregistered operations added during the transient scope.

Note: Any Python objects referencing transient IR entities become invalid after this call and must not be accessed.

property is_in_transient_scope: bool

Returns whether the context is currently in a transient scope.

class mlir._mlir_libs._mlir.dialects.transform.AnyOpType

Bases: mlir.ir.Type

static isinstance(type: mlir.ir.Type) → bool
static get(context: mlir.ir.Context | None = None) → AnyOpType
class mlir._mlir_libs._mlir.dialects.transform.OperationType

Bases: mlir.ir.Type

static isinstance(type: mlir.ir.Type) → bool
static get(operation_name: str, context: mlir.ir.Context | None = None) → OperationType
property operation_name: str