Skip to content

Transform

transform

MATCH_INTERFACES = tuple(MatchInterfaceEnum) module-attribute

Transform = Dialect('transform', [ApplyRegisteredPassOp, GetConsumersOfResultOp, GetDefiningOp, GetParentOp, GetProducerOfOperandOp, GetResultOp, GetTypeOp, IncludeOp, MatchOperationEmptyOp, MatchOperationNameOp, MatchParamCmpIOp, MergeHandlesOp, ParamConstantOp, SplitHandleOp, SequenceOp, YieldOp, TileOp, TileToForallOp, SelectOp, NamedSequenceOp, CastOp, MatchOp], [AffineMapType, AnyOpType, AnyValueType, AnyParamType, OperationType, ParamType, TypeParamType, FailurePropagationModeAttr]) module-attribute

TransformHandleType dataclass

Bases: ParametrizedAttribute, TypeAttribute, ABC

Source code in xdsl/dialects/transform.py
69
70
class TransformHandleType(ParametrizedAttribute, TypeAttribute, ABC):
    pass

TransformOpHandleType dataclass

Bases: TransformHandleType, ABC

Source code in xdsl/dialects/transform.py
73
74
class TransformOpHandleType(TransformHandleType, ABC):
    pass

TransformValueHandleType dataclass

Bases: TransformHandleType, ABC

Source code in xdsl/dialects/transform.py
77
78
class TransformValueHandleType(TransformHandleType, ABC):
    pass

TransformParamHandleType dataclass

Bases: TransformHandleType, ABC

Source code in xdsl/dialects/transform.py
81
82
class TransformParamHandleType(TransformHandleType, ABC):
    pass

AffineMapType dataclass

Bases: TransformHandleType

See external documentation.

Source code in xdsl/dialects/transform.py
85
86
87
88
89
90
91
@irdl_attr_definition
class AffineMapType(TransformHandleType):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#affinemapparamtype).
    """

    name = "transform.affine_map"

name = 'transform.affine_map' class-attribute instance-attribute

AnyOpType dataclass

Bases: TransformOpHandleType

See external documentation.

Source code in xdsl/dialects/transform.py
 94
 95
 96
 97
 98
 99
100
@irdl_attr_definition
class AnyOpType(TransformOpHandleType):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#anyoptype).
    """

    name = "transform.any_op"

name = 'transform.any_op' class-attribute instance-attribute

AnyValueType dataclass

Bases: TransformValueHandleType

See external documentation.

Source code in xdsl/dialects/transform.py
103
104
105
106
107
108
109
@irdl_attr_definition
class AnyValueType(TransformValueHandleType):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#anyvaluetype).
    """

    name = "transform.any_value"

name = 'transform.any_value' class-attribute instance-attribute

AnyParamType dataclass

Bases: TransformParamHandleType

Source code in xdsl/dialects/transform.py
112
113
114
@irdl_attr_definition
class AnyParamType(TransformParamHandleType):
    name = "transform.any_param"

name = 'transform.any_param' class-attribute instance-attribute

OperationType

Bases: TransformOpHandleType

See external documentation.

Source code in xdsl/dialects/transform.py
117
118
119
120
121
122
123
124
125
126
127
@irdl_attr_definition
class OperationType(TransformOpHandleType):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#operationtype).
    """

    name = "transform.op"
    operation: StringAttr

    def __init__(self, operation: str):
        super().__init__(StringAttr(operation))

name = 'transform.op' class-attribute instance-attribute

operation: StringAttr instance-attribute

__init__(operation: str)

Source code in xdsl/dialects/transform.py
126
127
def __init__(self, operation: str):
    super().__init__(StringAttr(operation))

ParamType dataclass

Bases: TransformParamHandleType

See external documentation.

Source code in xdsl/dialects/transform.py
130
131
132
133
134
135
136
137
@irdl_attr_definition
class ParamType(TransformParamHandleType):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#paramtype).
    """

    name = "transform.param"
    type: TypeAttribute

name = 'transform.param' class-attribute instance-attribute

type: TypeAttribute instance-attribute

TypeParamType dataclass

Bases: TransformParamHandleType

See external documentation.

Source code in xdsl/dialects/transform.py
140
141
142
143
144
145
146
@irdl_attr_definition
class TypeParamType(TransformParamHandleType):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#typeparamtype).
    """

    name = "transform.type"

name = 'transform.type' class-attribute instance-attribute

FailurePropagationModeType

Bases: StrEnum

Source code in xdsl/dialects/transform.py
149
150
151
class FailurePropagationModeType(StrEnum):
    PROPAGATE = "propagate"
    SUPPRESS = "suppress"

PROPAGATE = 'propagate' class-attribute instance-attribute

SUPPRESS = 'suppress' class-attribute instance-attribute

FailurePropagationModeAttr dataclass

Bases: EnumAttribute[FailurePropagationModeType], TypeAttribute

Source code in xdsl/dialects/transform.py
154
155
156
157
158
@irdl_attr_definition
class FailurePropagationModeAttr(
    EnumAttribute[FailurePropagationModeType], TypeAttribute
):
    name = "transform.failures"

name = 'transform.failures' class-attribute instance-attribute

ApplyRegisteredPassOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@irdl_op_definition
class ApplyRegisteredPassOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformapply_registered_pass-transformapplyregisteredpassop).
    """

    name = "transform.apply_registered_pass"

    options = prop_def(DictionaryAttr, default_value=DictionaryAttr({}))
    pass_name = prop_def(StringAttr)
    target = operand_def(TransformHandleType)
    # TODO implement dynamic options and custom directive
    # dynamic_options = var_operand_def(TransformHandleType)
    result = result_def(TransformHandleType)
    assembly_format = "$pass_name (`with` `options` `=` $options^)? `to` $target attr-dict `:` functional-type(operands, results)"

    def __init__(
        self,
        pass_name: str | StringAttr,
        target: SSAValue,
        options: str | StringAttr | None = None,
    ):
        if isinstance(pass_name, str):
            pass_name = StringAttr(pass_name)

        if isinstance(options, str):
            options = StringAttr(options)

        super().__init__(
            properties={
                "pass_name": pass_name,
                "options": options,
            },
            operands=[target],
            result_types=[target.type],
        )

name = 'transform.apply_registered_pass' class-attribute instance-attribute

options = prop_def(DictionaryAttr, default_value=DictionaryAttr({})) class-attribute instance-attribute

pass_name = prop_def(StringAttr) class-attribute instance-attribute

target = operand_def(TransformHandleType) class-attribute instance-attribute

result = result_def(TransformHandleType) class-attribute instance-attribute

assembly_format = '$pass_name (`with` `options` `=` $options^)? `to` $target attr-dict `:` functional-type(operands, results)' class-attribute instance-attribute

__init__(pass_name: str | StringAttr, target: SSAValue, options: str | StringAttr | None = None)

Source code in xdsl/dialects/transform.py
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
def __init__(
    self,
    pass_name: str | StringAttr,
    target: SSAValue,
    options: str | StringAttr | None = None,
):
    if isinstance(pass_name, str):
        pass_name = StringAttr(pass_name)

    if isinstance(options, str):
        options = StringAttr(options)

    super().__init__(
        properties={
            "pass_name": pass_name,
            "options": options,
        },
        operands=[target],
        result_types=[target.type],
    )

GetConsumersOfResultOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
@irdl_op_definition
class GetConsumersOfResultOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformget_consumers_of_result-transformgetconsumersofresult).
    """

    name = "transform.get_consumers_of_result"

    result_number = prop_def(IntegerAttr)
    target = operand_def(TransformOpHandleType)
    consumers = result_def(TransformOpHandleType)

    def __init__(
        self,
        result_number: int,
        target: SSAValue,
    ):
        super().__init__(
            properties={"result_number": IntegerAttr(result_number, IntegerType(64))},
            operands=[target],
            result_types=[AnyOpType()],
        )

