mlir.extras.meta¶
Functions¶
|
|
|
Decorator to define an MLIR Op specified as a python function. |
Module Contents¶
- 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.