mlir.dialects.builtin¶
Classes¶
Specialization for the module op class. |
|
An |
|
Specialization for the module op class. |
Functions¶
|
|
|
|
|
Decorator to define an MLIR Op specified as a python function. |
|
Module Contents¶
- class mlir.dialects.builtin.ModuleOp(*, sym_name=None, sym_visibility=None, loc=None, ip=None)¶
Bases:
_ods_irA
modulerepresents a top-level container operation. It contains a single graph region containing a single block which can contain any operations and does not have a terminator. Operations within this region cannot implicitly capture values defined outside the module, i.e. Modules are IsolatedFromAbove. Modules have an optional symbol name which can be used to refer to them in operations.Example:
module { func.func @foo() }
- OPERATION_NAME = 'builtin.module'¶
- _ODS_REGIONS = (1, True)¶
- sym_name() _ods_ir | None¶
- sym_visibility() _ods_ir | None¶
- bodyRegion() _ods_ir¶
- class mlir.dialects.builtin.UnrealizedConversionCastOp(outputs, inputs, *, loc=None, ip=None)¶
Bases:
_ods_irAn
unrealized_conversion_castoperation represents an unrealized conversion from one set of types to another, that is used to enable the inter-mixing of different type systems. This operation should not be attributed any special representational or execution semantics, and is generally only intended to be used to satisfy the temporary intermixing of type systems during the conversion of one type system to another.This operation may produce results of arity 1-N, and accept as input operands of arity 0-N.
Example:
// An unrealized 0-1 conversion. These types of conversions are useful in // cases where a type is removed from the type system, but not all uses have // been converted. For example, imagine we have a tuple type that is // expanded to its element types. If only some uses of an empty tuple type // instance are converted we still need an instance of the tuple type, but // have no inputs to the unrealized conversion. %result = unrealized_conversion_cast to !bar.tuple_type<> // An unrealized 1-1 conversion. %result1 = unrealized_conversion_cast %operand : !foo.type to !bar.lowered_type // An unrealized 1-N conversion. %results2:2 = unrealized_conversion_cast %tuple_operand : !foo.tuple_type<!foo.type, !foo.type> to !foo.type, !foo.type // An unrealized N-1 conversion. %result3 = unrealized_conversion_cast %operand, %operand : !foo.type, !foo.type to !bar.tuple_type<!foo.type, !foo.type>
- OPERATION_NAME = 'builtin.unrealized_conversion_cast'¶
- _ODS_REGIONS = (0, True)¶
- inputs() _ods_ir¶
- outputs() _ods_ir¶
- mlir.dialects.builtin.unrealized_conversion_cast(outputs, inputs, *, loc=None, ip=None) _ods_ir | _ods_ir | UnrealizedConversionCastOp¶
- mlir.dialects.builtin.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.