name = 'transform.get_consumers_of_result' class-attribute instance-attribute

result_number = prop_def(IntegerAttr) class-attribute instance-attribute

target = operand_def(TransformOpHandleType) class-attribute instance-attribute

consumers = result_def(TransformOpHandleType) class-attribute instance-attribute

__init__(result_number: int, target: SSAValue)

Source code in xdsl/dialects/transform.py
211
212
213
214
215
216
217
218
219
220
def __init__(
    self,
    result_number: int,
    target: SSAValue,
):
    super().__init__(
        properties={"result_number": IntegerAttr(result_number, IntegerType(64))},
        operands=[target],
        result_types=[AnyOpType()],
    )

GetDefiningOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
223
224
225
226
227
228
229
230
231
232
233
234
235
@irdl_op_definition
class GetDefiningOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformget_defining_op-transformgetdefiningop).
    """

    name = "transform.get_defining_op"

    target = operand_def(TransformValueHandleType)
    result = result_def(TransformOpHandleType)

    def __init__(self, target: SSAValue):
        super().__init__(operands=[target], result_types=[AnyOpType()])

name = 'transform.get_defining_op' class-attribute instance-attribute

target = operand_def(TransformValueHandleType) class-attribute instance-attribute

result = result_def(TransformOpHandleType) class-attribute instance-attribute

__init__(target: SSAValue)

Source code in xdsl/dialects/transform.py
234
235
def __init__(self, target: SSAValue):
    super().__init__(operands=[target], result_types=[AnyOpType()])

GetParentOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
@irdl_op_definition
class GetParentOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformget_parent_op-transformgetparentop).
    """

    name = "transform.get_parent_op"

    isolated_from_above = opt_prop_def(UnitAttr)
    allow_empty_results = opt_prop_def(UnitAttr)
    op_name = opt_prop_def(StringAttr)
    deduplicate = opt_prop_def(UnitAttr)
    nth_parent = prop_def(IntegerAttr)
    target = operand_def(TransformOpHandleType)
    parent_result = result_def(TransformOpHandleType)

    def __init__(
        self,
        target: SSAValue,
        isolated_from_above: bool = False,
        allow_empty_results: bool = False,
        op_name: str | None = None,
        deduplicate: bool = False,
        nth_parent: int | IntegerAttr = 1,
    ):
        if isinstance(nth_parent, int):
            nth_parent = IntegerAttr(nth_parent, IntegerType(64))
        super().__init__(
            properties={
                "isolated_from_above": UnitAttr() if isolated_from_above else None,
                "allow_empty_results": UnitAttr() if allow_empty_results else None,
                "op_name": StringAttr(op_name) if op_name else None,
                "deduplicate": UnitAttr() if deduplicate else None,
                "nth_parent": nth_parent,
            },
            operands=[target],
            result_types=[AnyOpType()],
        )

name = 'transform.get_parent_op' class-attribute instance-attribute

isolated_from_above = opt_prop_def(UnitAttr) class-attribute instance-attribute

allow_empty_results = opt_prop_def(UnitAttr) class-attribute instance-attribute

op_name = opt_prop_def(StringAttr) class-attribute instance-attribute

deduplicate = opt_prop_def(UnitAttr) class-attribute instance-attribute

nth_parent = prop_def(IntegerAttr) class-attribute instance-attribute

target = operand_def(TransformOpHandleType) class-attribute instance-attribute

parent_result = result_def(TransformOpHandleType) class-attribute instance-attribute

__init__(target: SSAValue, isolated_from_above: bool = False, allow_empty_results: bool = False, op_name: str | None = None, deduplicate: bool = False, nth_parent: int | IntegerAttr = 1)

Source code in xdsl/dialects/transform.py
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
def __init__(
    self,
    target: SSAValue,
    isolated_from_above: bool = False,
    allow_empty_results: bool = False,
    op_name: str | None = None,
    deduplicate: bool = False,
    nth_parent: int | IntegerAttr = 1,
):
    if isinstance(nth_parent, int):
        nth_parent = IntegerAttr(nth_parent, IntegerType(64))
    super().__init__(
        properties={
            "isolated_from_above": UnitAttr() if isolated_from_above else None,
            "allow_empty_results": UnitAttr() if allow_empty_results else None,
            "op_name": StringAttr(op_name) if op_name else None,
            "deduplicate": UnitAttr() if deduplicate else None,
            "nth_parent": nth_parent,
        },
        operands=[target],
        result_types=[AnyOpType()],
    )

GetProducerOfOperandOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
@irdl_op_definition
class GetProducerOfOperandOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformget_producer_of_operand-transformgetproducerofoperand).
    """

    name = "transform.get_producer_of_operand"

    operand_number = prop_def(IntegerAttr)
    target = operand_def(TransformOpHandleType)
    producer = result_def(TransformOpHandleType)

    def __init__(
        self,
        operand_number: int | IntegerAttr,
        target: SSAValue,
    ):
        if isinstance(operand_number, int):
            operand_number = IntegerAttr(operand_number, IntegerType(64))
        super().__init__(
            properties={"operand_number": operand_number},
            operands=[target],
            result_types=[AnyOpType()],
        )

name = 'transform.get_producer_of_operand' class-attribute instance-attribute

operand_number = prop_def(IntegerAttr) class-attribute instance-attribute

target = operand_def(TransformOpHandleType) class-attribute instance-attribute

producer = result_def(TransformOpHandleType) class-attribute instance-attribute

__init__(operand_number: int | IntegerAttr, target: SSAValue)

Source code in xdsl/dialects/transform.py
290
291
292
293
294
295
296
297
298
299
300
301
def __init__(
    self,
    operand_number: int | IntegerAttr,
    target: SSAValue,
):
    if isinstance(operand_number, int):
        operand_number = IntegerAttr(operand_number, IntegerType(64))
    super().__init__(
        properties={"operand_number": operand_number},
        operands=[target],
        result_types=[AnyOpType()],
    )

GetResultOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
@irdl_op_definition
class GetResultOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformget_result-transformgetresultop).
    """

    name = "transform.get_result"

    raw_position_list = prop_def(DenseArrayBase)
    is_inverted = opt_prop_def(UnitAttr)
    is_all = opt_prop_def(UnitAttr)
    target = operand_def(TransformOpHandleType)
    result = result_def(TransformValueHandleType)

    def __init__(
        self,
        target: SSAValue,
        raw_position_list: (Sequence[int] | DenseArrayBase),
        is_inverted: bool = False,
        is_all: bool = False,
    ):
        if isinstance(raw_position_list, Sequence):
            raw_position_list = DenseArrayBase.from_list(
                IntegerType(64), raw_position_list
            )
        super().__init__(
            properties={
                "raw_position_list": raw_position_list,
                "is_inverted": UnitAttr() if is_inverted else None,
                "is_all": UnitAttr() if is_all else None,
            },
            operands=[target],
            result_types=[AnyValueType()],
        )

name = 'transform.get_result' class-attribute instance-attribute

raw_position_list = prop_def(DenseArrayBase) class-attribute instance-attribute

is_inverted = opt_prop_def(UnitAttr) class-attribute instance-attribute

