[Mlir-commits] [mlir] [mlir][Transform] Relax the applicability of transform.foreach_match … (PR #70209)

Nicolas Vasilache llvmlistbot at llvm.org
Wed Oct 25 06:44:18 PDT 2023


https://github.com/nicolasvasilache created https://github.com/llvm/llvm-project/pull/70209

…to also take into account the op itself

>From 7687df171e4d193c6973e242b9100d25e298ef6d Mon Sep 17 00:00:00 2001
From: Nicolas Vasilache <nicolas.vasilache at gmail.com>
Date: Wed, 25 Oct 2023 13:43:25 +0000
Subject: [PATCH] [mlir][Transform] Relax the applicability of
 transform.foreach_match to also take into account the op itself

---
 mlir/lib/Dialect/Transform/IR/TransformOps.cpp      | 8 ++------
 mlir/test/Dialect/Linalg/match-ops-interpreter.mlir | 1 +
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index 8db77b6059dd2e3..d39a1847e643cc7 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -850,10 +850,6 @@ transform::ForeachMatchOp::apply(transform::TransformRewriter &rewriter,
 
   for (Operation *root : state.getPayloadOps(getRoot())) {
     WalkResult walkResult = root->walk([&](Operation *op) {
-      // Skip over the root op itself so we don't invalidate it.
-      if (op == root)
-        return WalkResult::advance();
-
       DEBUG_MATCHER({
         DBGS_MATCHER() << "matching ";
         op->print(llvm::dbgs(),
@@ -1556,10 +1552,10 @@ DiagnosedSilenceableFailure transform::MatchOperationEmptyOp::matchOperation(
     ::std::optional<::mlir::Operation *> maybeCurrent,
     transform::TransformResults &results, transform::TransformState &state) {
   if (!maybeCurrent.has_value()) {
-    DBGS_MATCHER() << "MatchOperationEmptyOp success\n";
+    DEBUG_MATCHER({DBGS_MATCHER() << "MatchOperationEmptyOp success\n";});
     return DiagnosedSilenceableFailure::success();
   }
-  DBGS_MATCHER() << "MatchOperationEmptyOp failure\n";
+  DEBUG_MATCHER({ DBGS_MATCHER() << "MatchOperationEmptyOp failure\n"; });
   return emitSilenceableError() << "operation is not empty";
 }
 
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index 9489aadac843d7b..05bfe294754d7c6 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -106,6 +106,7 @@ module attributes { transform.with_named_sequence } {
     transform.yield
   }
 
+  // expected-remark @below {{other}}
   func.func @payload() attributes { transform.target_tag = "start_here" } {
     // expected-remark @below {{other}}
     %D = arith.constant dense<1.0> : tensor<2x4xf32>



More information about the Mlir-commits mailing list