[Mlir-commits] [mlir] [MLIR][Transform][Python] Sync derived classes and their wrappers (PR #166871)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Nov 6 16:00:20 PST 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {darker}-->
:warning: Python code formatter, darker found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
darker --check --diff -r origin/main...HEAD mlir/python/mlir/dialects/transform/__init__.py mlir/test/python/dialects/transform.py
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from darker here.
</summary>
``````````diff
--- test/python/dialects/transform.py 2025-11-06 23:43:10.000000 +0000
+++ test/python/dialects/transform.py 2025-11-06 23:59:51.709024 +0000
@@ -132,111 +132,114 @@
with InsertionPoint(sequence.body):
transform.yield_()
# CHECK: transform.sequence failures(propagate)
# CHECK: ^{{.*}}(%{{.*}}: !transform.any_op, %{{.*}}: !transform.any_op, %{{.*}}: !transform.op<"foo.bar">):
+
@run
def testNestedSequenceOpWithExtras(module: Module):
- sequence = transform.SequenceOp(
+ sequence = transform.SequenceOp(
transform.FailurePropagationMode.Propagate,
[],
transform.AnyOpType.get(),
[transform.AnyOpType.get(), transform.OperationType.get("foo.bar")],
)
- with InsertionPoint(sequence.body):
- nested = transform.SequenceOp(
+ with InsertionPoint(sequence.body):
+ nested = transform.SequenceOp(
transform.FailurePropagationMode.Propagate,
[],
sequence.bodyTarget,
sequence.bodyExtraArgs,
)
- with InsertionPoint(nested.body):
- transform.YieldOp()
- transform.YieldOp()
- # CHECK-LABEL: TEST: testNestedSequenceOpWithExtras
- # CHECK: transform.sequence failures(propagate)
- # CHECK: ^{{.*}}(%[[ARG0:.*]]: !transform.any_op, %[[ARG1:.*]]: !transform.any_op, %[[ARG2:.*]]: !transform.op<"foo.bar">):
- # CHECK: sequence %[[ARG0]], %[[ARG1]], %[[ARG2]] : (!transform.any_op, !transform.any_op, !transform.op<"foo.bar">)
+ with InsertionPoint(nested.body):
+ transform.YieldOp()
+ transform.YieldOp()
+ # CHECK-LABEL: TEST: testNestedSequenceOpWithExtras
+ # CHECK: transform.sequence failures(propagate)
+ # CHECK: ^{{.*}}(%[[ARG0:.*]]: !transform.any_op, %[[ARG1:.*]]: !transform.any_op, %[[ARG2:.*]]: !transform.op<"foo.bar">):
+ # CHECK: sequence %[[ARG0]], %[[ARG1]], %[[ARG2]] : (!transform.any_op, !transform.any_op, !transform.op<"foo.bar">)
@run
def testTransformPDLOps(module: Module):
- withPdl = transform_pdl.WithPDLPatternsOp(transform.AnyOpType.get())
- with InsertionPoint(withPdl.body):
- sequence = transform.SequenceOp(
- transform.FailurePropagationMode.Propagate,
- [transform.AnyOpType.get()],
- withPdl.bodyTarget,
- )
- with InsertionPoint(sequence.body):
- match = transform_pdl.PDLMatchOp(
- transform.AnyOpType.get(), sequence.bodyTarget, "pdl_matcher"
- )
- transform.YieldOp(match)
- # CHECK-LABEL: TEST: testTransformPDLOps
- # CHECK: transform.with_pdl_patterns {
- # CHECK: ^{{.*}}(%[[ARG0:.+]]: !transform.any_op):
- # CHECK: = sequence %[[ARG0]] : !transform.any_op -> !transform.any_op failures(propagate) {
- # CHECK: ^{{.*}}(%[[ARG1:.+]]: !transform.any_op):
- # CHECK: %[[RES:.+]] = pdl_match @pdl_matcher in %[[ARG1]]
- # CHECK: yield %[[RES]] : !transform.any_op
- # CHECK: }
- # CHECK: }
+ withPdl = transform_pdl.WithPDLPatternsOp(transform.AnyOpType.get())
+ with InsertionPoint(withPdl.body):
+ sequence = transform.SequenceOp(
+ transform.FailurePropagationMode.Propagate,
+ [transform.AnyOpType.get()],
+ withPdl.bodyTarget,
+ )
+ with InsertionPoint(sequence.body):
+ match = transform_pdl.PDLMatchOp(
+ transform.AnyOpType.get(), sequence.bodyTarget, "pdl_matcher"
+ )
+ transform.YieldOp(match)
+ # CHECK-LABEL: TEST: testTransformPDLOps
+ # CHECK: transform.with_pdl_patterns {
+ # CHECK: ^{{.*}}(%[[ARG0:.+]]: !transform.any_op):
+ # CHECK: = sequence %[[ARG0]] : !transform.any_op -> !transform.any_op failures(propagate) {
+ # CHECK: ^{{.*}}(%[[ARG1:.+]]: !transform.any_op):
+ # CHECK: %[[RES:.+]] = pdl_match @pdl_matcher in %[[ARG1]]
+ # CHECK: yield %[[RES]] : !transform.any_op
+ # CHECK: }
+ # CHECK: }
@run
def testNamedSequenceOp(module: Module):
module.operation.attributes["transform.with_named_sequence"] = UnitAttr.get()
named_sequence = transform.NamedSequenceOp(
"__transform_main",
[transform.AnyOpType.get()],
[transform.AnyOpType.get()],
- arg_attrs = [{"transform.consumed": UnitAttr.get()}])
+ arg_attrs=[{"transform.consumed": UnitAttr.get()}],
+ )
with InsertionPoint(named_sequence.body):
transform.YieldOp([named_sequence.bodyTarget])
# CHECK-LABEL: TEST: testNamedSequenceOp
# CHECK: module attributes {transform.with_named_sequence} {
# CHECK: transform.named_sequence @__transform_main(%[[ARG0:.+]]: !transform.any_op {transform.consumed}) -> !transform.any_op {
# CHECK: yield %[[ARG0]] : !transform.any_op
named_sequence = transform.named_sequence(
"other_seq",
[transform.AnyOpType.get()],
[transform.AnyOpType.get()],
- arg_attrs = [{"transform.consumed": UnitAttr.get()}])
+ arg_attrs=[{"transform.consumed": UnitAttr.get()}],
+ )
with InsertionPoint(named_sequence.body):
transform.yield_([named_sequence.bodyTarget])
# CHECK: transform.named_sequence @other_seq(%[[ARG1:.+]]: !transform.any_op {transform.consumed}) -> !transform.any_op {
# CHECK: yield %[[ARG1]] : !transform.any_op
@run
def testGetParentOp(module: Module):
- sequence = transform.SequenceOp(
- transform.FailurePropagationMode.Propagate, [], transform.AnyOpType.get()
- )
- with InsertionPoint(sequence.body):
- transform.GetParentOp(
- transform.AnyOpType.get(),
- sequence.bodyTarget,
- isolated_from_above=True,
- nth_parent=2,
- )
- transform.get_parent_op(
- transform.AnyOpType.get(),
- sequence.bodyTarget,
- isolated_from_above=True,
- nth_parent=2,
- allow_empty_results=True,
- op_name="func.func",
- deduplicate=True,
- )
- transform.YieldOp()
- # CHECK-LABEL: TEST: testGetParentOp
- # CHECK: transform.sequence
- # CHECK: ^{{.*}}(%[[ARG1:.+]]: !transform.any_op):
- # CHECK: = get_parent_op %[[ARG1]] {isolated_from_above, nth_parent = 2 : i64}
- # CHECK: = get_parent_op %[[ARG1]] {allow_empty_results, deduplicate, isolated_from_above, nth_parent = 2 : i64, op_name = "func.func"}
+ sequence = transform.SequenceOp(
+ transform.FailurePropagationMode.Propagate, [], transform.AnyOpType.get()
+ )
+ with InsertionPoint(sequence.body):
+ transform.GetParentOp(
+ transform.AnyOpType.get(),
+ sequence.bodyTarget,
+ isolated_from_above=True,
+ nth_parent=2,
+ )
+ transform.get_parent_op(
+ transform.AnyOpType.get(),
+ sequence.bodyTarget,
+ isolated_from_above=True,
+ nth_parent=2,
+ allow_empty_results=True,
+ op_name="func.func",
+ deduplicate=True,
+ )
+ transform.YieldOp()
+ # CHECK-LABEL: TEST: testGetParentOp
+ # CHECK: transform.sequence
+ # CHECK: ^{{.*}}(%[[ARG1:.+]]: !transform.any_op):
+ # CHECK: = get_parent_op %[[ARG1]] {isolated_from_above, nth_parent = 2 : i64}
+ # CHECK: = get_parent_op %[[ARG1]] {allow_empty_results, deduplicate, isolated_from_above, nth_parent = 2 : i64, op_name = "func.func"}
@run
def testMergeHandlesOp(module: Module):
sequence = transform.SequenceOp(
@@ -253,42 +256,50 @@
# CHECK: = merge_handles deduplicate %[[RES1]] : !transform.any_op
@run
def testApplyPatternsOpCompact(module: Module):
- sequence = transform.SequenceOp(
- transform.FailurePropagationMode.Propagate, [], transform.AnyOpType.get()
- )
- with InsertionPoint(sequence.body):
- with InsertionPoint(transform.ApplyPatternsOp(sequence.bodyTarget).patterns):
- transform.ApplyCanonicalizationPatternsOp()
- with InsertionPoint(transform.apply_patterns(sequence.bodyTarget, apply_cse=True, max_iterations=3, max_num_rewrites=5).patterns):
- transform.ApplyCanonicalizationPatternsOp()
- transform.YieldOp()
- # CHECK-LABEL: TEST: testApplyPatternsOpCompact
- # CHECK: apply_patterns to
- # CHECK: transform.apply_patterns.canonicalization
- # CHECK: } : !transform.any_op
- # CHECK: apply_patterns to
- # CHECK: transform.apply_patterns.canonicalization
- # CHECK: } {apply_cse, max_iterations = 3 : i64, max_num_rewrites = 5 : i64} : !transform.any_op
+ sequence = transform.SequenceOp(
+ transform.FailurePropagationMode.Propagate, [], transform.AnyOpType.get()
+ )
+ with InsertionPoint(sequence.body):
+ with InsertionPoint(transform.ApplyPatternsOp(sequence.bodyTarget).patterns):
+ transform.ApplyCanonicalizationPatternsOp()
+ with InsertionPoint(
+ transform.apply_patterns(
+ sequence.bodyTarget,
+ apply_cse=True,
+ max_iterations=3,
+ max_num_rewrites=5,
+ ).patterns
+ ):
+ transform.ApplyCanonicalizationPatternsOp()
+ transform.YieldOp()
+ # CHECK-LABEL: TEST: testApplyPatternsOpCompact
+ # CHECK: apply_patterns to
+ # CHECK: transform.apply_patterns.canonicalization
+ # CHECK: } : !transform.any_op
+ # CHECK: apply_patterns to
+ # CHECK: transform.apply_patterns.canonicalization
+ # CHECK: } {apply_cse, max_iterations = 3 : i64, max_num_rewrites = 5 : i64} : !transform.any_op
@run
def testApplyPatternsOpWithType(module: Module):
- sequence = transform.SequenceOp(
- transform.FailurePropagationMode.Propagate, [],
- transform.OperationType.get('test.dummy')
- )
- with InsertionPoint(sequence.body):
- with InsertionPoint(transform.ApplyPatternsOp(sequence.bodyTarget).patterns):
- transform.ApplyCanonicalizationPatternsOp()
- transform.YieldOp()
- # CHECK-LABEL: TEST: testApplyPatternsOp
- # CHECK: apply_patterns to
- # CHECK: transform.apply_patterns.canonicalization
- # CHECK: !transform.op<"test.dummy">
+ sequence = transform.SequenceOp(
+ transform.FailurePropagationMode.Propagate,
+ [],
+ transform.OperationType.get("test.dummy"),
+ )
+ with InsertionPoint(sequence.body):
+ with InsertionPoint(transform.ApplyPatternsOp(sequence.bodyTarget).patterns):
+ transform.ApplyCanonicalizationPatternsOp()
+ transform.YieldOp()
+ # CHECK-LABEL: TEST: testApplyPatternsOp
+ # CHECK: apply_patterns to
+ # CHECK: transform.apply_patterns.canonicalization
+ # CHECK: !transform.op<"test.dummy">
@run
def testReplicateOp(module: Module):
with_pdl = transform_pdl.WithPDLPatternsOp(transform.AnyOpType.get())
``````````
</details>
https://github.com/llvm/llvm-project/pull/166871
More information about the Mlir-commits
mailing list