is_all = opt_prop_def(UnitAttr) class-attribute instance-attribute

target = operand_def(TransformOpHandleType) class-attribute instance-attribute

result = result_def(TransformValueHandleType) class-attribute instance-attribute

__init__(target: SSAValue, raw_position_list: Sequence[int] | DenseArrayBase, is_inverted: bool = False, is_all: bool = False)

Source code in xdsl/dialects/transform.py
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
def __init__(
    self,
    target: SSAValue,
    raw_position_list: (Sequence[int] | DenseArrayBase),
    is_inverted: bool = False,
    is_all: bool = False,
):
    if isinstance(raw_position_list, Sequence):
        raw_position_list = DenseArrayBase.from_list(
            IntegerType(64), raw_position_list
        )
    super().__init__(
        properties={
            "raw_position_list": raw_position_list,
            "is_inverted": UnitAttr() if is_inverted else None,
            "is_all": UnitAttr() if is_all else None,
        },
        operands=[target],
        result_types=[AnyValueType()],
    )

GetTypeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
@irdl_op_definition
class GetTypeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformget_type-transformgettypeop).
    """

    name = "transform.get_type"

    elemental = opt_prop_def(UnitAttr)
    value = operand_def(TransformValueHandleType)
    type_param = result_def(TransformParamHandleType)

    def __init__(self, elemental: bool, value: SSAValue):
        super().__init__(
            properties={"elemental": UnitAttr() if elemental else None},
            operands=[value],
            result_types=[TypeParamType()],
        )

name = 'transform.get_type' class-attribute instance-attribute

elemental = opt_prop_def(UnitAttr) class-attribute instance-attribute

value = operand_def(TransformValueHandleType) class-attribute instance-attribute

type_param = result_def(TransformParamHandleType) class-attribute instance-attribute

__init__(elemental: bool, value: SSAValue)

Source code in xdsl/dialects/transform.py
352
353
354
355
356
357
def __init__(self, elemental: bool, value: SSAValue):
    super().__init__(
        properties={"elemental": UnitAttr() if elemental else None},
        operands=[value],
        result_types=[TypeParamType()],
    )

IncludeOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
@irdl_op_definition
class IncludeOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transforminclude-transformincludeop).
    """

    name = "transform.include"

    target = prop_def(SymbolRefAttr)
    failure_propagation_mode = prop_def()
    operands_input = var_operand_def(TransformHandleType)
    result = var_result_def(TransformHandleType)

    def __init__(
        self,
        target: str,
        failure_propagation_mode: FailurePropagationModeAttr | IntegerAttr | int,
        operands_input: Sequence[SSAValue],
    ):
        if isinstance(failure_propagation_mode, int):
            failure_propagation_mode = IntegerAttr(
                failure_propagation_mode, IntegerType(1)
            )
        super().__init__(
            properties={
                "target": SymbolRefAttr(target),
                "failure_propagation_mode": failure_propagation_mode,
            },
            operands=[operands_input],
            result_types=[[input.type for input in operands_input]],
        )

name = 'transform.include' class-attribute instance-attribute

target = prop_def(SymbolRefAttr) class-attribute instance-attribute

failure_propagation_mode = prop_def() class-attribute instance-attribute

operands_input = var_operand_def(TransformHandleType) class-attribute instance-attribute

result = var_result_def(TransformHandleType) class-attribute instance-attribute

__init__(target: str, failure_propagation_mode: FailurePropagationModeAttr | IntegerAttr | int, operands_input: Sequence[SSAValue])

Source code in xdsl/dialects/transform.py
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
def __init__(
    self,
    target: str,
    failure_propagation_mode: FailurePropagationModeAttr | IntegerAttr | int,
    operands_input: Sequence[SSAValue],
):
    if isinstance(failure_propagation_mode, int):
        failure_propagation_mode = IntegerAttr(
            failure_propagation_mode, IntegerType(1)
        )
    super().__init__(
        properties={
            "target": SymbolRefAttr(target),
            "failure_propagation_mode": failure_propagation_mode,
        },
        operands=[operands_input],
        result_types=[[input.type for input in operands_input]],
    )

MatchOperationEmptyOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
393
394
395
396
397
398
399
400
401
402
403
404
@irdl_op_definition
class MatchOperationEmptyOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformmatchoperation_empty-transformmatchoperationemptyop).
    """

    name = "transform.match.operation_empty"

    operand_handle = operand_def(TransformOpHandleType)

    def __init__(self, operand_handle: SSAValue):
        super().__init__(operands=[operand_handle])

name = 'transform.match.operation_empty' class-attribute instance-attribute

operand_handle = operand_def(TransformOpHandleType) class-attribute instance-attribute

__init__(operand_handle: SSAValue)

Source code in xdsl/dialects/transform.py
403
404
def __init__(self, operand_handle: SSAValue):
    super().__init__(operands=[operand_handle])

MatchOperationNameOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
@irdl_op_definition
class MatchOperationNameOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformmatchoperation_name-transformmatchoperationnameop).
    """

    name = "transform.match.operation_name"

    op_names = prop_def(ArrayAttr[StringAttr])
    operand_handle = operand_def(TransformOpHandleType)

    def __init__(
        self,
        op_names: Sequence[str] | Sequence[StringAttr] | ArrayAttr[StringAttr],
        operand_handle: SSAValue,
    ):
        if isinstance(op_names, Sequence):
            op_names = ArrayAttr(
                [
                    StringAttr(name) if isinstance(name, str) else name
                    for name in op_names
                ]
            )
        super().__init__(
            properties={"op_names": op_names},
            operands=[operand_handle],
        )

name = 'transform.match.operation_name' class-attribute instance-attribute

op_names = prop_def(ArrayAttr[StringAttr]) class-attribute instance-attribute

operand_handle = operand_def(TransformOpHandleType) class-attribute instance-attribute

__init__(op_names: Sequence[str] | Sequence[StringAttr] | ArrayAttr[StringAttr], operand_handle: SSAValue)

Source code in xdsl/dialects/transform.py
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
def __init__(
    self,
    op_names: Sequence[str] | Sequence[StringAttr] | ArrayAttr[StringAttr],
    operand_handle: SSAValue,
):
    if isinstance(op_names, Sequence):
        op_names = ArrayAttr(
            [
                StringAttr(name) if isinstance(name, str) else name
                for name in op_names
            ]
        )
    super().__init__(
        properties={"op_names": op_names},
        operands=[operand_handle],
    )

MatchParamCmpIOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
@irdl_op_definition
class MatchParamCmpIOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformmatchparamcmpi-transformmatchparamcmpiop).
    """

    name = "transform.match.param.cmpi"

    predicate = prop_def(
        IntegerAttr
    )  # Valid values given in xdsl/xdsl/dialects/arith.py
    param = operand_def(TransformParamHandleType)
    reference = operand_def(TransformParamHandleType)

    def __init__(
        self, predicate: int | IntegerAttr, param: SSAValue, reference: SSAValue
    ):
        if isinstance(predicate, int):
            predicate = IntegerAttr(predicate, IntegerType(64))
        super().__init__(
            properties={"predicate": predicate},
            operands=[param, reference],
        )

name = 'transform.match.param.cmpi' class-attribute instance-attribute

predicate = prop_def(IntegerAttr) class-attribute instance-attribute

param = operand_def(TransformParamHandleType) class-attribute instance-attribute

reference = operand_def(TransformParamHandleType) class-attribute instance-attribute

__init__(predicate: int | IntegerAttr, param: SSAValue, reference: SSAValue)

Source code in xdsl/dialects/transform.py
450
451
452
453
454
455
456
457
458
def __init__(
    self, predicate: int | IntegerAttr, param: SSAValue, reference: SSAValue
):
    if isinstance(predicate, int):
        predicate = IntegerAttr(predicate, IntegerType(64))
    super().__init__(
        properties={"predicate": predicate},
        operands=[param, reference],
    )

MergeHandlesOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
@irdl_op_definition
class MergeHandlesOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformmerge_handles-transformmergehandlesop).
    """

    name = "transform.merge_handles"

    deduplicate = opt_prop_def(UnitAttr)
    handles = var_operand_def(TransformHandleType)
    result = result_def(TransformHandleType)

    def __init__(self, handles: Sequence[SSAValue], deduplicate: bool = False):
        super().__init__(
            properties={"deduplicate": UnitAttr() if deduplicate else None},
            operands=[handles],
            result_types=[handles[0].type],
        )

