mlir.extras.meta¶
Classes¶
Functions¶
|
|
|
Decorator to define an MLIR Op specified as a python function. |
Module Contents¶
- mlir.extras.meta.get_op_result_or_op_results(op: mlir._mlir_libs._mlir.ir.OpView | mlir._mlir_libs._mlir.ir.Operation) mlir._mlir_libs._mlir.ir.Operation | mlir._mlir_libs._mlir.ir.OpResult | Sequence[mlir._mlir_libs._mlir.ir.OpResult]¶
- class mlir.extras.meta.Type(cast_from_type: Type)¶
- property _CAPIPtr: object¶
Gets a capsule wrapping the
MlirType.
- static parse(asm: str, context: Context | None = None) Type¶
Parses the assembly form of a type.
Returns a Type object or raises an
MLIRErrorif the type cannot be parsed.
- __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.
- class mlir.extras.meta.InsertionPoint(block: Block)¶
- class mlir.extras.meta.InsertionPoint(beforeOperation: _OperationBase)
- __enter__(/) InsertionPoint¶
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.
- mlir.extras.meta.op_region_builder(op, op_region, terminator=None)¶
- mlir.extras.meta.region_op(op_constructor, terminator=None)¶
Decorator to define an MLIR Op specified as a python function.
Requires that an
mlir.ir.InsertionPointandmlir.ir.Locationare active for the current thread (i.e. established in awithblock).Supports “naked” usage i.e., no parens if no args need to be passed to the Op constructor.
When applied as a decorator to a Python function, an entry block will be constructed for the Op with types as specified as type hints on the args of the function. The block arguments will be passed positionally to the Python function.
If a terminator is specified then the return from the decorated function will be passed to the terminator as the last statement in the entry block. Note, the API for the terminator is a (possibly empty) list; terminator accepting single values should be wrapped in a
lambda args: term(args[0])The identifier (name) of the function will become:
A single value result if the Op returns a single value;
An OpResultList (as a list) if the Op returns multiple values;
The Operation if the Op returns no results.
See examples in tensor.py and transform.extras.