mlir.dialects.transform.tune

Classes

Type

Value

Abstract base class for generic types.

Operation

OpView

Attribute

ArrayAttr

StringAttr

F64Type

IntegerType

IntegerAttr

FloatAttr

BoolAttr

AlternativesOp

This op represents a choice over which of its regions is to be used.

AlternativesOpAdaptor

KnobOp

Provides a representation for "tunables" within schedules.

KnobOpAdaptor

KnobOp

Provides a representation for "tunables" within schedules.

AlternativesOp

This op represents a choice over which of its regions is to be used.

Functions

tune_alternatives(→ Union[_ods_ir, _ods_ir, ...)

tune_knob(→ _ods_ir)

knob(result, name, options, *[, selected, loc, ip])

alternatives(results, name, num_alternatives, *[, ...])

Module Contents

class mlir.dialects.transform.tune.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.dialects.transform.tune.Value(value: Value)

Bases: Generic[_T]

Abstract base class for generic types.

A generic type is typically declared by inheriting from this class parameterized with one or more type variables. For example, a generic mapping type might be defined as:

class Mapping(Generic[KT, VT]): def **getitem**(self, key: KT) -> VT: … # Etc.

This class can then be used as follows:

def lookup_name(mapping: Mapping[KT, VT], key: KT, default: VT) -> VT: try: return mapping[key] except KeyError: return default

property _CAPIPtr: object

Gets a capsule wrapping the MlirValue.

static _CAPICreate(arg: object, /) Value

Creates a Value from a capsule wrapping MlirValue.

property context: Context

Context in which the value lives.

dump() None

Dumps a debug representation of the object to stderr.

property owner: OpView | Block

Returns the owner of the value (Operation for results, Block for arguments).

property uses: OpOperandIterator

Returns an iterator over uses of this value.

__eq__(arg: Value, /) bool
__eq__(arg: object, /) bool

Compares value with non-value object (always returns False).

__hash__() int

Returns the hash value of the value.

__str__() str

Returns the string form of the value.

If the value is a block argument, this is the assembly form of its type and the position in the argument list. If the value is an operation result, this is equivalent to printing the operation that produced it.

get_name(use_local_scope: bool = False, use_name_loc_as_prefix: bool = False) str
get_name(state: AsmState) str

Returns the string form of value as an operand (i.e., the ValueID).

property type: _T

Returns the type of the value.

set_type(type: _T)

Sets the type of the value.

replace_all_uses_with(arg: Value, /) None

Replace all uses of value with the new value, updating anything in the IR that uses self to use the other value instead.

replace_all_uses_except(with_: Value, exceptions: Operation) None
replace_all_uses_except(with_: Value, exceptions: collections.abc.Sequence[Operation]) None
maybe_downcast() BlockArgument | OpResult | Value

Downcasts the Value to a more specific kind if possible.

property location: Location

Returns the source location of the value.

class mlir.dialects.transform.tune.Operation

Bases: _OperationBase

static create(name: str, results: collections.abc.Sequence[Type] | None = None, operands: collections.abc.Sequence[Value] | None = None, attributes: dict[str, Attribute] | None = None, successors: collections.abc.Sequence[Block] | None = None, regions: int = 0, loc: Location | None = None, ip: object | None = None, infer_type: bool = False) Operation

Creates a new operation.

Parameters:
  • name – Operation name (e.g. dialect.operation).

  • results – Optional sequence of Type representing op result types.

  • operands – Optional operands of the operation.

  • attributes – Optional Dict of {str: Attribute}.

  • successors – Optional List of Block for the operation’s successors.

  • regions – Number of regions to create (default = 0).

  • location – Optional Location object (defaults to resolve from context manager).

  • ip – Optional InsertionPoint (defaults to resolve from context manager or set to False to disable insertion, even with an insertion point set in the context manager).

  • infer_type – Whether to infer result types (default = False).

Returns:

A new detached Operation object. Detached operations can be added to blocks, which causes them to become attached.

static parse(source: str, *, source_name: str = '', context: Context | None = None) OpView

Parses an operation. Supports both text assembly format and binary bytecode format.

property _CAPIPtr: object

Gets a capsule wrapping the MlirOperation.

static _CAPICreate(arg: object, /) object

Creates an Operation from a capsule wrapping MlirOperation.

property operation: Operation

Returns self (the operation).

property opview: OpView

Returns an OpView of this operation.

Note: If the operation has a registered and loaded dialect then this OpView will be concrete wrapper class.

property block: Block

Returns the block containing this operation.

property successors: OpSuccessors

Returns the list of Operation successors.

replace_uses_of_with(of: Value, with_: Value) None

Replaces uses of the ‘of’ value with the ‘with’ value inside the operation.

_set_invalid() None

Invalidate the operation.

class mlir.dialects.transform.tune.OpView(operation: Operation)
class mlir.dialects.transform.tune.OpView(name: str, opRegionSpec: tuple[int, bool], operandSegmentSpecObj: object | None = None, resultSegmentSpecObj: object | None = None, results: collections.abc.Sequence | None = None, operands: collections.abc.Sequence | None = None, attributes: dict[str, Attribute] | None = None, successors: collections.abc.Sequence[Block] | None = None, regions: int | None = None, loc: Location | None = None, ip: object | None = None)

Bases: _OperationBase

property operation: Operation
property opview: OpView
__str__() str

Returns the assembly form of the operation.

property successors: OpSuccessors

Returns the list of Operation successors.

_set_invalid() None

Invalidate the operation.

_ODS_REGIONS: tuple = (0, True)
_ODS_OPERAND_SEGMENTS: None = None
_ODS_RESULT_SEGMENTS: None = None
classmethod build_generic(**kwargs) Any

build_generic(cls, results: Sequence[Type] | None = None, operands: Sequence[Value] | None = None, attributes: dict[str, Attribute] | None = None, successors: Sequence[Block] | None = None, regions: int | None = None, loc: Location | None = None, ip: InsertionPoint | None = None) -> typing.Self

Builds a specific, generated OpView based on class level attributes.

classmethod parse(**kwargs) Any

parse(cls, source: str, *, source_name: str = ‘’, context: Context | None = None) -> typing.Self

Parses a specific, generated OpView based on class level attributes.

classmethod has_trait(**kwargs) Any

(cls: object, trait_cls: type, context: _mlir.ir.Context | None = None) -> bool

Checks if the operation has a given trait.

class mlir.dialects.transform.tune.Attribute(cast_from_type: Attribute)
property _CAPIPtr: object

Gets a capsule wrapping the MlirAttribute.

static _CAPICreate(arg: object, /) Attribute

Creates an Attribute from a capsule wrapping MlirAttribute.

static parse(asm: str, context: Context | None = None) Attribute

Parses an attribute from an assembly form. Raises an MLIRError on failure.

property context: Context

Context that owns the Attribute.

property type: Type

Returns the type of the Attribute.

get_named(arg: str, /) NamedAttribute

Binds a name to the attribute, creating a NamedAttribute.

Parameters:

name – The name to bind to the Attribute.

Returns:

A NamedAttribute with the given name and this attribute.

__eq__(arg: Attribute, /) bool
__eq__(arg: object, /) bool

Compares attribute with non-attribute object (always returns False).

__hash__() int

Returns the hash value of the attribute.

dump() None

Dumps a debug representation of the object to stderr.

__str__() str

Returns the assembly form of the Attribute.

__repr__() str

Returns a string representation of the attribute.

property typeid: TypeID

Returns the TypeID of the attribute.

maybe_downcast() Attribute

Downcasts the attribute to a more specific attribute if possible.

class mlir.dialects.transform.tune.ArrayAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

attr_name: str = Ellipsis

(arg: object, /) -> str

static get(attributes: collections.abc.Sequence[Attribute], context: Context | None = None) ArrayAttr

Gets a uniqued Array attribute

__getitem__(arg: int, /) Attribute
__len__() int
__iter__() ArrayAttributeIterator
__add__(arg: collections.abc.Sequence[Attribute], /) ArrayAttr
class mlir.dialects.transform.tune.StringAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

attr_name: str = Ellipsis

(arg: object, /) -> str

static get(value: str, context: Context | None = None) StringAttr
static get(value: bytes, context: Context | None = None) StringAttr
static get_typed(type: Type, value: str) StringAttr

Gets a uniqued string attribute associated to a type

property value: str

Returns the value of the string attribute

property value_bytes: bytes

Returns the value of the string attribute as bytes

class mlir.dialects.transform.tune.F64Type(cast_from_type: Type)

Bases: FloatType

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

static get(context: Context | None = None) F64Type

Create a f64 type.

class mlir.dialects.transform.tune.IntegerType(cast_from_type: Type)

Bases: Type

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the Type, or raises ValueError if Type has no TypeID.

__repr__() str

Returns a string representation of the Type.

type_name: str = Ellipsis

(arg: object, /) -> str

class Signedness

Bases: enum.Enum

Generic enumeration.

Derive from this class to define new enumerations.

SIGNLESS = 0
SIGNED = 1
UNSIGNED = 2
SIGNLESS: IntegerType
SIGNED: IntegerType
UNSIGNED: IntegerType
static get_signless(width: int, context: Context | None = None) IntegerType

Create a signless integer type

static get_signed(width: int, context: Context | None = None) IntegerType

Create a signed integer type

static get_unsigned(width: int, context: Context | None = None) IntegerType

Create an unsigned integer type

static get(width: int, signedness: IntegerType = IntegerType.Signedness.SIGNLESS, context: Context | None = None) IntegerType

Create an integer type

property signedness: IntegerType
property width: int

Returns the width of the integer type

property is_signless: bool

Returns whether this is a signless integer

property is_signed: bool

Returns whether this is a signed integer

property is_unsigned: bool

Returns whether this is an unsigned integer

class mlir.dialects.transform.tune.IntegerAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

attr_name: str = Ellipsis

(arg: object, /) -> str

static get(type: Type, value: object) IntegerAttr

Gets an uniqued integer attribute associated to a type

property value: int

Returns the value of the integer attribute

__int__() int

Converts the value of the integer attribute to a Python int

__index__() int

Converts the value of the integer attribute to a Python int

class mlir.dialects.transform.tune.FloatAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

attr_name: str = Ellipsis

(arg: object, /) -> str

static get(type: Type, value: float, loc: Location | None = None) FloatAttr

Gets an uniqued float point attribute associated to a type

static get_unchecked(type: Type, value: float, context: Context | None = None) FloatAttr

Gets an uniqued float point attribute associated to a type

static get_f32(value: float, context: Context | None = None) FloatAttr

Gets an uniqued float point attribute associated to a f32 type

static get_f64(value: float, context: Context | None = None) FloatAttr

Gets an uniqued float point attribute associated to a f64 type

property value: float

Returns the value of the float attribute

__float__() float

Converts the value of the float attribute to a Python float

class mlir.dialects.transform.tune.BoolAttr(cast_from_attr: Attribute)

Bases: Attribute

property type: Type

Returns the type of the Attribute.

static_typeid: _mlir.ir.TypeID = Ellipsis

(arg: object, /) -> _mlir.ir.TypeID

property typeid: TypeID

Returns the TypeID of the attribute.

__repr__() str

Returns a string representation of the attribute.

static get(value: bool, context: Context | None = None) BoolAttr

Gets an uniqued bool attribute

property value: bool

Returns the value of the bool attribute

__bool__() bool

Converts the value of the bool attribute to a Python bool

class mlir.dialects.transform.tune.AlternativesOp(results_: Sequence[_ods_ir], name: Any | _ods_ir, num_alternatives: int, *, selected_region_attr: Any | _ods_ir | None = None, selected_region_param: _ods_ir | None = None, loc: _ods_ir | None = None, ip: _ods_ir | None = None)

Bases: _ods_ir

This op represents a choice over which of its regions is to be used.

When selected_region is provided, the semantics are that this op is to be substituted for by the selected region, meaning the region’s results become the results of this op. Without a provided selected_region, the semantics are that this non-deterministic choice is yet to be resolved – which in terms of the op’s interpreted semantics is a failure.

The selected_region argument is either an IntegerAttr or a param holding an IntegerAttr, which should provide a valid zero-based index with respect to the number of alternatives, i.e. regions.

OPERATION_NAME = 'transform.tune.alternatives'
_ODS_REGIONS = (0, False)
selected_region_param() _ods_ir | None
name() _ods_ir

Returns the fully qualified name of the operation.

selected_region_attr() _ods_ir | None
results_() _ods_ir
alternatives() _ods_ir
class mlir.dialects.transform.tune.AlternativesOpAdaptor(operands: list[Value], attributes: OpAttributeMap)
class mlir.dialects.transform.tune.AlternativesOpAdaptor(operands: list[Value], opview: OpView)

Bases: _ods_ir

OPERATION_NAME = 'transform.tune.alternatives'
selected_region_param() _ods_ir | None
name() _ods_ir
selected_region_attr() _ods_ir | None
mlir.dialects.transform.tune.tune_alternatives(results_: Sequence[_ods_ir], name: Any | _ods_ir, num_alternatives: int, *, selected_region_attr: Any | _ods_ir | None = None, selected_region_param: _ods_ir | None = None, loc: _ods_ir | None = None, ip: _ods_ir | None = None) _ods_ir | _ods_ir | AlternativesOp
class mlir.dialects.transform.tune.KnobOp(result: _ods_ir, name: Any | _ods_ir, options: Any | _ods_ir, *, selected: Any | _ods_ir | None = None, loc: _ods_ir | None = None, ip: _ods_ir | None = None)

Bases: _ods_ir

Provides a representation for “tunables” within schedules.

Each op represents a single tunable, which has a name and a set of valid options described by an attribute. Without a specified selected option, this op represents a non-deterministic choice that has yet to be resolved – as such, the interpreter runtime semantics is to raise a failure.

The non-deterministic choice is resolved through providing a selected attribute. When provided, the interpreter runtime semantics are to return the selected attribute as a param through the op’s result.

In case the options attribute is an ArrayAttr, the verifier checks that the provided selected attribute occurs in options.

OPERATION_NAME = 'transform.tune.knob'
_ODS_REGIONS = (0, True)
name() _ods_ir

Returns the fully qualified name of the operation.

options() _ods_ir
selected() _ods_ir | None
result() _ods_ir

Shortcut to get an op result if it has only one (throws an error otherwise).

class mlir.dialects.transform.tune.KnobOpAdaptor(operands: list[Value], attributes: OpAttributeMap)
class mlir.dialects.transform.tune.KnobOpAdaptor(operands: list[Value], opview: OpView)

Bases: _ods_ir

OPERATION_NAME = 'transform.tune.knob'
name() _ods_ir
options() _ods_ir
selected() _ods_ir | None
mlir.dialects.transform.tune.tune_knob(result: _ods_ir, name: Any | _ods_ir, options: Any | _ods_ir, *, selected: Any | _ods_ir | None = None, loc: _ods_ir | None = None, ip: _ods_ir | None = None) _ods_ir
class mlir.dialects.transform.tune.KnobOp(result: mlir.ir.Type, name: mlir.ir.StringAttr | str, options: mlir.ir.ArrayAttr | Sequence[mlir.ir.Attribute | bool | int | float | str] | mlir.ir.Attribute, *, selected: mlir.ir.Attribute | bool | int | float | str | None = None, loc=None, ip=None)

Bases: KnobOp

Provides a representation for “tunables” within schedules.

Each op represents a single tunable, which has a name and a set of valid options described by an attribute. Without a specified selected option, this op represents a non-deterministic choice that has yet to be resolved – as such, the interpreter runtime semantics is to raise a failure.

The non-deterministic choice is resolved through providing a selected attribute. When provided, the interpreter runtime semantics are to return the selected attribute as a param through the op’s result.

In case the options attribute is an ArrayAttr, the verifier checks that the provided selected attribute occurs in options.

mlir.dialects.transform.tune.knob(result: mlir.ir.Type, name: mlir.ir.StringAttr | str, options: mlir.ir.ArrayAttr | Sequence[mlir.ir.Attribute | bool | int | float | str] | mlir.ir.Attribute, *, selected: mlir.ir.Attribute | bool | int | float | str | None = None, loc=None, ip=None)
class mlir.dialects.transform.tune.AlternativesOp(results: Sequence[mlir.ir.Type], name: mlir.ir.StringAttr | str, num_alternatives: int, *, selected_region: int | mlir.ir.IntegerAttr | mlir.ir.Value | mlir.ir.Operation | mlir.ir.OpView | None = None, loc=None, ip=None)

Bases: AlternativesOp

This op represents a choice over which of its regions is to be used.

When selected_region is provided, the semantics are that this op is to be substituted for by the selected region, meaning the region’s results become the results of this op. Without a provided selected_region, the semantics are that this non-deterministic choice is yet to be resolved – which in terms of the op’s interpreted semantics is a failure.

The selected_region argument is either an IntegerAttr or a param holding an IntegerAttr, which should provide a valid zero-based index with respect to the number of alternatives, i.e. regions.

mlir.dialects.transform.tune.alternatives(results: Sequence[mlir.ir.Type], name: mlir.ir.StringAttr | str, num_alternatives: int, *, selected_region: int | mlir.ir.IntegerAttr | mlir.ir.Value | mlir.ir.Operation | mlir.ir.OpView | None = None, loc=None, ip=None)