name = 'transform.merge_handles' class-attribute instance-attribute

deduplicate = opt_prop_def(UnitAttr) class-attribute instance-attribute

handles = var_operand_def(TransformHandleType) class-attribute instance-attribute

result = result_def(TransformHandleType) class-attribute instance-attribute

__init__(handles: Sequence[SSAValue], deduplicate: bool = False)

Source code in xdsl/dialects/transform.py
473
474
475
476
477
478
def __init__(self, handles: Sequence[SSAValue], deduplicate: bool = False):
    super().__init__(
        properties={"deduplicate": UnitAttr() if deduplicate else None},
        operands=[handles],
        result_types=[handles[0].type],
    )

ParamConstantOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
@irdl_op_definition
class ParamConstantOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformparamconstant-transformparamconstantop).
    """

    name = "transform.param.constant"

    value = prop_def()
    param = result_def(ParamType)

    def __init__(self, value: Attribute, param_type: TypeAttribute):
        super().__init__(
            properties={"value": value}, result_types=[ParamType(param_type)]
        )

name = 'transform.param.constant' class-attribute instance-attribute

value = prop_def() class-attribute instance-attribute

param = result_def(ParamType) class-attribute instance-attribute

__init__(value: Attribute, param_type: TypeAttribute)

Source code in xdsl/dialects/transform.py
492
493
494
495
def __init__(self, value: Attribute, param_type: TypeAttribute):
    super().__init__(
        properties={"value": value}, result_types=[ParamType(param_type)]
    )

SplitHandleOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
@irdl_op_definition
class SplitHandleOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformsplit_handle-transformsplithandleop).
    """

    name = "transform.split_handle"

    pass_through_empty_handle = prop_def(IntegerAttr)
    fail_on_payload_too_small = prop_def(IntegerAttr)
    overflow_result = opt_prop_def(IntegerAttr)
    handle = operand_def(TransformHandleType)
    results_ = var_result_def(TransformHandleType)

    def __init__(
        self,
        handle: SSAValue,
        number_of_results: int,
        pass_through_empty_handle: int | IntegerAttr | bool = False,
        fail_on_payload_too_small: int | IntegerAttr | bool = False,
        overflow_result: int | IntegerAttr | None = None,
    ):
        if isinstance(pass_through_empty_handle, bool):
            pass_through_empty_handle = IntegerAttr(
                int(pass_through_empty_handle), IntegerType(1)
            )
        if isinstance(fail_on_payload_too_small, bool):
            fail_on_payload_too_small = IntegerAttr(
                int(fail_on_payload_too_small), IntegerType(1)
            )
        if isinstance(pass_through_empty_handle, int):
            pass_through_empty_handle = IntegerAttr(
                pass_through_empty_handle, IntegerType(1)
            )
        if isinstance(fail_on_payload_too_small, int):
            fail_on_payload_too_small = IntegerAttr(
                fail_on_payload_too_small, IntegerType(1)
            )
        if isinstance(overflow_result, int):
            overflow_result = IntegerAttr(overflow_result, IntegerType(64))
        super().__init__(
            properties={
                "pass_through_empty_handle": pass_through_empty_handle,
                "fail_on_payload_too_small": fail_on_payload_too_small,
                "overflow_result": overflow_result,
            },
            operands=[handle],
            result_types=[[handle.type for _ in range(number_of_results)]],
        )

name = 'transform.split_handle' class-attribute instance-attribute

pass_through_empty_handle = prop_def(IntegerAttr) class-attribute instance-attribute

fail_on_payload_too_small = prop_def(IntegerAttr) class-attribute instance-attribute

overflow_result = opt_prop_def(IntegerAttr) class-attribute instance-attribute

handle = operand_def(TransformHandleType) class-attribute instance-attribute

results_ = var_result_def(TransformHandleType) class-attribute instance-attribute

__init__(handle: SSAValue, number_of_results: int, pass_through_empty_handle: int | IntegerAttr | bool = False, fail_on_payload_too_small: int | IntegerAttr | bool = False, overflow_result: int | IntegerAttr | None = None)

Source code in xdsl/dialects/transform.py
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
def __init__(
    self,
    handle: SSAValue,
    number_of_results: int,
    pass_through_empty_handle: int | IntegerAttr | bool = False,
    fail_on_payload_too_small: int | IntegerAttr | bool = False,
    overflow_result: int | IntegerAttr | None = None,
):
    if isinstance(pass_through_empty_handle, bool):
        pass_through_empty_handle = IntegerAttr(
            int(pass_through_empty_handle), IntegerType(1)
        )
    if isinstance(fail_on_payload_too_small, bool):
        fail_on_payload_too_small = IntegerAttr(
            int(fail_on_payload_too_small), IntegerType(1)
        )
    if isinstance(pass_through_empty_handle, int):
        pass_through_empty_handle = IntegerAttr(
            pass_through_empty_handle, IntegerType(1)
        )
    if isinstance(fail_on_payload_too_small, int):
        fail_on_payload_too_small = IntegerAttr(
            fail_on_payload_too_small, IntegerType(1)
        )
    if isinstance(overflow_result, int):
        overflow_result = IntegerAttr(overflow_result, IntegerType(64))
    super().__init__(
        properties={
            "pass_through_empty_handle": pass_through_empty_handle,
            "fail_on_payload_too_small": fail_on_payload_too_small,
            "overflow_result": overflow_result,
        },
        operands=[handle],
        result_types=[[handle.type for _ in range(number_of_results)]],
    )

YieldOp dataclass

Bases: AbstractYieldOperation[Attribute]

See external documentation.

Source code in xdsl/dialects/transform.py
549
550
551
552
553
554
555
556
557
@irdl_op_definition
class YieldOp(AbstractYieldOperation[Attribute]):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformyield-transformyieldop).
    """

    name = "transform.yield"

    traits = traits_def(IsTerminator())

name = 'transform.yield' class-attribute instance-attribute

traits = traits_def(IsTerminator()) class-attribute instance-attribute

SequenceOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
@irdl_op_definition
class SequenceOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformsequence-transformsequenceop).
    """

    name = "transform.sequence"

    body = region_def("single_block")
    failure_propagation_mode = prop_def()
    root = var_operand_def(AnyOpType)
    extra_bindings = var_operand_def(TransformHandleType)

    irdl_options = (AttrSizedOperandSegments(as_property=True),)
    traits = traits_def(IsolatedFromAbove())

    def __init__(
        self,
        failure_propagation_mode: FailurePropagationModeAttr | IntegerAttr | int,
        root: Sequence[SSAValue],
        extra_bindings: Sequence[SSAValue],
        body: Region,
    ):
        if isinstance(failure_propagation_mode, int):
            failure_propagation_mode = IntegerAttr(
                failure_propagation_mode, IntegerType(32)
            )
        super().__init__(
            properties={
                "failure_propagation_mode": failure_propagation_mode,
            },
            regions=[body],
            operands=[root, extra_bindings],
        )

    def verify_(self):
        if not isinstance(
            self.failure_propagation_mode, FailurePropagationModeAttr
        ) and not isinstance(self.failure_propagation_mode, IntegerAttr):
            raise VerifyException(
                "Expected failure_propagation_mode to be of type "
                f"FailurePropagationModeAttr, got {type(self.failure_propagation_mode)}"
            )

