mlir.dialects.transform.tune¶
Classes¶
Abstract base class for generic types. |
|
This op represents a choice over which of its regions is to be used. |
|
Provides a representation for "tunables" within schedules. |
|
Provides a representation for "tunables" within schedules. |
|
This op represents a choice over which of its regions is to be used. |
Functions¶
|
|
|
|
|
|
|
Module Contents¶
- class mlir.dialects.transform.tune.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.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.
- dump() None¶
Dumps a debug representation of the object to stderr.
- property owner: OpView | Block¶
Returns the owner of the value (
Operationfor results,Blockfor 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
selfto 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
Valueto a more specific kind if possible.
- 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 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 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- __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
MLIRErroron failure.
- 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.
- class mlir.dialects.transform.tune.ArrayAttr(cast_from_attr: Attribute)¶
Bases:
Attribute- static_typeid: _mlir.ir.TypeID = Ellipsis¶
(arg: object, /) -> _mlir.ir.TypeID
- __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
- __len__() int¶
- __iter__() ArrayAttributeIterator¶
- class mlir.dialects.transform.tune.StringAttr(cast_from_attr: Attribute)¶
Bases:
Attribute- static_typeid: _mlir.ir.TypeID = Ellipsis¶
(arg: object, /) -> _mlir.ir.TypeID
- __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
TypeIDof theType, or raisesValueErrorifTypehas noTypeID.
- __repr__() str¶
Returns a string representation of the
Type.
- type_name: str = Ellipsis¶
(arg: object, /) -> str
- 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
TypeIDof theType, or raisesValueErrorifTypehas noTypeID.
- __repr__() str¶
Returns a string representation of the
Type.
- type_name: str = Ellipsis¶
(arg: object, /) -> str
- class Signedness¶
Bases:
enum.EnumGeneric 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- static_typeid: _mlir.ir.TypeID = Ellipsis¶
(arg: object, /) -> _mlir.ir.TypeID
- __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- static_typeid: _mlir.ir.TypeID = Ellipsis¶
(arg: object, /) -> _mlir.ir.TypeID
- __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- static_typeid: _mlir.ir.TypeID = Ellipsis¶
(arg: object, /) -> _mlir.ir.TypeID
- __repr__() str¶
Returns a string representation of the 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_irThis op represents a choice over which of its regions is to be used.
When
selected_regionis 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 providedselected_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_regionargument is either anIntegerAttror a param holding anIntegerAttr, 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_irProvides a representation for “tunables” within schedules.
Each op represents a single tunable, which has a
nameand a set of validoptionsdescribed by an attribute. Without a specifiedselectedoption, 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
selectedattribute. When provided, the interpreter runtime semantics are to return theselectedattribute as a param through the op’s result.In case the
optionsattribute is anArrayAttr, the verifier checks that the providedselectedattribute occurs inoptions.- 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:
KnobOpProvides a representation for “tunables” within schedules.
Each op represents a single tunable, which has a
nameand a set of validoptionsdescribed by an attribute. Without a specifiedselectedoption, 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
selectedattribute. When provided, the interpreter runtime semantics are to return theselectedattribute as a param through the op’s result.In case the
optionsattribute is anArrayAttr, the verifier checks that the providedselectedattribute occurs inoptions.
- 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:
AlternativesOpThis op represents a choice over which of its regions is to be used.
When
selected_regionis 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 providedselected_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_regionargument is either anIntegerAttror a param holding anIntegerAttr, 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)¶