[Mlir-commits] [mlir] [mlir] update remaining transform tests to main pass (PR #81279)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Wed Feb 28 01:23:38 PST 2024
https://github.com/ftynse updated https://github.com/llvm/llvm-project/pull/81279
>From d6b4dbf91d71d097ff9108c268e6738a4aaf2bb0 Mon Sep 17 00:00:00 2001
From: Alex Zinenko <zinenko at google.com>
Date: Fri, 9 Feb 2024 17:00:49 +0000
Subject: [PATCH 1/2] [mlir] update remaining transform tests to main pass
Use the main transform interpreter pass instead of the test pass. The
only tests that are not updated are specific to the operation of the
test pass.
---
.../Transform/Transforms/InterpreterPass.cpp | 95 ++++-
...nterpreter-external-concurrent-source.mlir | 25 +-
.../test-interpreter-external-source.mlir | 14 +-
.../Transform/multi-arg-top-level-ops.mlir | 63 ++-
.../Transform/multi-arg-top-level-params.mlir | 39 +-
.../Transform/multi-arg-top-level-values.mlir | 32 +-
.../Transform/test-interpreter-debug.mlir | 58 +--
.../test-interpreter-external-concurrent.mlir | 4 +-
.../Transform/test-interpreter-external.mlir | 4 +-
.../Dialect/Transform/test-interpreter.mlir | 1 -
.../Transform/test-pass-application.mlir | 78 ++--
.../Transform/test-pattern-application.mlir | 384 ++++++++++--------
.../Dialect/Transform/test-pdl-extension.mlir | 68 ++--
.../Transform/transform-state-extension.mlir | 102 ++---
.../Vector/CPU/ArmSVE/test-contraction.mlir | 18 +-
15 files changed, 562 insertions(+), 423 deletions(-)
diff --git a/mlir/lib/Dialect/Transform/Transforms/InterpreterPass.cpp b/mlir/lib/Dialect/Transform/Transforms/InterpreterPass.cpp
index 5073234a7e35e9..7adf223f3440a5 100644
--- a/mlir/lib/Dialect/Transform/Transforms/InterpreterPass.cpp
+++ b/mlir/lib/Dialect/Transform/Transforms/InterpreterPass.cpp
@@ -50,12 +50,79 @@ static Operation *findPayloadRoot(Operation *passRoot, StringRef tag) {
return WalkResult::interrupt();
});
+ if (!target) {
+ passRoot->emitError()
+ << "could not find the operation with transform.target_tag=\"" << tag
+ << "\" attribute";
+ return nullptr;
+ }
+
return walkResult.wasInterrupted() ? nullptr : target;
}
namespace {
class InterpreterPass
: public transform::impl::InterpreterPassBase<InterpreterPass> {
+ // Parses the pass arguments to bind trailing arguments of the entry point.
+ std::optional<RaggedArray<transform::MappedValue>>
+ parseArguments(Operation *payloadRoot) {
+ MLIRContext *context = payloadRoot->getContext();
+
+ SmallVector<SmallVector<transform::MappedValue>, 2> trailingBindings;
+ trailingBindings.resize(debugBindTrailingArgs.size());
+
+ // Construct lists of op names to match.
+ SmallVector<std::optional<OperationName>> debugBindNames;
+ debugBindNames.reserve(debugBindTrailingArgs.size());
+ for (auto &&[position, nameString] :
+ llvm::enumerate(debugBindTrailingArgs)) {
+ StringRef name = nameString;
+
+ // Parse the integer literals.
+ if (name.starts_with("#")) {
+ debugBindNames.push_back(std::nullopt);
+ StringRef lhs = "";
+ StringRef rhs = name.drop_front();
+ do {
+ std::tie(lhs, rhs) = rhs.split(';');
+ int64_t value;
+ if (lhs.getAsInteger(10, value)) {
+ emitError(UnknownLoc::get(context))
+ << "couldn't parse integer pass argument " << name;
+ return std::nullopt;
+ }
+ trailingBindings[position].push_back(
+ Builder(context).getI64IntegerAttr(value));
+ } while (!rhs.empty());
+ } else if (name.starts_with("^")) {
+ debugBindNames.emplace_back(OperationName(name.drop_front(), context));
+ } else {
+ debugBindNames.emplace_back(OperationName(name, context));
+ }
+ }
+
+ // Collect operations or results for extra bindings.
+ payloadRoot->walk([&](Operation *payload) {
+ for (auto &&[position, name] : llvm::enumerate(debugBindNames)) {
+ if (!name || payload->getName() != *name)
+ continue;
+
+ if (StringRef(*std::next(debugBindTrailingArgs.begin(), position))
+ .starts_with("^")) {
+ llvm::append_range(trailingBindings[position], payload->getResults());
+ } else {
+ trailingBindings[position].push_back(payload);
+ }
+ }
+ });
+
+ RaggedArray<transform::MappedValue> bindings;
+ bindings.push_back(ArrayRef<Operation *>{payloadRoot});
+ for (SmallVector<transform::MappedValue> &trailing : trailingBindings)
+ bindings.push_back(std::move(trailing));
+ return bindings;
+ }
+
public:
using Base::Base;
@@ -67,34 +134,18 @@ class InterpreterPass
findPayloadRoot(getOperation(), debugPayloadRootTag);
if (!payloadRoot)
return signalPassFailure();
- auto debugBindNames = llvm::map_to_vector(
- debugBindTrailingArgs,
- [&](const std::string &name) { return OperationName(name, context); });
- SmallVector<SmallVector<Operation *>, 2> trailingBindings;
- trailingBindings.resize(debugBindNames.size());
- payloadRoot->walk([&](Operation *payload) {
- for (auto &&[position, name] : llvm::enumerate(debugBindNames)) {
- if (payload->getName() == name)
- trailingBindings[position].push_back(payload);
- }
- });
Operation *transformEntryPoint = transform::detail::findTransformEntryPoint(
getOperation(), transformModule, entryPoint);
- if (!transformEntryPoint) {
- getOperation()->emitError()
- << "could not find transform entry point: " << entryPoint
- << " in either payload or transform module";
+ if (!transformEntryPoint)
return signalPassFailure();
- }
-
- RaggedArray<transform::MappedValue> bindings;
- bindings.push_back(ArrayRef<Operation *>{payloadRoot});
- for (SmallVector<Operation *> &trailing : trailingBindings)
- bindings.push_back(std::move(trailing));
+ std::optional<RaggedArray<transform::MappedValue>> bindings =
+ parseArguments(payloadRoot);
+ if (!bindings)
+ return signalPassFailure();
if (failed(transform::applyTransformNamedSequence(
- bindings,
+ *bindings,
cast<transform::TransformOpInterface>(transformEntryPoint),
transformModule,
options.enableExpensiveChecks(!disableExpensiveChecks)))) {
diff --git a/mlir/test/Dialect/Transform/include/test-interpreter-external-concurrent-source.mlir b/mlir/test/Dialect/Transform/include/test-interpreter-external-concurrent-source.mlir
index 316b90f85236e4..255ff5f31ed3f5 100644
--- a/mlir/test/Dialect/Transform/include/test-interpreter-external-concurrent-source.mlir
+++ b/mlir/test/Dialect/Transform/include/test-interpreter-external-concurrent-source.mlir
@@ -1,16 +1,21 @@
// RUN: mlir-opt %s
// No need to check anything else than parsing here, this is being used by another test as data.
-transform.with_pdl_patterns {
-^bb0(%arg0: !transform.any_op):
- pdl.pattern @func_return : benefit(1) {
- %0 = pdl.operation "func.return"
- pdl.rewrite %0 with "transform.dialect"
- }
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%root: !transform.any_op) {
+ transform.with_pdl_patterns %root : !transform.any_op {
+ ^bb0(%arg0: !transform.any_op):
+ pdl.pattern @func_return : benefit(1) {
+ %0 = pdl.operation "func.return"
+ pdl.rewrite %0 with "transform.dialect"
+ }
- sequence %arg0 : !transform.any_op failures(propagate) {
- ^bb1(%arg1: !transform.any_op):
- %0 = pdl_match @func_return in %arg1 : (!transform.any_op) -> !transform.op<"func.return">
- transform.debug.emit_remark_at %0, "matched" : !transform.op<"func.return">
+ sequence %arg0 : !transform.any_op failures(propagate) {
+ ^bb1(%arg1: !transform.any_op):
+ %0 = pdl_match @func_return in %arg1 : (!transform.any_op) -> !transform.op<"func.return">
+ transform.debug.emit_remark_at %0, "matched" : !transform.op<"func.return">
+ }
+ }
+ transform.yield
}
}
diff --git a/mlir/test/Dialect/Transform/include/test-interpreter-external-source.mlir b/mlir/test/Dialect/Transform/include/test-interpreter-external-source.mlir
index 5956c86ebbe4b2..f6b7f787cc2c38 100644
--- a/mlir/test/Dialect/Transform/include/test-interpreter-external-source.mlir
+++ b/mlir/test/Dialect/Transform/include/test-interpreter-external-source.mlir
@@ -1,11 +1,13 @@
// RUN: mlir-opt %s
// No need to check anything else than parsing here, this is being used by another test as data.
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op):
- transform.debug.emit_remark_at %arg0, "outer" : !transform.any_op
- transform.sequence %arg0 : !transform.any_op failures(propagate) attributes {transform.target_tag="transform"} {
- ^bb1(%arg1: !transform.any_op):
- transform.debug.emit_remark_at %arg1, "inner" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
+ transform.debug.emit_remark_at %arg0, "outer" : !transform.any_op
+ transform.sequence %arg0 : !transform.any_op failures(propagate) attributes {transform.target_tag="transform"} {
+ ^bb1(%arg1: !transform.any_op):
+ transform.debug.emit_remark_at %arg1, "inner" : !transform.any_op
+ }
+ transform.yield
}
}
diff --git a/mlir/test/Dialect/Transform/multi-arg-top-level-ops.mlir b/mlir/test/Dialect/Transform/multi-arg-top-level-ops.mlir
index 9a7e7ca2f9536e..1c018b1b1f7796 100644
--- a/mlir/test/Dialect/Transform/multi-arg-top-level-ops.mlir
+++ b/mlir/test/Dialect/Transform/multi-arg-top-level-ops.mlir
@@ -1,10 +1,15 @@
-// RUN: mlir-opt %s --pass-pipeline='builtin.module(test-transform-dialect-interpreter{bind-first-extra-to-ops=func.func bind-second-extra-to-ops=func.return})' \
-// RUN: --split-input-file --verify-diagnostics
+// RUN: mlir-opt %s --pass-pipeline="builtin.module(transform-interpreter{\
+// RUN: debug-bind-trailing-args=func.func,func.return})" \
+// RUN: --split-input-file --verify-diagnostics
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_op):
- transform.debug.emit_remark_at %arg1, "first extra" : !transform.any_op
- transform.debug.emit_remark_at %arg2, "second extra" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_op,
+ %arg2: !transform.any_op) {
+ transform.debug.emit_remark_at %arg1, "first extra" : !transform.any_op
+ transform.debug.emit_remark_at %arg2, "second extra" : !transform.any_op
+ transform.yield
+ }
}
// expected-remark @below {{first extra}}
@@ -26,9 +31,13 @@ func.func @bar(%arg0: i1) {
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.param<i64>):
- // expected-error @above {{wrong kind of value provided for top-level parameter}}
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_op,
+ %arg2: !transform.param<i64>) {
+ // expected-error @above {{wrong kind of value provided for top-level parameter}}
+ transform.yield
+ }
}
func.func @foo() {
@@ -37,9 +46,13 @@ func.func @foo() {
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_value):
- // expected-error @above {{wrong kind of value provided for the top-level value handle}}
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_op,
+ %arg2: !transform.any_value) {
+ // expected-error @above {{wrong kind of value provided for the top-level value handle}}
+ transform.yield
+ }
}
func.func @foo() {
@@ -48,19 +61,27 @@ func.func @foo() {
// -----
-// expected-error @below {{operation expects 1 extra value bindings, but 2 were provided to the interpreter}}
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op):
+
+module attributes {transform.with_named_sequence} {
+ // expected-error @below {{operation expects 1 extra value bindings, but 2 were provided to the interpreter}}
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_op) {
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_op):
- transform.sequence %arg0, %arg1, %arg2 : !transform.any_op, !transform.any_op, !transform.any_op failures(propagate) {
- ^bb0(%arg3: !transform.any_op, %arg4: !transform.any_op, %arg5: !transform.any_op):
- transform.debug.emit_remark_at %arg4, "first extra" : !transform.any_op
- transform.debug.emit_remark_at %arg5, "second extra" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_op,
+ %arg2: !transform.any_op) {
+ transform.sequence %arg0, %arg1, %arg2 : !transform.any_op, !transform.any_op, !transform.any_op failures(propagate) {
+ ^bb0(%arg3: !transform.any_op, %arg4: !transform.any_op, %arg5: !transform.any_op):
+ transform.debug.emit_remark_at %arg4, "first extra" : !transform.any_op
+ transform.debug.emit_remark_at %arg5, "second extra" : !transform.any_op
+ }
+ transform.yield
}
}
diff --git a/mlir/test/Dialect/Transform/multi-arg-top-level-params.mlir b/mlir/test/Dialect/Transform/multi-arg-top-level-params.mlir
index f59a4b6d4ccc32..6486bcae3294e4 100644
--- a/mlir/test/Dialect/Transform/multi-arg-top-level-params.mlir
+++ b/mlir/test/Dialect/Transform/multi-arg-top-level-params.mlir
@@ -1,24 +1,37 @@
-// RUN: mlir-opt %s --pass-pipeline='builtin.module(test-transform-dialect-interpreter{bind-first-extra-to-params=1,2,3 bind-second-extra-to-params=42,45})' \
+// RUN: mlir-opt %s --pass-pipeline='builtin.module(transform-interpreter{\
+// RUN: debug-bind-trailing-args=#1;2;3,#42;45})' \
// RUN: --split-input-file --verify-diagnostics
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.param<i64>, %arg2: !transform.param<i64>):
- // expected-remark @below {{1 : i64, 2 : i64, 3 : i64}}
- transform.debug.emit_param_as_remark %arg1 : !transform.param<i64>
- // expected-remark @below {{42 : i64, 45 : i64}}
- transform.debug.emit_param_as_remark %arg2 : !transform.param<i64>
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.param<i64>,
+ %arg2: !transform.param<i64>) {
+ // expected-remark @below {{1 : i64, 2 : i64, 3 : i64}}
+ transform.debug.emit_param_as_remark %arg1 : !transform.param<i64>
+ // expected-remark @below {{42 : i64, 45 : i64}}
+ transform.debug.emit_param_as_remark %arg2 : !transform.param<i64>
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.param<i64>):
- // expected-error @above {{wrong kind of value provided for top-level operation handle}}
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_op,
+ // expected-error @above {{wrong kind of value provided for top-level operation handle}}
+ %arg2: !transform.param<i64>) {
+ transform.yield
+ }
}
// -----
-// expected-error @below {{operation expects 3 extra value bindings, but 2 were provided to the interpreter}}
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.param<i64>, %arg2: !transform.param<i64>, %arg3: !transform.param<i64>):
+module attributes {transform.with_named_sequence} {
+ // expected-error @below {{operation expects 3 extra value bindings, but 2 were provided to the interpreter}}
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.param<i64>,
+ %arg2: !transform.param<i64>, %arg3: !transform.param<i64>) {
+ transform.yield
+ }
}
diff --git a/mlir/test/Dialect/Transform/multi-arg-top-level-values.mlir b/mlir/test/Dialect/Transform/multi-arg-top-level-values.mlir
index 38d7e28697774d..dcc1079267dc7c 100644
--- a/mlir/test/Dialect/Transform/multi-arg-top-level-values.mlir
+++ b/mlir/test/Dialect/Transform/multi-arg-top-level-values.mlir
@@ -1,4 +1,5 @@
-// RUN: mlir-opt %s --pass-pipeline='builtin.module(test-transform-dialect-interpreter{bind-first-extra-to-results-of-ops=test.some_returning_op bind-second-extra-to-results-of-ops=test.some_other_returning_op})' \
+// RUN: mlir-opt %s --pass-pipeline='builtin.module(transform-interpreter{\
+// RUN: debug-bind-trailing-args=^test.some_returning_op,^test.some_other_returning_op})' \
// RUN: --split-input-file --verify-diagnostics
// Note that diagnostic checker will merge two diagnostics with the same message
@@ -21,10 +22,14 @@
// expected-note @below {{value handle points to an op result #1}}
%2:2 = "test.some_other_returning_op"() : () -> (f32, f64)
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_value, %arg2: !transform.any_value):
- transform.debug.emit_remark_at %arg1, "first extra" : !transform.any_value
- transform.debug.emit_remark_at %arg2, "second extra" : !transform.any_value
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ %arg0: !transform.any_op, %arg1: !transform.any_value,
+ %arg2: !transform.any_value) {
+ transform.debug.emit_remark_at %arg1, "first extra" : !transform.any_value
+ transform.debug.emit_remark_at %arg2, "second extra" : !transform.any_value
+ transform.yield
+ }
}
// -----
@@ -32,14 +37,19 @@ transform.sequence failures(propagate) {
%0:2 = "test.some_returning_op"() : () -> (i32, i64)
%1 = "test.some_returning_op"() : () -> index
-transform.sequence failures(propagate) {
-// expected-error @below {{wrong kind of value provided for top-level operation handle}}
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_value):
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(
+ // expected-error @below {{wrong kind of value provided for top-level operation handle}}
+ %arg0: !transform.any_op, %arg1: !transform.any_op, %arg2: !transform.any_value) {
+ transform.yield
+ }
}
// -----
-// expected-error @below {{operation expects 1 extra value bindings, but 2 were provided to the interpreter}}
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op, %arg1: !transform.any_value):
+module attributes {transform.with_named_sequence} {
+ // expected-error @below {{operation expects 1 extra value bindings, but 2 were provided to the interpreter}}
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op, %arg1: !transform.any_value) {
+ transform.yield
+ }
}
diff --git a/mlir/test/Dialect/Transform/test-interpreter-debug.mlir b/mlir/test/Dialect/Transform/test-interpreter-debug.mlir
index c7dad582dd432c..99301ea23c6f8d 100644
--- a/mlir/test/Dialect/Transform/test-interpreter-debug.mlir
+++ b/mlir/test/Dialect/Transform/test-interpreter-debug.mlir
@@ -1,19 +1,21 @@
-// RUN: mlir-opt %s --pass-pipeline="builtin.module(test-transform-dialect-interpreter{debug-payload-root-tag=payload debug-transform-root-tag=transform})" \
-// RUN: --allow-unregistered-dialect --split-input-file --verify-diagnostics
+// RUN: mlir-opt %s --pass-pipeline="builtin.module(transform-interpreter{\
+// RUN: debug-payload-root-tag=payload \
+// RUN: entry-point=transform})" \
+// RUN: --allow-unregistered-dialect --split-input-file --verify-diagnostics
// expected-error @below {{could not find the operation with transform.target_tag="payload" attribute}}
-module {
- transform.sequence failures(suppress) {
- ^bb0(%arg0: !transform.any_op):
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @transform(%arg0: !transform.any_op) {
+ transform.yield
}
}
// -----
-// expected-error @below {{could not find the operation with transform.target_tag="transform" attribute}}
-module {
- transform.sequence failures(suppress) {
- ^bb0(%arg0: !transform.any_op):
+// expected-error @below {{could not find a nested named sequence with name: transform}}
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @not_transform(%arg0: !transform.any_op) {
+ transform.yield
}
module attributes {transform.target_tag="payload"} {}
@@ -21,42 +23,16 @@ module {
// -----
-// expected-error @below {{more than one operation with transform.target_tag="transform" attribute}}
-module {
- // expected-note @below {{first operation}}
- transform.sequence failures(propagate) attributes {transform.target_tag="transform"} {
- ^bb0(%arg0: !transform.any_op):
- }
-
- // expected-note @below {{other operation}}
- transform.sequence failures(propagate) attributes {transform.target_tag="transform"} {
- ^bb0(%arg0: !transform.any_op):
- }
-
- module attributes {transform.target_tag="payload"} {}
-}
-
-// -----
-
-module {
- // expected-error @below {{expected the transform entry point to be a top-level transform op}}
- func.func private @foo() attributes {transform.target_tag="transform"}
-
- module attributes {transform.target_tag="payload"} {}
-}
-
-// -----
-
-module {
- transform.sequence failures(suppress) attributes {transform.target_tag="transform"} {
- ^bb0(%arg0: !transform.any_op):
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @transform(%arg0: !transform.any_op) {
transform.debug.emit_remark_at %arg0, "payload" : !transform.any_op
+ transform.yield
}
- // This will not be executed because it's not tagged.
- transform.sequence failures(suppress) {
- ^bb0(%arg0: !transform.any_op):
+ // This will not be executed.
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
transform.debug.emit_remark_at %arg0, "some other text that is not printed" : !transform.any_op
+ transform.yield
}
module {
diff --git a/mlir/test/Dialect/Transform/test-interpreter-external-concurrent.mlir b/mlir/test/Dialect/Transform/test-interpreter-external-concurrent.mlir
index 59c2b672a6e6b1..9884102c6c0ff5 100644
--- a/mlir/test/Dialect/Transform/test-interpreter-external-concurrent.mlir
+++ b/mlir/test/Dialect/Transform/test-interpreter-external-concurrent.mlir
@@ -1,4 +1,6 @@
-// RUN: mlir-opt %s --pass-pipeline="builtin.module(func.func(test-transform-dialect-interpreter{transform-file-name=%p%{fs-sep}include%{fs-sep}test-interpreter-external-concurrent-source.mlir}))" \
+// RUN: mlir-opt %s --pass-pipeline="builtin.module(\
+// RUN: transform-preload-library{transform-library-paths=%p%{fs-sep}include%{fs-sep}test-interpreter-external-concurrent-source.mlir},\
+// RUN: func.func(transform-interpreter))" \
// RUN: --verify-diagnostics
// Exercising the pass on multiple functions of different lengths that may be
diff --git a/mlir/test/Dialect/Transform/test-interpreter-external.mlir b/mlir/test/Dialect/Transform/test-interpreter-external.mlir
index ba8e0c6870dbf8..599ce05fcc40b1 100644
--- a/mlir/test/Dialect/Transform/test-interpreter-external.mlir
+++ b/mlir/test/Dialect/Transform/test-interpreter-external.mlir
@@ -1,4 +1,6 @@
-// RUN: mlir-opt %s --pass-pipeline="builtin.module(test-transform-dialect-interpreter{transform-file-name=%p%{fs-sep}include%{fs-sep}test-interpreter-external-source.mlir})" \
+// RUN: mlir-opt %s --pass-pipeline="builtin.module(\
+// RUN: transform-preload-library{transform-library-paths=%p%{fs-sep}include%{fs-sep}test-interpreter-external-source.mlir},\
+// RUN: transform-interpreter)" \
// RUN: --verify-diagnostics
// The schedule in the separate file emits remarks at the payload root.
diff --git a/mlir/test/Dialect/Transform/test-interpreter.mlir b/mlir/test/Dialect/Transform/test-interpreter.mlir
index de5807b2874b27..b6850e2024d53d 100644
--- a/mlir/test/Dialect/Transform/test-interpreter.mlir
+++ b/mlir/test/Dialect/Transform/test-interpreter.mlir
@@ -1411,7 +1411,6 @@ module attributes {transform.with_named_sequence} {
// -----
// expected-error @below {{could not find a nested named sequence with name: __transform_main}}
-// expected-error @below {{could not find transform entry point: __transform_main in either payload or transform module}}
module {
}
diff --git a/mlir/test/Dialect/Transform/test-pass-application.mlir b/mlir/test/Dialect/Transform/test-pass-application.mlir
index 65625457c86898..7cb5387b937d45 100644
--- a/mlir/test/Dialect/Transform/test-pass-application.mlir
+++ b/mlir/test/Dialect/Transform/test-pass-application.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s --test-transform-dialect-interpreter -allow-unregistered-dialect --split-input-file --verify-diagnostics | FileCheck %s
+// RUN: mlir-opt %s --transform-interpreter -allow-unregistered-dialect --split-input-file --verify-diagnostics | FileCheck %s
// CHECK-LABEL: func @successful_pass_application(
// CHECK: %[[c5:.*]] = arith.constant 5 : index
@@ -9,10 +9,12 @@ func.func @successful_pass_application(%t: tensor<5xf32>) -> index {
return %dim : index
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_registered_pass "canonicalize" to %1 : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_registered_pass "canonicalize" to %1 : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -22,12 +24,14 @@ func.func @pass_pipeline() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // This pipeline does not do anything. Just make sure that the pipeline is
- // found and no error is produced.
- transform.apply_registered_pass "test-options-pass-pipeline" to %1 : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // This pipeline does not do anything. Just make sure that the pipeline is
+ // found and no error is produced.
+ transform.apply_registered_pass "test-options-pass-pipeline" to %1 : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -36,11 +40,13 @@ func.func @invalid_pass_name() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-error @below {{unknown pass or pass pipeline: non-existing-pass}}
- transform.apply_registered_pass "non-existing-pass" to %1 : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below {{unknown pass or pass pipeline: non-existing-pass}}
+ transform.apply_registered_pass "non-existing-pass" to %1 : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -53,11 +59,13 @@ func.func @not_isolated_from_above(%t: tensor<5xf32>) -> index {
return %dim : index
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["tensor.dim"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-error @below {{pass pipeline failed}}
- transform.apply_registered_pass "canonicalize" to %1 : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["tensor.dim"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below {{pass pipeline failed}}
+ transform.apply_registered_pass "canonicalize" to %1 : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -66,11 +74,13 @@ func.func @invalid_pass_option() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-error @below {{failed to add pass or pass pipeline to pipeline: canonicalize}}
- transform.apply_registered_pass "canonicalize" to %1 {options = "invalid-option=1"} : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below {{failed to add pass or pass pipeline to pipeline: canonicalize}}
+ transform.apply_registered_pass "canonicalize" to %1 {options = "invalid-option=1"} : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -80,27 +90,29 @@ func.func @valid_pass_option() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_registered_pass "canonicalize" to %1 {options = "top-down=false"} : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_registered_pass "canonicalize" to %1 {options = "top-down=false"} : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
-module {
+module attributes {transform.with_named_sequence} {
// expected-error @below {{trying to schedule a pass on an unsupported operation}}
// expected-note @below {{target op}}
func.func @invalid_target_op_type() {
return
}
- transform.sequence failures(propagate) {
- ^bb1(%arg1: !transform.any_op):
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
%1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
// func-bufferize can be applied only to ModuleOps.
// expected-error @below {{pass pipeline failed}}
transform.apply_registered_pass "func-bufferize" to %1 : (!transform.any_op) -> !transform.any_op
+ transform.yield
}
}
diff --git a/mlir/test/Dialect/Transform/test-pattern-application.mlir b/mlir/test/Dialect/Transform/test-pattern-application.mlir
index 10cd9ef351fe54..0c41e81b17b522 100644
--- a/mlir/test/Dialect/Transform/test-pattern-application.mlir
+++ b/mlir/test/Dialect/Transform/test-pattern-application.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s --test-transform-dialect-interpreter -allow-unregistered-dialect --split-input-file --verify-diagnostics | FileCheck %s
+// RUN: mlir-opt %s --transform-interpreter -allow-unregistered-dialect --split-input-file --verify-diagnostics | FileCheck %s
// CHECK-LABEL: func @update_tracked_op_mapping()
// CHECK: "test.container"() ({
@@ -11,15 +11,17 @@ func.func @update_tracked_op_mapping() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_patterns to %0 {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
- // Add an attribute to %1, which is now mapped to a new op.
- transform.annotate %1 "annotated" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_patterns to %0 {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ // Add an attribute to %1, which is now mapped to a new op.
+ transform.annotate %1 "annotated" : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -33,19 +35,21 @@ func.func @replacement_op_not_found() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-note @below {{replacement is required because this handle must be updated}}
- %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-error @below {{tracking listener failed to find replacement op during application of this transform op}}
- // expected-note @below {{ran out of suitable replacement values}}
- transform.apply_patterns to %0 {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
- // %1 must be used in some way. If no replacement payload op could be found,
- // an error is thrown only if the handle is not dead.
- transform.annotate %1 "annotated" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-note @below {{replacement is required because this handle must be updated}}
+ %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below {{tracking listener failed to find replacement op during application of this transform op}}
+ // expected-note @below {{ran out of suitable replacement values}}
+ transform.apply_patterns to %0 {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ // %1 must be used in some way. If no replacement payload op could be found,
+ // an error is thrown only if the handle is not dead.
+ transform.annotate %1 "annotated" : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -61,14 +65,16 @@ func.func @replacement_op_for_dead_handle_not_found() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // No error because %1 is dead.
- transform.apply_patterns to %0 {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // No error because %1 is dead.
+ transform.apply_patterns to %0 {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -84,14 +90,16 @@ func.func @replacement_op_not_found_silenced() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_patterns to %0 {
- transform.apply_patterns.transform.test_patterns
- } {transform.silence_tracking_failures} : !transform.any_op
- transform.annotate %1 "annotated" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_patterns to %0 {
+ transform.apply_patterns.transform.test_patterns
+ } {transform.silence_tracking_failures} : !transform.any_op
+ transform.annotate %1 "annotated" : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -103,12 +111,14 @@ func.func @patterns_apply_only_to_target_body() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
-%0 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_patterns to %0 {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_patterns to %0 {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -125,16 +135,18 @@ func.func @erase_tracked_op() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["test.erase_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.debug.emit_remark_at %1, "matched op" : !transform.any_op
- transform.apply_patterns to %0 {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
- // No marker should be printed.
- transform.debug.emit_remark_at %1, "op was deleted" : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["test.erase_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.debug.emit_remark_at %1, "matched op" : !transform.any_op
+ transform.apply_patterns to %0 {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ // No marker should be printed.
+ transform.debug.emit_remark_at %1, "op was deleted" : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -143,7 +155,7 @@ transform.sequence failures(propagate) {
// CHECK: "test.container"() ({
// CHECK-NEXT: ^bb0:
// CHECK-NEXT: }) : () -> ()
-module {
+module attributes {transform.with_named_sequence} {
func.func @erase_tracked_op_in_named_sequence() {
"test.container"() ({
// expected-remark @below {{matched op}}
@@ -152,23 +164,21 @@ module {
return
}
- module attributes { transform.with_named_sequence } {
- transform.named_sequence @foo(%arg0: !transform.any_op {transform.readonly}) -> () {
- transform.apply_patterns to %arg0 {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
- transform.yield
- }
+ transform.named_sequence @foo(%arg0: !transform.any_op {transform.readonly}) -> () {
+ transform.apply_patterns to %arg0 {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ transform.yield
+ }
- transform.sequence failures(propagate) {
- ^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["test.erase_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.debug.emit_remark_at %1, "matched op" : !transform.any_op
- include @foo failures(propagate) (%0) : (!transform.any_op) -> ()
- // No marker should be printed.
- transform.debug.emit_remark_at %1, "op was deleted" : !transform.any_op
- }
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["test.erase_op"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.debug.emit_remark_at %1, "matched op" : !transform.any_op
+ transform.include @foo failures(propagate) (%0) : (!transform.any_op) -> ()
+ // No marker should be printed.
+ transform.debug.emit_remark_at %1, "op was deleted" : !transform.any_op
+ transform.yield
}
}
@@ -183,13 +193,15 @@ func.func @canonicalization(%t: tensor<5xf32>) -> index {
return %dim : index
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["tensor.dim"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_patterns to %1 {
- transform.apply_patterns.canonicalization
- } : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["tensor.dim"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_patterns to %1 {
+ transform.apply_patterns.canonicalization
+ } : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -200,13 +212,13 @@ module {
return
}
- module {
- transform.sequence failures(propagate) {
- ^bb1(%arg1: !transform.any_op):
+ module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
// expected-error @below {{cannot apply transform to itself (or one of its ancestors)}}
transform.apply_patterns to %arg1 {
transform.apply_patterns.canonicalization
} : !transform.any_op
+ transform.yield
}
}
}
@@ -224,12 +236,14 @@ func.func @canonicalization_and_cse(%m: memref<5xf32>) {
return
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_patterns to %1 {
- transform.apply_patterns.canonicalization
- } {apply_cse} : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %1 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_patterns to %1 {
+ transform.apply_patterns.canonicalization
+ } {apply_cse} : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -243,15 +257,17 @@ func.func @full_dialect_conversion() -> tensor<5xf32> {
return %0 : tensor<5xf32>
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_conversion_patterns to %0 {
- transform.apply_conversion_patterns.transform.test_conversion_patterns
- } with type_converter {
- transform.apply_conversion_patterns.transform.test_type_converter
- } {legal_ops = ["func.func", "func.return", "test.new_op"]}
- : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_conversion_patterns to %0 {
+ transform.apply_conversion_patterns.transform.test_conversion_patterns
+ } with type_converter {
+ transform.apply_conversion_patterns.transform.test_type_converter
+ } {legal_ops = ["func.func", "func.return", "test.new_op"]}
+ : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -266,16 +282,18 @@ func.func @full_dialect_conversion_failed() -> tensor<5xf32> {
return %0 : tensor<5xf32>
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-error @below{{dialect conversion failed}}
- transform.apply_conversion_patterns to %0 {
- transform.apply_conversion_patterns.transform.test_conversion_patterns
- } with type_converter {
- transform.apply_conversion_patterns.transform.test_type_converter
- } {legal_ops = ["func.func", "func.return", "test.new_op"]}
- : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below{{dialect conversion failed}}
+ transform.apply_conversion_patterns to %0 {
+ transform.apply_conversion_patterns.transform.test_conversion_patterns
+ } with type_converter {
+ transform.apply_conversion_patterns.transform.test_type_converter
+ } {legal_ops = ["func.func", "func.return", "test.new_op"]}
+ : !transform.any_op
+ transform.yield
+ }
}
// -----
@@ -294,98 +312,108 @@ func.func @partial_dialect_conversion() -> tensor<5xf32> {
return %0 : tensor<5xf32>
}
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_conversion_patterns to %0 {
- transform.apply_conversion_patterns.transform.test_conversion_patterns
- } with type_converter {
- transform.apply_conversion_patterns.transform.test_type_converter
- } {legal_ops = ["func.func", "func.return", "test.new_op"],
- partial_conversion} : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_conversion_patterns to %0 {
+ transform.apply_conversion_patterns.transform.test_conversion_patterns
+ } with type_converter {
+ transform.apply_conversion_patterns.transform.test_type_converter
+ } {legal_ops = ["func.func", "func.return", "test.new_op"],
+ partial_conversion} : !transform.any_op
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- // expected-error @below{{pattern descriptor does not specify type converter and apply_conversion_patterns op has no default type converter}}
- transform.apply_conversion_patterns to %0 {
- // expected-note @below{{pattern descriptor op}}
- transform.apply_conversion_patterns.transform.test_conversion_patterns
- } {illegal_ops = ["test.foo"]} : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below{{pattern descriptor does not specify type converter and apply_conversion_patterns op has no default type converter}}
+ transform.apply_conversion_patterns to %0 {
+ // expected-note @below{{pattern descriptor op}}
+ transform.apply_conversion_patterns.transform.test_conversion_patterns
+ } {illegal_ops = ["test.foo"]} : !transform.any_op
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_conversion_patterns to %0 {
- // expected-error @below{{expected LLVMTypeConverter}}
- transform.apply_conversion_patterns.dialect_to_llvm "test"
- } with type_converter {
- transform.apply_conversion_patterns.transform.test_type_converter
- } {illegal_ops = ["test.foo"],
- legal_ops = ["func.func", "func.return", "test.new_op"]}
- : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_conversion_patterns to %0 {
+ // expected-error @below{{expected LLVMTypeConverter}}
+ transform.apply_conversion_patterns.dialect_to_llvm "test"
+ } with type_converter {
+ transform.apply_conversion_patterns.transform.test_type_converter
+ } {illegal_ops = ["test.foo"],
+ legal_ops = ["func.func", "func.return", "test.new_op"]}
+ : !transform.any_op
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_conversion_patterns to %0 {
- // expected-error @below{{unknown dialect or dialect not loaded: this_dialect_does_not_exist}}
- transform.apply_conversion_patterns.dialect_to_llvm "this_dialect_does_not_exist"
- } with type_converter {
- transform.apply_conversion_patterns.memref.memref_to_llvm_type_converter
- } {illegal_ops = ["test.foo"],
- legal_ops = ["func.func", "func.return", "test.new_op"]}
- : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_conversion_patterns to %0 {
+ // expected-error @below{{unknown dialect or dialect not loaded: this_dialect_does_not_exist}}
+ transform.apply_conversion_patterns.dialect_to_llvm "this_dialect_does_not_exist"
+ } with type_converter {
+ transform.apply_conversion_patterns.memref.memref_to_llvm_type_converter
+ } {illegal_ops = ["test.foo"],
+ legal_ops = ["func.func", "func.return", "test.new_op"]}
+ : !transform.any_op
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.apply_conversion_patterns to %0 {
- // expected-error @below{{dialect does not implement ConvertToLLVMPatternInterface or extension was not loaded: transform}}
- transform.apply_conversion_patterns.dialect_to_llvm "transform"
- } with type_converter {
- transform.apply_conversion_patterns.memref.memref_to_llvm_type_converter
- } {illegal_ops = ["test.foo"],
- legal_ops = ["func.func", "func.return", "test.new_op"]}
- : !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.apply_conversion_patterns to %0 {
+ // expected-error @below{{dialect does not implement ConvertToLLVMPatternInterface or extension was not loaded: transform}}
+ transform.apply_conversion_patterns.dialect_to_llvm "transform"
+ } with type_converter {
+ transform.apply_conversion_patterns.memref.memref_to_llvm_type_converter
+ } {illegal_ops = ["test.foo"],
+ legal_ops = ["func.func", "func.return", "test.new_op"]}
+ : !transform.any_op
+ transform.yield
+ }
}
// -----
module attributes { transform.with_named_sequence } {
-func.func @replacement_op_not_found() {
- // No op replacement can be found, but there are no handles that must be
- // updated. No error should be reported.
- "test.container"() ({
- %0 = "test.foo"() {replace_with_new_op = "test.bar"} : () -> (i32)
- }) : () -> ()
- return
-}
+ func.func @replacement_op_not_found() {
+ // No op replacement can be found, but there are no handles that must be
+ // updated. No error should be reported.
+ "test.container"() ({
+ %0 = "test.foo"() {replace_with_new_op = "test.bar"} : () -> (i32)
+ }) : () -> ()
+ return
+ }
-transform.named_sequence @patterns(%container: !transform.any_op {transform.readonly}) {
- transform.apply_patterns to %container {
- transform.apply_patterns.transform.test_patterns
- } : !transform.any_op
- transform.yield
-}
+ transform.named_sequence @patterns(%container: !transform.any_op {transform.readonly}) {
+ transform.apply_patterns to %container {
+ transform.apply_patterns.transform.test_patterns
+ } : !transform.any_op
+ transform.yield
+ }
-transform.sequence failures(propagate) {
-^bb1(%arg1: !transform.any_op):
- %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.annotate %1 "annotated" : !transform.any_op
- transform.include @patterns failures(propagate) (%0) : (!transform.any_op) -> ()
-}
+ transform.named_sequence @__transform_main(%arg1: !transform.any_op) {
+ %0 = transform.structured.match ops{["test.container"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["test.foo"]} in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.annotate %1 "annotated" : !transform.any_op
+ transform.include @patterns failures(propagate) (%0) : (!transform.any_op) -> ()
+ transform.yield
+ }
}
diff --git a/mlir/test/Dialect/Transform/test-pdl-extension.mlir b/mlir/test/Dialect/Transform/test-pdl-extension.mlir
index a9710f75531262..a3349c1ba50594 100644
--- a/mlir/test/Dialect/Transform/test-pdl-extension.mlir
+++ b/mlir/test/Dialect/Transform/test-pdl-extension.mlir
@@ -1,21 +1,26 @@
-// RUN: mlir-opt %s --test-transform-dialect-interpreter -allow-unregistered-dialect --split-input-file --verify-diagnostics
-
-transform.with_pdl_patterns {
-^bb0(%arg0: !transform.any_op):
- sequence %arg0 : !transform.any_op failures(propagate) {
- ^bb0(%arg1: !transform.any_op):
- %0 = pdl_match @some in %arg1 : (!transform.any_op) -> !transform.any_op
- transform.debug.emit_remark_at %0, "matched" : !transform.any_op
- }
-
- pdl.pattern @some : benefit(1) {
- %0 = pdl.operation "test.some_op"
- pdl.rewrite %0 with "transform.dialect"
- }
-
- pdl.pattern @other : benefit(1) {
- %0 = pdl.operation "test.other_op"
- pdl.rewrite %0 with "transform.dialect"
+// RUN: mlir-opt %s --transform-interpreter -allow-unregistered-dialect --split-input-file --verify-diagnostics
+
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%root: !transform.any_op) {
+ transform.with_pdl_patterns %root : !transform.any_op {
+ ^bb0(%arg0: !transform.any_op):
+ sequence %arg0 : !transform.any_op failures(propagate) {
+ ^bb0(%arg1: !transform.any_op):
+ %0 = pdl_match @some in %arg1 : (!transform.any_op) -> !transform.any_op
+ transform.debug.emit_remark_at %0, "matched" : !transform.any_op
+ }
+
+ pdl.pattern @some : benefit(1) {
+ %0 = pdl.operation "test.some_op"
+ pdl.rewrite %0 with "transform.dialect"
+ }
+
+ pdl.pattern @other : benefit(1) {
+ %0 = pdl.operation "test.other_op"
+ pdl.rewrite %0 with "transform.dialect"
+ }
+ }
+ transform.yield
}
}
@@ -28,17 +33,22 @@ transform.with_pdl_patterns {
// -----
-transform.with_pdl_patterns {
-^bb0(%arg0: !transform.any_op):
- sequence %arg0 : !transform.any_op failures(propagate) {
- ^bb1(%arg1: !transform.any_op):
- %0 = pdl_match @some in %arg1 : (!transform.any_op) -> !transform.any_op
- }
-
- pdl.pattern @some : benefit(1) {
- %0 = pdl.operation "test.some_op"
- pdl.apply_native_constraint "verbose_constraint"(%0 : !pdl.operation)
- pdl.rewrite %0 with "transform.dialect"
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%root: !transform.any_op) {
+ transform.with_pdl_patterns %root : !transform.any_op {
+ ^bb0(%arg0: !transform.any_op):
+ sequence %arg0 : !transform.any_op failures(propagate) {
+ ^bb1(%arg1: !transform.any_op):
+ %0 = pdl_match @some in %arg1 : (!transform.any_op) -> !transform.any_op
+ }
+
+ pdl.pattern @some : benefit(1) {
+ %0 = pdl.operation "test.some_op"
+ pdl.apply_native_constraint "verbose_constraint"(%0 : !pdl.operation)
+ pdl.rewrite %0 with "transform.dialect"
+ }
+ }
+ transform.yield
}
}
diff --git a/mlir/test/Dialect/Transform/transform-state-extension.mlir b/mlir/test/Dialect/Transform/transform-state-extension.mlir
index a26293fbe51ca6..e8c0b7a8a3aac0 100644
--- a/mlir/test/Dialect/Transform/transform-state-extension.mlir
+++ b/mlir/test/Dialect/Transform/transform-state-extension.mlir
@@ -1,89 +1,95 @@
-// RUN: mlir-opt %s -test-transform-dialect-interpreter -verify-diagnostics -split-input-file
+// RUN: mlir-opt %s -transform-interpreter -verify-diagnostics -split-input-file
// expected-note @below {{associated payload op}}
-module {
- transform.sequence failures(propagate) {
- ^bb0(%arg0: !transform.any_op):
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
// expected-remark @below {{extension absent}}
- test_check_if_test_extension_present %arg0 : !transform.any_op
- test_add_test_extension "A"
+ transform.test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.test_add_test_extension "A"
// expected-remark @below {{extension present, A}}
- test_check_if_test_extension_present %arg0 : !transform.any_op
- test_remove_test_extension
+ transform.test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.test_remove_test_extension
// expected-remark @below {{extension absent}}
- test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.yield
}
}
// -----
// expected-note @below {{associated payload op}}
-module {
- transform.sequence failures(propagate) {
- ^bb0(%arg0: !transform.any_op):
- test_add_test_extension "A"
- test_remove_test_extension
- test_add_test_extension "B"
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
+ transform.test_add_test_extension "A"
+ transform.test_remove_test_extension
+ transform.test_add_test_extension "B"
// expected-remark @below {{extension present, B}}
- test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.yield
}
}
// -----
// expected-note @below {{associated payload op}}
-module {
- transform.sequence failures(propagate) {
- ^bb0(%arg0: !transform.any_op):
- test_add_test_extension "A"
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
+ transform.test_add_test_extension "A"
// expected-remark @below {{extension present, A}}
- test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.test_check_if_test_extension_present %arg0 : !transform.any_op
// expected-note @below {{associated payload op}}
- test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+ transform.test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
// expected-remark @below {{extension present, A}}
- test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.test_check_if_test_extension_present %arg0 : !transform.any_op
+ transform.yield
}
}
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op):
- test_add_test_extension "A"
- // This is okay because we are replacing the top-level module operation
- // (0 results) with this operation that has _more_ (1) results.
- %dummy = test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
+ transform.test_add_test_extension "A"
+ // This is okay because we are replacing the top-level module operation
+ // (0 results) with this operation that has _more_ (1) results.
+ %dummy = transform.test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op):
- test_add_test_extension "A"
- %dummy = test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
- // This is still okay. Even though we are replacing the previous
- // operation with (1 result) with this operation that has less (0) results,
- // there is no handle to the result, hence no issue with value handle update.
- test_remap_operand_to_self %dummy : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
+ transform.test_add_test_extension "A"
+ %dummy = transform.test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+ // This is still okay. Even though we are replacing the previous
+ // operation with (1 result) with this operation that has less (0) results,
+ // there is no handle to the result, hence no issue with value handle update.
+ transform.test_remap_operand_to_self %dummy : (!transform.any_op) -> !transform.any_op
+ transform.yield
+ }
}
// -----
-transform.sequence failures(propagate) {
-^bb0(%arg0: !transform.any_op):
- test_add_test_extension "A"
- // expected-error @below {{cannot replace an op with another op producing fewer results while tracking handles}}
- %dummy = test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
- %valuehandle = transform.get_result %dummy[0] : (!transform.any_op) -> !transform.any_value
- test_remap_operand_to_self %dummy : (!transform.any_op) -> ()
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
+ transform.test_add_test_extension "A"
+ // expected-error @below {{cannot replace an op with another op producing fewer results while tracking handles}}
+ %dummy = transform.test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+ %valuehandle = transform.get_result %dummy[0] : (!transform.any_op) -> !transform.any_value
+ transform.test_remap_operand_to_self %dummy : (!transform.any_op) -> ()
+ transform.yield
+ }
}
// -----
-module {
- transform.sequence failures(suppress) {
- ^bb0(%arg0: !transform.any_op):
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op) {
// expected-error @below {{TestTransformStateExtension missing}}
- test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+ transform.test_remap_operand_to_self %arg0 : (!transform.any_op) -> !transform.any_op
+ transform.yield
}
}
diff --git a/mlir/test/Integration/Dialect/Vector/CPU/ArmSVE/test-contraction.mlir b/mlir/test/Integration/Dialect/Vector/CPU/ArmSVE/test-contraction.mlir
index d86ff56d79e33c..79121bf31c26ed 100644
--- a/mlir/test/Integration/Dialect/Vector/CPU/ArmSVE/test-contraction.mlir
+++ b/mlir/test/Integration/Dialect/Vector/CPU/ArmSVE/test-contraction.mlir
@@ -1,4 +1,4 @@
-// DEFINE: %{compile} = mlir-opt %s -test-transform-dialect-interpreter -test-transform-dialect-erase-schedule\
+// DEFINE: %{compile} = mlir-opt %s -transform-interpreter -test-transform-dialect-erase-schedule\
// DEFINE: -cse -canonicalize -convert-vector-to-scf -arm-sve-legalize-vector-storage\
// DEFINE: -convert-vector-to-llvm="enable-arm-sve" -test-lower-to-llvm -o %t
// DEFINE: %{entry} =
@@ -188,12 +188,14 @@ func.func @matmul_f32() {
return
}
-transform.sequence failures(propagate) {
-^bb1(%module_op: !transform.any_op):
- %f = transform.structured.match ops{["func.func"]} in %module_op
- : (!transform.any_op) -> !transform.any_op
+module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%module_op: !transform.any_op) {
+ %f = transform.structured.match ops{["func.func"]} in %module_op
+ : (!transform.any_op) -> !transform.any_op
- transform.apply_patterns to %f {
- transform.apply_patterns.vector.lower_contraction lowering_strategy = "outerproduct"
- } : !transform.any_op
+ transform.apply_patterns to %f {
+ transform.apply_patterns.vector.lower_contraction lowering_strategy = "outerproduct"
+ } : !transform.any_op
+ transform.yield
+ }
}
>From 9d4ac3abc3d939060a9188736e90708562b178e0 Mon Sep 17 00:00:00 2001
From: Alex Zinenko <zinenko at google.com>
Date: Wed, 28 Feb 2024 09:22:47 +0000
Subject: [PATCH 2/2] document pass in greater detail
---
.../Dialect/Transform/Transforms/Passes.td | 24 +++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/mlir/include/mlir/Dialect/Transform/Transforms/Passes.td b/mlir/include/mlir/Dialect/Transform/Transforms/Passes.td
index 1d6eb24156e334..86a2b3c21faf0d 100644
--- a/mlir/include/mlir/Dialect/Transform/Transforms/Passes.td
+++ b/mlir/include/mlir/Dialect/Transform/Transforms/Passes.td
@@ -66,7 +66,25 @@ def InterpreterPass : Pass<"transform-interpreter"> {
let description = [{
This pass runs the transform dialect interpreter and applies the named
sequence transformation specified by the provided name (defaults to
- `TransformDialect::kTransformEntryPointSymbolName` (i.e. `__transform_main`)).
+ `TransformDialect::kTransformEntryPointSymbolName`,
+ i.e. `__transform_main`).
+
+ Additional options can be used to narrow down the pass applicability for
+ debugging purposes:
+ * `debugPayloadRootTag` makes the transform script apply to the payload
+ operation that has a `transform.target_tag` string attribute with the
+ given value, rather than to the anchor operation of the pass.
+ * `debugBindTrailingArgs` allows one to bind values to trailing arguments
+ of the transform entry point as follows:
+ * arguments of `TransformHandleTypeInterface` type can be bound to all
+ payload operations with the name provided as a simple string;
+ * arguments of `TransformValueHandleTypeInterface` type can be bound to
+ a flattened list of results of all operations with the name provided
+ as a string prefixed with `^`;
+ * arguments of `TransformParamTypeInterface` type can be bound to
+ integer constants provided as `;`-separated list prefixed with `#`.
+ * `entryPoint` specifies the name of the transform symbol to serve as the
+ entry point.
}];
let dependentDialects = ["::mlir::transform::TransformDialect"];
let options = [
@@ -83,7 +101,9 @@ def InterpreterPass : Pass<"transform-interpreter"> {
"false",
"Disable expensive checks in the interpreter for a faster run.">,
Option<"entryPoint", "entry-point", "std::string",
- /*default=*/[{TransformDialect::kTransformEntryPointSymbolName.str()}],
+ /*default=*/[{
+ TransformDialect::kTransformEntryPointSymbolName.str()
+ }],
"Entry point of the pass pipeline.">,
];
}
More information about the Mlir-commits
mailing list