name = 'transform.sequence' class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

failure_propagation_mode = prop_def() class-attribute instance-attribute

root = var_operand_def(AnyOpType) class-attribute instance-attribute

extra_bindings = var_operand_def(TransformHandleType) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

traits = traits_def(IsolatedFromAbove()) class-attribute instance-attribute

__init__(failure_propagation_mode: FailurePropagationModeAttr | IntegerAttr | int, root: Sequence[SSAValue], extra_bindings: Sequence[SSAValue], body: Region)

Source code in xdsl/dialects/transform.py
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
def __init__(
    self,
    failure_propagation_mode: FailurePropagationModeAttr | IntegerAttr | int,
    root: Sequence[SSAValue],
    extra_bindings: Sequence[SSAValue],
    body: Region,
):
    if isinstance(failure_propagation_mode, int):
        failure_propagation_mode = IntegerAttr(
            failure_propagation_mode, IntegerType(32)
        )
    super().__init__(
        properties={
            "failure_propagation_mode": failure_propagation_mode,
        },
        regions=[body],
        operands=[root, extra_bindings],
    )

verify_()

Source code in xdsl/dialects/transform.py
595
596
597
598
599
600
601
602
def verify_(self):
    if not isinstance(
        self.failure_propagation_mode, FailurePropagationModeAttr
    ) and not isinstance(self.failure_propagation_mode, IntegerAttr):
        raise VerifyException(
            "Expected failure_propagation_mode to be of type "
            f"FailurePropagationModeAttr, got {type(self.failure_propagation_mode)}"
        )

TileOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
@irdl_op_definition
class TileOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformstructuredtile_using_for-transformtileusingforop).
    """

    name = "transform.structured.tile_using_for"

    target = operand_def(TransformHandleType)
    dynamic_sizes = var_operand_def(TransformHandleType)
    static_sizes = opt_prop_def(DenseArrayBase.constr(i64))
    interchange = opt_prop_def(DenseArrayBase.constr(i64))
    scalable_sizes = opt_prop_def(DenseArrayBase.constr(i1))

    tiled_linalg_op = result_def(AnyOpType)
    loops = var_result_def(AnyOpType)

    assembly_format = (
        "$target `tile_sizes` "
        "custom<ScalableDynamicIndexList>($dynamic_sizes, $static_sizes, $scalable_sizes) "
        "(`interchange` `=` $interchange^)? "
        "attr-dict `:` functional-type(operands, results)"
    )

    custom_directives = (ScalableDynamicIndexList,)

    def __init__(
        self,
        target: SSAValue,
        dynamic_sizes: Sequence[SSAValue] = (),
        static_sizes: DenseArrayBase[IntegerType] | Sequence[int] | None = None,
        interchange: DenseArrayBase[IntegerType] | Sequence[int] | None = None,
        scalable_sizes: DenseArrayBase[IntegerType] | Sequence[int] | None = None,
    ):
        if isinstance(static_sizes, Sequence):
            static_sizes = DenseArrayBase.from_list(i64, static_sizes)
        if isinstance(interchange, Sequence):
            interchange = DenseArrayBase.from_list(i64, interchange)
        if isinstance(scalable_sizes, Sequence):
            scalable_sizes = DenseArrayBase.from_list(i1, scalable_sizes)
        super().__init__(
            operands=(target, dynamic_sizes),
            properties={
                "static_sizes": static_sizes,
                "interchange": interchange,
                "scalable_sizes": scalable_sizes,
            },
            result_types=[
                AnyOpType(),
                [
                    AnyOpType()
                    for _ in range(
                        (
                            len(static_sizes.get_values())
                            - static_sizes.get_values().count(0)
                        )
                        if static_sizes
                        else 0
                    )
                ],
            ],
        )

name = 'transform.structured.tile_using_for' class-attribute instance-attribute

target = operand_def(TransformHandleType) class-attribute instance-attribute

dynamic_sizes = var_operand_def(TransformHandleType) class-attribute instance-attribute

static_sizes = opt_prop_def(DenseArrayBase.constr(i64)) class-attribute instance-attribute

interchange = opt_prop_def(DenseArrayBase.constr(i64)) class-attribute instance-attribute

scalable_sizes = opt_prop_def(DenseArrayBase.constr(i1)) class-attribute instance-attribute

tiled_linalg_op = result_def(AnyOpType) class-attribute instance-attribute

loops = var_result_def(AnyOpType) class-attribute instance-attribute

assembly_format = '$target `tile_sizes` custom<ScalableDynamicIndexList>($dynamic_sizes, $static_sizes, $scalable_sizes) (`interchange` `=` $interchange^)? attr-dict `:` functional-type(operands, results)' class-attribute instance-attribute

custom_directives = (ScalableDynamicIndexList,) class-attribute instance-attribute

__init__(target: SSAValue, dynamic_sizes: Sequence[SSAValue] = (), static_sizes: DenseArrayBase[IntegerType] | Sequence[int] | None = None, interchange: DenseArrayBase[IntegerType] | Sequence[int] | None = None, scalable_sizes: DenseArrayBase[IntegerType] | Sequence[int] | None = None)

Source code in xdsl/dialects/transform.py
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
def __init__(
    self,
    target: SSAValue,
    dynamic_sizes: Sequence[SSAValue] = (),
    static_sizes: DenseArrayBase[IntegerType] | Sequence[int] | None = None,
    interchange: DenseArrayBase[IntegerType] | Sequence[int] | None = None,
    scalable_sizes: DenseArrayBase[IntegerType] | Sequence[int] | None = None,
):
    if isinstance(static_sizes, Sequence):
        static_sizes = DenseArrayBase.from_list(i64, static_sizes)
    if isinstance(interchange, Sequence):
        interchange = DenseArrayBase.from_list(i64, interchange)
    if isinstance(scalable_sizes, Sequence):
        scalable_sizes = DenseArrayBase.from_list(i1, scalable_sizes)
    super().__init__(
        operands=(target, dynamic_sizes),
        properties={
            "static_sizes": static_sizes,
            "interchange": interchange,
            "scalable_sizes": scalable_sizes,
        },
        result_types=[
            AnyOpType(),
            [
                AnyOpType()
                for _ in range(
                    (
                        len(static_sizes.get_values())
                        - static_sizes.get_values().count(0)
                    )
                    if static_sizes
                    else 0
                )
            ],
        ],
    )

TileToForallOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
@irdl_op_definition
class TileToForallOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformstructuredtile_using_for-transformtileusingforop).
    """

    name = "transform.structured.tile_using_forall"

    target = operand_def(TransformHandleType)
    num_threads = var_operand_def(DenseArrayBase)
    tile_sizes = var_operand_def(DenseArrayBase)
    packed_num_threads = opt_operand_def(DenseArrayBase)
    packed_tile_sizes = opt_operand_def(DenseArrayBase)
    static_num_threads = opt_prop_def(DenseArrayBase)
    static_tile_sizes = opt_prop_def(DenseArrayBase)
    mapping = opt_attr_def(DenseArrayBase)

    forall_op = result_def(TransformHandleType)
    tiled_op = result_def(TransformHandleType)

    irdl_options = (AttrSizedOperandSegments(as_property=True),)

    def __init__(
        self,
        target: SSAValue,
        num_threads: Sequence[SSAValue],
        tile_sizes: Sequence[SSAValue],
        packed_num_threads: SSAValue | None,
        packed_tile_sizes: SSAValue | None,
        static_num_threads: DenseArrayBase | Sequence[int] | None,
        static_tile_sizes: DenseArrayBase | Sequence[int] | None,
        mapping: DenseArrayBase | Sequence[int] | None,
    ):
        if isinstance(static_num_threads, Sequence):
            static_num_threads = DenseArrayBase.from_list(
                IntegerType(64), static_num_threads
            )
        if isinstance(static_tile_sizes, Sequence):
            static_tile_sizes = DenseArrayBase.from_list(
                IntegerType(64), static_tile_sizes
            )
        if isinstance(mapping, Sequence):
            mapping = DenseArrayBase.from_list(IntegerType(64), mapping)

        super().__init__(
            operands=[
                target,
                num_threads,
                tile_sizes,
                packed_num_threads,
                packed_tile_sizes,
            ],
            properties={
                "static_num_threads": static_num_threads,
                "static_tile_sizes": static_tile_sizes,
                "mapping": mapping,
            },
            result_types=[AnyOpType(), AnyOpType()],
        )

