mlir.dialects.func

Attributes

Classes

ConstantOp

Specialization for the constant op class.

FuncOp

Specialization for the func op class.

CallOp

Specialization for the call op class.

Module Contents

mlir.dialects.func.ARGUMENT_ATTRIBUTE_NAME = 'arg_attrs'
mlir.dialects.func.RESULT_ATTRIBUTE_NAME = 'res_attrs'
class mlir.dialects.func.ConstantOp(result, value, *, loc=None, ip=None)

Bases: ConstantOp

Specialization for the constant op class.

property type
class mlir.dialects.func.FuncOp(name, type, *, visibility=None, body_builder=None, loc=None, ip=None)

Bases: FuncOp

Specialization for the func op class.

property is_external
property body
property type
property visibility
property name: StringAttr

Returns the fully qualified name of the operation.

property entry_block
add_entry_block(arg_locs: Sequence[Location] | None = None)

Add an entry block to the function body using the function signature to infer block arguments. Returns the newly created block

property arg_attrs
property arguments
property result_attrs
classmethod from_py_func(*inputs: Type, results: Sequence[Type] | None = None, name: str | None = None)

Decorator to define an MLIR FuncOp specified as a python function.

Requires that an mlir.ir.InsertionPoint and mlir.ir.Location are active for the current thread (i.e. established in a with block).

When applied as a decorator to a Python function, an entry block will be constructed for the FuncOp with types as specified in *inputs. The block arguments will be passed positionally to the Python function. In addition, if the Python function accepts keyword arguments generally or has a corresponding keyword argument, the following will be passed:

  • func_op: The func op being defined.

By default, the function name will be the Python function __name__. This can be overriden by passing the name argument to the decorator.

If results is not specified, then the decorator will implicitly insert a ReturnOp with the Value’s returned from the decorated function. It will also set the FuncOp type with the actual return value types. If results is specified, then the decorated function must return None and no implicit ReturnOp is added (nor are the result types updated). The implicit behavior is intended for simple, single-block cases, and users should specify result types explicitly for any complicated cases.

The decorated function can further be called from Python and will insert a CallOp at the then-current insertion point, returning either None ( if no return values), a unary Value (for one result), or a list of Values). This mechanism cannot be used to emit recursive calls (by construction).

mlir.dialects.func.func
class mlir.dialects.func.CallOp(calleeOrResults: FuncOp | List[Type], argumentsOrCallee: List | FlatSymbolRefAttr | str, arguments: List | None = None, *, loc=None, ip=None)

Bases: CallOp

Specialization for the call op class.