mlir.dialects._irdl_ops_gen¶
Attributes¶
Classes¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The |
|
|
|
|
|
|
|
|
|
|
|
The irdl.region construct defines a set of characteristics |
|
|
|
|
|
|
Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Module Contents¶
- mlir.dialects._irdl_ops_gen._ods_ir¶
- class mlir.dialects._irdl_ops_gen._Dialect(descriptor: object)¶
Bases:
_ods_ir- DIALECT_NAMESPACE = 'irdl'¶
- class mlir.dialects._irdl_ops_gen.AllOfOp(args, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.all_ofdefines a constraint that accepts any type or attribute that satisfies all of its provided constraints.Example:
irdl.dialect @cmath { irdl.type @complex_f32 { %0 = irdl.is i32 %1 = irdl.is f32 %2 = irdl.any_of(%0, %1) // is 32-bit %3 = irdl.is f32 %4 = irdl.is f64 %5 = irdl.any_of(%3, %4) // is a float %6 = irdl.all_of(%2, %5) // is a 32-bit float irdl.parameters(%6) } }
The above program defines a type
complexinside the dialectcmaththat has one parameter that must be 32-bit long and a float (in other words, that must bef32).- OPERATION_NAME = 'irdl.all_of'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.all_of(args, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.AnyOfOp(args, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.any_ofdefines a constraint that accepts any type or attribute that satisfies at least one of its provided type constraints.Example:
irdl.dialect @cmath { irdl.type @complex { %0 = irdl.is i32 %1 = irdl.is i64 %2 = irdl.is f32 %3 = irdl.is f64 %4 = irdl.any_of(%0, %1, %2, %3) irdl.parameters(%4) } }
The above program defines a type
complexinside the dialectcmaththat has a single type parameter that can be eitheri32,i64,f32orf64.- OPERATION_NAME = 'irdl.any_of'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.any_of(args, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.AnyOp(*, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.anydefines a constraint that accepts any type or attribute.Example:
irdl.dialect @cmath { irdl.type @complex_flexible { %0 = irdl.any irdl.parameters(%0) } }
The above program defines a type
complex_flexibleinside the dialectcmaththat has a single parameter that can be any attribute.- OPERATION_NAME = 'irdl.any'¶
- _ODS_REGIONS = (0, True)¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.any(*, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.AttributeOp(sym_name, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.attributedefines a new attribute belonging to theirdl.dialectparent.The attribute parameters can be defined with an
irdl.parametersoperation in the optional region.Example:
irdl.dialect @testd { irdl.attribute @enum_attr { %0 = irdl.is "foo" %1 = irdl.is "bar" %2 = irdl.any_of(%0, %1) irdl.parameters(%2) } }
The above program defines an
enum_attrattribute inside thetestddialect. The attribute has oneStringAttrparameter that should be either a"foo"or a"bar".- OPERATION_NAME = 'irdl.attribute'¶
- _ODS_REGIONS = (1, True)¶
- sym_name() _ods_ir¶
- body() _ods_ir¶
- mlir.dialects._irdl_ops_gen.attribute(sym_name, *, loc=None, ip=None) AttributeOp¶
- class mlir.dialects._irdl_ops_gen.AttributesOp(attributeValues, attributeValueNames, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.attributesdefines the attributes of theirdl.operationparent operation definition.In the following example,
irdl.attributesdefines the attributes of theattr_opoperation:irdl.dialect @example { irdl.operation @attr_op { %0 = irdl.any %1 = irdl.is i64 irdl.attibutes { "attr1" = %0, "attr2" = %1 } } }
The operation will expect an arbitrary attribute “attr1” and an attribute “attr2” with value
i64.- OPERATION_NAME = 'irdl.attributes'¶
- _ODS_REGIONS = (0, True)¶
- attributeValues() _ods_ir¶
- attributeValueNames() _ods_ir¶
- mlir.dialects._irdl_ops_gen.attributes_(attribute_values, attribute_value_names, *, loc=None, ip=None) AttributesOp¶
- class mlir.dialects._irdl_ops_gen.BaseOp(*, base_ref=None, base_name=None, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.basedefines a constraint that only accepts a single type or attribute base, e.g. anIntegerType. The attribute base is defined either by a symbolic reference to the corresponding IRDL definition, or by the name of the base. Named bases are prefixed with!or#respectively for types and attributes.Example:
irdl.dialect @cmath { irdl.type @complex { %0 = irdl.base "!builtin.integer" irdl.parameters(%0) } irdl.type @complex_wrapper { %0 = irdl.base @cmath::@complex irdl.parameters(%0) } }
The above program defines a
cmath.complextype that expects a single parameter, which is a type with base namebuiltin.integer, which is the name of anIntegerTypetype. It also defines acmath.complex_wrappertype that expects a single parameter, which is a type of base typecmath.complex.- OPERATION_NAME = 'irdl.base'¶
- _ODS_REGIONS = (0, True)¶
- base_ref() _ods_ir | None¶
- base_name() _ods_ir | None¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.base(*, base_ref=None, base_name=None, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.CPredOp(pred, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.c_preddefines a constraint that is written in C++.Dialects using this operation cannot be registered at runtime, as it relies on C++ code.
Special placeholders can be used to refer to entities in the context where this predicate is used. They serve as “hooks” to the enclosing environment. The following special placeholders are supported in constraints for an op:
$_builderwill be replaced by a mlir::Builder instance.$_opwill be replaced by the current operation.$_selfwill be replaced with the entity this predicate is attached to.
Compared to ODS,
$_selfis always of typemlir::Attribute, and types are manipulated asTypeAttrattributes.Example:
irdl.type @op_with_attr { %0 = irdl.c_pred "::llvm::isa<::mlir::IntegerAttr>($_self)" irdl.parameters(%0) }
In this example, @op_with_attr is defined as a type with a single parameter, which is an
IntegerAttr, as constrained by the C++ predicate.- OPERATION_NAME = 'irdl.c_pred'¶
- _ODS_REGIONS = (0, True)¶
- pred() _ods_ir¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.c_pred(pred, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.DialectOp(sym_name, *, loc=None, ip=None)¶
Bases:
_ods_irThe
irdl.dialectoperation defines a dialect. All operations, attributes, and types defined inside its region will be part of the dialect.Example:
irdl.dialect @cmath { ... }
The above program defines a
cmathdialect.- OPERATION_NAME = 'irdl.dialect'¶
- _ODS_REGIONS = (1, True)¶
- sym_name() _ods_ir¶
- body() _ods_ir¶
- class mlir.dialects._irdl_ops_gen.IsOp(expected, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.isdefines a constraint that only accepts a specific instance of a type or attribute.Example:
irdl.dialect @cmath { irdl.type @complex_i32 { %0 = irdl.is i32 irdl.parameters(%0) } }
The above program defines a
complex_i32type inside the dialectcmaththat can only have ai32as its parameter.- OPERATION_NAME = 'irdl.is'¶
- _ODS_REGIONS = (0, True)¶
- expected() _ods_ir¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.is_(expected, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.OperandsOp(args, names, variadicity, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.operandsdefine the operands of theirdl.operationparent operation definition. Each operand is named after an identifier.In the following example,
irdl.operandsdefines the operands of themuloperation:irdl.dialect @cmath { irdl.type @complex { /* ... */ } irdl.operation @mul { %0 = irdl.any %1 = irdl.parametric @cmath::@complex<%0> irdl.results(res: %1) irdl.operands(lhs: %1, rhs: %1) } }
The
muloperation will expect two operands of typecmath.complex, that have the same type, and return a result of the same type.The operands can also be marked as variadic or optional:
irdl.operands(foo: %0, bar: single %1, baz: optional %2, qux: variadic %3)
Here, foo and bar are required single operands, baz is an optional operand, and qux is a variadic operand.
When more than one operand is marked as optional or variadic, the operation will expect a ‘operandSegmentSizes’ attribute that defines the number of operands in each segment.
- OPERATION_NAME = 'irdl.operands'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- names() _ods_ir¶
- variadicity() _ods_ir¶
- mlir.dialects._irdl_ops_gen.operands_(args, names, variadicity, *, loc=None, ip=None) OperandsOp¶
- class mlir.dialects._irdl_ops_gen.OperationOp(sym_name, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.operationdefines a new operation belonging to theirdl.dialectparent.Operations can define constraints on their operands and results with the
irdl.resultsandirdl.operandsoperations. If these operations are not present in the region, the results or operands are expected to be empty.Example:
irdl.dialect @cmath { irdl.type @complex { /* ... */ } irdl.operation @norm { %0 = irdl.any %1 = irdl.parametric @cmath::@complex<%0> irdl.results(%0) irdl.operands(%1) } }
The above program defines an operation
norminside the dialectcmath. The operation expects a single operand of base typecmath.complex, and returns a single result of the element type of the operand.- OPERATION_NAME = 'irdl.operation'¶
- _ODS_REGIONS = (1, True)¶
- sym_name() _ods_ir¶
- body() _ods_ir¶
- mlir.dialects._irdl_ops_gen.operation_(sym_name, *, loc=None, ip=None) OperationOp¶
- class mlir.dialects._irdl_ops_gen.ParametersOp(args, names, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.parametersdefines the constraints on parameters of a type or attribute definition. Each parameter is named after an identifier.Example:
irdl.dialect @cmath { irdl.type @complex { %0 = irdl.is i32 %1 = irdl.is i64 %2 = irdl.any_of(%0, %1) irdl.parameters(elem: %2) } }
The above program defines a type
complexinside the dialectcmath. The type has a single parameterelemthat should be eitheri32ori64.- OPERATION_NAME = 'irdl.parameters'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- names() _ods_ir¶
- mlir.dialects._irdl_ops_gen.parameters(args, names, *, loc=None, ip=None) ParametersOp¶
- class mlir.dialects._irdl_ops_gen.ParametricOp(base_type, args, *, results=None, loc=None, ip=None)¶
Bases:
_ods_irirdl.parametricdefines a constraint that accepts only a single type or attribute base. The attribute base is defined by a symbolic reference to the corresponding definition. It will additionally constraint the parameters of the type/attribute.Example:
irdl.dialect @cmath { irdl.type @complex { /* ... */ } irdl.operation @norm { %0 = irdl.any %1 = irdl.parametric @cmath::@complex<%0> irdl.operands(%1) irdl.results(%0) } }
The above program defines an operation
norminside the dialectcmaththat for anyTtakes acmath.complexwith parameterTand returns aT.- OPERATION_NAME = 'irdl.parametric'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- base_type() _ods_ir¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.parametric(base_type, args, *, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.RegionOp(entryBlockArgs, *, numberOfBlocks=None, constrainedArguments=None, results=None, loc=None, ip=None)¶
Bases:
_ods_irThe irdl.region construct defines a set of characteristics that a region of an operation should satify. Each region is named after an identifier.
These characteristics include constraints for the entry block arguments of the region and the total number of blocks it contains. The number of blocks must be a non-zero and non-negative integer, and it is optional by default. The set of constraints for the entry block arguments may be optional or empty. If no parentheses are provided, the set is assumed to be optional, and the arguments are not constrained in any way. If parentheses are provided with no arguments, it means that the region must have no entry block arguments
Example:
irdl.dialect @example { irdl.operation @op_with_regions { %r0 = irdl.region %r1 = irdl.region() %v0 = irdl.is i32 %v1 = irdl.is i64 %r2 = irdl.region(%v0, %v1) %r3 = irdl.region with size 3 irdl.regions(foo: %r0, bar: %r1, baz: %r2, qux: %r3) } }
The above snippet demonstrates an operation named
@op_with_regions, which is constrained to have four regions.Region
foodoesn’t have any constraints on the arguments
or the number of blocks. * Region
barshould have an empty set of arguments. * Regionbazshould have two arguments of typesi32andi64. * Regionquxshould contain exactly three blocks.- OPERATION_NAME = 'irdl.region'¶
- _ODS_REGIONS = (0, True)¶
- entryBlockArgs() _ods_ir¶
- numberOfBlocks() _ods_ir | None¶
- constrainedArguments() bool¶
- output() _ods_ir¶
- mlir.dialects._irdl_ops_gen.region(entry_block_args, *, number_of_blocks=None, constrained_arguments=None, results=None, loc=None, ip=None) _ods_ir¶
- class mlir.dialects._irdl_ops_gen.RegionsOp(args, names, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.regionsdefines the regions of an operation by accepting values produced byirdl.regionoperation as arguments. Each region has an identifier as name.Example:
irdl.dialect @example { irdl.operation @op_with_regions { %r1 = irdl.region with size 3 %0 = irdl.any %r2 = irdl.region(%0) irdl.regions(foo: %r1, bar: %r2) } }
In the snippet above the operation is constrained to have two regions. The first region (
foo) should contain three blocks. The second region (bar) should have one region with one argument.- OPERATION_NAME = 'irdl.regions'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- names() _ods_ir¶
- class mlir.dialects._irdl_ops_gen.ResultsOp(args, names, variadicity, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.resultsdefine the results of theirdl.operationparent operation definition. Each result is named after an identifier.In the following example,
irdl.resultsdefines the results of theget_valuesoperation:irdl.dialect @cmath { irdl.type @complex { /* ... */ } /// Returns the real and imaginary parts of a complex number. irdl.operation @get_values { %0 = irdl.any %1 = irdl.parametric @cmath::@complex<%0> irdl.results(re: %0, im: %0) irdl.operands(complex: %1) } }
The operation will expect one operand of the
cmath.complextype, and two results that have the underlying type of thecmath.complex.The results can also be marked as variadic or optional:
irdl.results(foo: %0, bar: single %1, baz: optional %2, qux: variadic %3)
Here, foo and bar are required single results, baz is an optional result, and qux is a variadic result.
When more than one result is marked as optional or variadic, the operation will expect a ‘resultSegmentSizes’ attribute that defines the number of results in each segment.
- OPERATION_NAME = 'irdl.results'¶
- _ODS_REGIONS = (0, True)¶
- args() _ods_ir¶
- names() _ods_ir¶
- variadicity() _ods_ir¶
- class mlir.dialects._irdl_ops_gen.TypeOp(sym_name, *, loc=None, ip=None)¶
Bases:
_ods_irirdl.typedefines a new type belonging to theirdl.dialectparent.The type parameters can be defined with an
irdl.parametersoperation in the optional region.Example:
irdl.dialect @cmath { irdl.type @complex { %0 = irdl.is i32 %1 = irdl.is i64 %2 = irdl.any_of(%0, %1) irdl.parameters(%2) } }
The above program defines a type
complexinside the dialectcmath. The type has a single parameter that should be eitheri32ori64.- OPERATION_NAME = 'irdl.type'¶
- _ODS_REGIONS = (1, True)¶
- sym_name() _ods_ir¶
- body() _ods_ir¶