name = 'transform.structured.tile_using_forall' class-attribute instance-attribute

target = operand_def(TransformHandleType) class-attribute instance-attribute

num_threads = var_operand_def(DenseArrayBase) class-attribute instance-attribute

tile_sizes = var_operand_def(DenseArrayBase) class-attribute instance-attribute

packed_num_threads = opt_operand_def(DenseArrayBase) class-attribute instance-attribute

packed_tile_sizes = opt_operand_def(DenseArrayBase) class-attribute instance-attribute

static_num_threads = opt_prop_def(DenseArrayBase) class-attribute instance-attribute

static_tile_sizes = opt_prop_def(DenseArrayBase) class-attribute instance-attribute

mapping = opt_attr_def(DenseArrayBase) class-attribute instance-attribute

forall_op = result_def(TransformHandleType) class-attribute instance-attribute

tiled_op = result_def(TransformHandleType) class-attribute instance-attribute

irdl_options = (AttrSizedOperandSegments(as_property=True),) class-attribute instance-attribute

__init__(target: SSAValue, num_threads: Sequence[SSAValue], tile_sizes: Sequence[SSAValue], packed_num_threads: SSAValue | None, packed_tile_sizes: SSAValue | None, static_num_threads: DenseArrayBase | Sequence[int] | None, static_tile_sizes: DenseArrayBase | Sequence[int] | None, mapping: DenseArrayBase | Sequence[int] | None)

Source code in xdsl/dialects/transform.py
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
def __init__(
    self,
    target: SSAValue,
    num_threads: Sequence[SSAValue],
    tile_sizes: Sequence[SSAValue],
    packed_num_threads: SSAValue | None,
    packed_tile_sizes: SSAValue | None,
    static_num_threads: DenseArrayBase | Sequence[int] | None,
    static_tile_sizes: DenseArrayBase | Sequence[int] | None,
    mapping: DenseArrayBase | Sequence[int] | None,
):
    if isinstance(static_num_threads, Sequence):
        static_num_threads = DenseArrayBase.from_list(
            IntegerType(64), static_num_threads
        )
    if isinstance(static_tile_sizes, Sequence):
        static_tile_sizes = DenseArrayBase.from_list(
            IntegerType(64), static_tile_sizes
        )
    if isinstance(mapping, Sequence):
        mapping = DenseArrayBase.from_list(IntegerType(64), mapping)

    super().__init__(
        operands=[
            target,
            num_threads,
            tile_sizes,
            packed_num_threads,
            packed_tile_sizes,
        ],
        properties={
            "static_num_threads": static_num_threads,
            "static_tile_sizes": static_tile_sizes,
            "mapping": mapping,
        },
        result_types=[AnyOpType(), AnyOpType()],
    )

SelectOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
@irdl_op_definition
class SelectOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformselect-transformselectop).
    """

    name = "transform.select"

    op_name = prop_def(StringAttr)
    target = operand_def(TransformHandleType)
    result = result_def(TransformHandleType)

    def __init__(self, op_name: str | StringAttr, target: SSAValue):
        if isinstance(op_name, str):
            op_name = StringAttr(op_name)
        super().__init__(
            properties={"op_name": op_name},
            operands=[target],
            result_types=[AnyOpType()],
        )

name = 'transform.select' class-attribute instance-attribute

op_name = prop_def(StringAttr) class-attribute instance-attribute

target = operand_def(TransformHandleType) class-attribute instance-attribute

result = result_def(TransformHandleType) class-attribute instance-attribute

__init__(op_name: str | StringAttr, target: SSAValue)

Source code in xdsl/dialects/transform.py
742
743
744
745
746
747
748
749
def __init__(self, op_name: str | StringAttr, target: SSAValue):
    if isinstance(op_name, str):
        op_name = StringAttr(op_name)
    super().__init__(
        properties={"op_name": op_name},
        operands=[target],
        result_types=[AnyOpType()],
    )

NamedSequenceOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
@irdl_op_definition
class NamedSequenceOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformnamed_sequence-transformnamedsequenceop).
    """

    name = "transform.named_sequence"

    sym_name = prop_def(SymbolNameConstraint())
    function_type = prop_def(FunctionType)
    sym_visibility = opt_prop_def(StringAttr)
    arg_attrs = opt_prop_def(ArrayAttr[DictionaryAttr])
    res_attrs = opt_prop_def(ArrayAttr[DictionaryAttr])
    body = region_def("single_block")

    traits = traits_def(
        IsolatedFromAbove(), SymbolOpInterface(), FuncOpCallableInterface()
    )

    def __init__(
        self,
        sym_name: str | StringAttr,
        function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]],
        body: Region,
        sym_visibility: str | StringAttr | None = None,
        arg_attrs: Sequence[DictionaryAttr] | ArrayAttr[DictionaryAttr] | None = None,
        res_attrs: Sequence[DictionaryAttr] | ArrayAttr[DictionaryAttr] | None = None,
    ):
        if isinstance(sym_name, str):
            sym_name = StringAttr(sym_name)
        if isinstance(sym_visibility, str):
            sym_visibility = StringAttr(sym_visibility)
        if isinstance(function_type, tuple):
            inputs, outputs = function_type
            function_type = FunctionType.from_lists(inputs, outputs)
        if isinstance(arg_attrs, Sequence):
            arg_attrs = ArrayAttr(arg_attrs)
        if isinstance(res_attrs, Sequence):
            res_attrs = ArrayAttr(res_attrs)
        super().__init__(
            properties={
                "sym_name": sym_name,
                "function_type": function_type,
                "sym_visibility": sym_visibility,
                "arg_attrs": arg_attrs,
                "res_attrs": res_attrs,
            },
            regions=[body],
        )

    @classmethod
    def parse(cls, parser: Parser) -> NamedSequenceOp:
        visibility = parser.parse_optional_visibility_keyword()

        (
            name,
            input_types,
            return_types,
            region,
            extra_attrs,
            arg_attrs,
            res_attrs,
        ) = parse_func_op_like(
            parser, reserved_attr_names=("sym_name", "function_type", "sym_visibility")
        )
        named_sequence = NamedSequenceOp(
            sym_name=name,
            function_type=(input_types, return_types),
            body=region,
            sym_visibility=visibility,
            arg_attrs=arg_attrs,
            res_attrs=res_attrs,
        )
        if extra_attrs is not None:
            named_sequence.attributes |= extra_attrs.data
        return named_sequence

    def print(self, printer: Printer):
        if self.sym_visibility:
            visibility = self.sym_visibility.data
            printer.print_string(" ")
            printer.print_string(visibility)

        print_func_op_like(
            printer,
            self.sym_name,
            self.function_type,
            self.body,
            self.attributes,
            arg_attrs=self.arg_attrs,
            res_attrs=self.res_attrs,
            reserved_attr_names=(
                "sym_name",
                "function_type",
                "sym_visibility",
                "arg_attrs",
            ),
        )

name = 'transform.named_sequence' class-attribute instance-attribute

sym_name = prop_def(SymbolNameConstraint()) class-attribute instance-attribute

function_type = prop_def(FunctionType) class-attribute instance-attribute

sym_visibility = opt_prop_def(StringAttr) class-attribute instance-attribute

arg_attrs = opt_prop_def(ArrayAttr[DictionaryAttr]) class-attribute instance-attribute

res_attrs = opt_prop_def(ArrayAttr[DictionaryAttr]) class-attribute instance-attribute

body = region_def('single_block') class-attribute instance-attribute

traits = traits_def(IsolatedFromAbove(), SymbolOpInterface(), FuncOpCallableInterface()) class-attribute instance-attribute

__init__(sym_name: str | StringAttr, function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]], body: Region, sym_visibility: str | StringAttr | None = None, arg_attrs: Sequence[DictionaryAttr] | ArrayAttr[DictionaryAttr] | None = None, res_attrs: Sequence[DictionaryAttr] | ArrayAttr[DictionaryAttr] | None = None)

Source code in xdsl/dialects/transform.py
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
def __init__(
    self,
    sym_name: str | StringAttr,
    function_type: FunctionType | tuple[Sequence[Attribute], Sequence[Attribute]],
    body: Region,
    sym_visibility: str | StringAttr | None = None,
    arg_attrs: Sequence[DictionaryAttr] | ArrayAttr[DictionaryAttr] | None = None,
    res_attrs: Sequence[DictionaryAttr] | ArrayAttr[DictionaryAttr] | None = None,
):
    if isinstance(sym_name, str):
        sym_name = StringAttr(sym_name)
    if isinstance(sym_visibility, str):
        sym_visibility = StringAttr(sym_visibility)
    if isinstance(function_type, tuple):
        inputs, outputs = function_type
        function_type = FunctionType.from_lists(inputs, outputs)
    if isinstance(arg_attrs, Sequence):
        arg_attrs = ArrayAttr(arg_attrs)
    if isinstance(res_attrs, Sequence):
        res_attrs = ArrayAttr(res_attrs)
    super().__init__(
        properties={
            "sym_name": sym_name,
            "function_type": function_type,
            "sym_visibility": sym_visibility,
            "arg_attrs": arg_attrs,
            "res_attrs": res_attrs,
        },
        regions=[body],
    )

parse(parser: Parser) -> NamedSequenceOp classmethod

Source code in xdsl/dialects/transform.py
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
@classmethod
def parse(cls, parser: Parser) -> NamedSequenceOp:
    visibility = parser.parse_optional_visibility_keyword()

    (
        name,
        input_types,
        return_types,
        region,
        extra_attrs,
        arg_attrs,
        res_attrs,
    ) = parse_func_op_like(
        parser, reserved_attr_names=("sym_name", "function_type", "sym_visibility")
    )
    named_sequence = NamedSequenceOp(
        sym_name=name,
        function_type=(input_types, return_types),
        body=region,
        sym_visibility=visibility,
        arg_attrs=arg_attrs,
        res_attrs=res_attrs,
    )
    if extra_attrs is not None:
        named_sequence.attributes |= extra_attrs.data
    return named_sequence

print(printer: Printer)

Source code in xdsl/dialects/transform.py
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
def print(self, printer: Printer):
    if self.sym_visibility:
        visibility = self.sym_visibility.data
        printer.print_string(" ")
        printer.print_string(visibility)

    print_func_op_like(
        printer,
        self.sym_name,
        self.function_type,
        self.body,
        self.attributes,
        arg_attrs=self.arg_attrs,
        res_attrs=self.res_attrs,
        reserved_attr_names=(
            "sym_name",
            "function_type",
            "sym_visibility",
            "arg_attrs",
        ),
    )

CastOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
852
853
854
855
856
857
858
859
860
861
862
863
864
@irdl_op_definition
class CastOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformcast-transformcastop).
    """

    name = "transform.cast"

    input = operand_def(TransformHandleType)
    output = result_def(TransformHandleType)

    def __init__(self, input: SSAValue):
        super().__init__(operands=[input], result_types=[AnyOpType()])

name = 'transform.cast' class-attribute instance-attribute

input = operand_def(TransformHandleType) class-attribute instance-attribute

output = result_def(TransformHandleType) class-attribute instance-attribute

__init__(input: SSAValue)

Source code in xdsl/dialects/transform.py
863
864
def __init__(self, input: SSAValue):
    super().__init__(operands=[input], result_types=[AnyOpType()])

MatchInterfaceEnum

Bases: StrEnum

The interfaces transform.structured.match can match on. The order must match upstream's MatchInterfaceEnum: the position of each case is the i32 value MLIR stores for it.

Source code in xdsl/dialects/transform.py
867
868
869
870
871
872
873
874
875
876
class MatchInterfaceEnum(StrEnum):
    """
    The interfaces `transform.structured.match` can match on. The order must
    match upstream's `MatchInterfaceEnum`: the position of each case is the
    `i32` value MLIR stores for it.
    """

    LINALG_OP = "LinalgOp"
    TILING_INTERFACE = "TilingInterface"
    LOOP_LIKE_INTERFACE = "LoopLikeInterface"

LINALG_OP = 'LinalgOp' class-attribute instance-attribute

TILING_INTERFACE = 'TilingInterface' class-attribute instance-attribute

LOOP_LIKE_INTERFACE = 'LoopLikeInterface' class-attribute instance-attribute

MatchInterface dataclass

Bases: CustomDirective

Parses and prints the interface property of transform.structured.match as its upstream enum keyword (e.g. TilingInterface) rather than as the i32 it is stored as.

Source code in xdsl/dialects/transform.py
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
@irdl_custom_directive
class MatchInterface(CustomDirective):
    """
    Parses and prints the `interface` property of `transform.structured.match`
    as its upstream enum keyword (e.g. `TilingInterface`) rather than as the
    `i32` it is stored as.
    """

    interface: AttributeVariable

    def is_anchorable(self) -> bool:
        return True

    def is_present(self, op: IRDLOperation) -> bool:
        return self.interface.get(op) is not None

    def parse(self, parser: Parser, state: ParsingState):
        interface = parser.parse_str_enum(MatchInterfaceEnum)
        self.interface.set(state, IntegerAttr(MATCH_INTERFACES.index(interface), i32))

    def print(self, printer: Printer, state: PrintingState, op: IRDLOperation) -> None:
        attr = self.interface.get(op)
        # The op verifier guarantees the value indexes MATCH_INTERFACES.
        assert isa(attr, IntegerAttr[I32])
        printer.print_string(MATCH_INTERFACES[attr.value.data].value)

interface: AttributeVariable instance-attribute

is_anchorable() -> bool

Source code in xdsl/dialects/transform.py
892
893
def is_anchorable(self) -> bool:
    return True

is_present(op: IRDLOperation) -> bool

Source code in xdsl/dialects/transform.py
895
896
def is_present(self, op: IRDLOperation) -> bool:
    return self.interface.get(op) is not None

parse(parser: Parser, state: ParsingState)

Source code in xdsl/dialects/transform.py
898
899
900
def parse(self, parser: Parser, state: ParsingState):
    interface = parser.parse_str_enum(MatchInterfaceEnum)
    self.interface.set(state, IntegerAttr(MATCH_INTERFACES.index(interface), i32))

print(printer: Printer, state: PrintingState, op: IRDLOperation) -> None

Source code in xdsl/dialects/transform.py
902
903
904
905
906
def print(self, printer: Printer, state: PrintingState, op: IRDLOperation) -> None:
    attr = self.interface.get(op)
    # The op verifier guarantees the value indexes MATCH_INTERFACES.
    assert isa(attr, IntegerAttr[I32])
    printer.print_string(MATCH_INTERFACES[attr.value.data].value)

MatchOp

Bases: IRDLOperation

See external documentation.

Source code in xdsl/dialects/transform.py
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
@irdl_op_definition
class MatchOp(IRDLOperation):
    """
    See external [documentation](https://mlir.llvm.org/docs/Dialects/Transform/#transformstructuredmatch-transformmatchop).
    """

    name = "transform.structured.match"

    ops = opt_prop_def(ArrayAttr[StringAttr])
    interface = opt_prop_def(IntegerAttr[I32])
    op_attrs = opt_prop_def(DictionaryAttr)
    filter_result_type = opt_prop_def(TypeAttribute)
    filter_operand_types = opt_prop_def(ArrayAttr[TypeAttribute])

    target = operand_def(TransformOpHandleType)
    result = result_def(TransformOpHandleType)

    assembly_format = (
        "(`ops` `{` $ops^ `}`)? "
        "(`interface` `{` custom<MatchInterface>($interface)^ `}`)? "
        "(`attributes` $op_attrs^)? "
        "(`filter_result_type` `=` $filter_result_type^)? "
        "(`filter_operand_types` `=` $filter_operand_types^)? "
        "`in` $target attr-dict `:` functional-type(operands, results)"
    )

    custom_directives = (MatchInterface,)

    def __init__(
        self,
        target: SSAValue,
        ops: Sequence[str] | ArrayAttr[StringAttr] | None = None,
        interface: int | IntegerAttr | MatchInterfaceEnum | None = None,
        op_attrs: dict[str, Attribute] | DictionaryAttr | None = None,
        filter_result_type: TypeAttribute | None = None,
        filter_operand_types: Sequence[TypeAttribute]
        | ArrayAttr[TypeAttribute]
        | None = None,
    ):
        if isinstance(ops, Sequence):
            ops = ArrayAttr([StringAttr(op) for op in ops])
        if isinstance(interface, MatchInterfaceEnum):
            interface = MATCH_INTERFACES.index(interface)
        if isinstance(interface, int):
            interface = IntegerAttr(interface, i32)

        if isinstance(op_attrs, Mapping):
            op_attrs = DictionaryAttr(op_attrs)
        if isinstance(filter_operand_types, Sequence):
            filter_operand_types = ArrayAttr(filter_operand_types)
        super().__init__(
            properties={
                "ops": ops,
                "interface": interface,
                "op_attrs": op_attrs,
                "filter_result_type": filter_result_type,
                "filter_operand_types": filter_operand_types,
            },
            operands=[target],
            result_types=[AnyOpType()],
        )

    def verify_(self):
        if self.interface is not None and not (
            0 <= self.interface.value.data < len(MATCH_INTERFACES)
        ):
            raise VerifyException(
                f"interface must be one of {', '.join(MatchInterfaceEnum)} "
                f"(0 to {len(MATCH_INTERFACES) - 1}), got "
                f"{self.interface.value.data}"
            )

name = 'transform.structured.match' class-attribute instance-attribute

ops = opt_prop_def(ArrayAttr[StringAttr]) class-attribute instance-attribute

interface = opt_prop_def(IntegerAttr[I32]) class-attribute instance-attribute

op_attrs = opt_prop_def(DictionaryAttr) class-attribute instance-attribute

filter_result_type = opt_prop_def(TypeAttribute) class-attribute instance-attribute

filter_operand_types = opt_prop_def(ArrayAttr[TypeAttribute]) class-attribute instance-attribute

target = operand_def(TransformOpHandleType) class-attribute instance-attribute

result = result_def(TransformOpHandleType) class-attribute instance-attribute

assembly_format = '(`ops` `{` $ops^ `}`)? (`interface` `{` custom<MatchInterface>($interface)^ `}`)? (`attributes` $op_attrs^)? (`filter_result_type` `=` $filter_result_type^)? (`filter_operand_types` `=` $filter_operand_types^)? `in` $target attr-dict `:` functional-type(operands, results)' class-attribute instance-attribute

custom_directives = (MatchInterface,) class-attribute instance-attribute

__init__(target: SSAValue, ops: Sequence[str] | ArrayAttr[StringAttr] | None = None, interface: int | IntegerAttr | MatchInterfaceEnum | None = None, op_attrs: dict[str, Attribute] | DictionaryAttr | None = None, filter_result_type: TypeAttribute | None = None, filter_operand_types: Sequence[TypeAttribute] | ArrayAttr[TypeAttribute] | None = None)

Source code in xdsl/dialects/transform.py
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
def __init__(
    self,
    target: SSAValue,
    ops: Sequence[str] | ArrayAttr[StringAttr] | None = None,
    interface: int | IntegerAttr | MatchInterfaceEnum | None = None,
    op_attrs: dict[str, Attribute] | DictionaryAttr | None = None,
    filter_result_type: TypeAttribute | None = None,
    filter_operand_types: Sequence[TypeAttribute]
    | ArrayAttr[TypeAttribute]
    | None = None,
):
    if isinstance(ops, Sequence):
        ops = ArrayAttr([StringAttr(op) for op in ops])
    if isinstance(interface, MatchInterfaceEnum):
        interface = MATCH_INTERFACES.index(interface)
    if isinstance(interface, int):
        interface = IntegerAttr(interface, i32)

    if isinstance(op_attrs, Mapping):
        op_attrs = DictionaryAttr(op_attrs)
    if isinstance(filter_operand_types, Sequence):
        filter_operand_types = ArrayAttr(filter_operand_types)
    super().__init__(
        properties={
            "ops": ops,
            "interface": interface,
            "op_attrs": op_attrs,
            "filter_result_type": filter_result_type,
            "filter_operand_types": filter_operand_types,
        },
        operands=[target],
        result_types=[AnyOpType()],
    )

verify_()

Source code in xdsl/dialects/transform.py
971
972
973
974
975
976
977
978
979
def verify_(self):
    if self.interface is not None and not (
        0 <= self.interface.value.data < len(MATCH_INTERFACES)
    ):
        raise VerifyException(
            f"interface must be one of {', '.join(MatchInterfaceEnum)} "
            f"(0 to {len(MATCH_INTERFACES) - 1}), got "
            f"{self.interface.value.data}"
        )