[Mlir-commits] [mlir] 5228313 - [mlir][linalg][transform] Extend diagnostics of FuseIntoContainingOp.
Ingo Müller
llvmlistbot at llvm.org
Fri Jul 21 02:34:08 PDT 2023
Author: Ingo Müller
Date: 2023-07-21T09:34:04Z
New Revision: 522831384f9051c4e40d26ab8f6d1d0762d4f6aa
URL: https://github.com/llvm/llvm-project/commit/522831384f9051c4e40d26ab8f6d1d0762d4f6aa
DIFF: https://github.com/llvm/llvm-project/commit/522831384f9051c4e40d26ab8f6d1d0762d4f6aa.diff
LOG: [mlir][linalg][transform] Extend diagnostics of FuseIntoContainingOp.
This patch extends the diagnostic output of `FuseIntoContainingOp` when
it fails to find the next producer by also provided the location of the
affected transform op.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D155803
Added:
Modified:
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index 40b602ffd4f80b..859dc7810a79ed 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -919,8 +919,10 @@ transform::FuseIntoContainingOp::apply(transform::TransformRewriter &rewriter,
while (!remainingProducers.empty()) {
auto nextProducer = getNextProducer();
if (failed(nextProducer)) {
- return mlir::emitSilenceableFailure(containingOp->getLoc())
+ auto diag = mlir::emitSilenceableFailure(getLoc())
<< "could not find next producer to fuse into container";
+ diag.attachNote(containingOp->getLoc()) << "containing op";
+ return diag;
}
Operation *producerOp = *nextProducer;
diff --git a/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir b/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir
index 773405e61a4f85..799d21db130049 100644
--- a/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir
+++ b/mlir/test/Dialect/Linalg/transform-op-fuse-into-containing.mlir
@@ -628,3 +628,36 @@ module {
: (!transform.op<"linalg.generic">, !transform.op<"scf.forall">) -> (!transform.any_op, !transform.any_op)
}
}
+
+
+////////////////////////////////////////////////////////////////////////////////
+// Tests below are expected to fail.
+////////////////////////////////////////////////////////////////////////////////
+
+// -----
+
+// NO-CHECK-LABEL-ON-EXPECTED-ERROR
+func.func @copy_1d_1024xf16(%arg0: tensor<123x456xf32>, %arg1: tensor<456x789xf32>, %arg2 : tensor<123x789xf32>) -> tensor<123x789xf32> {
+ %0 = arith.constant 0.000000e+00 : f32
+ %1 = linalg.fill ins(%0 : f32) outs(%arg2 : tensor<123x789xf32>) -> tensor<123x789xf32>
+ // expected-note @below {{containing op}}
+ %2 = linalg.matmul ins(%arg0, %arg1 : tensor<123x456xf32>, tensor<456x789xf32>) outs(%1 : tensor<123x789xf32>) -> tensor<123x789xf32>
+ return %2 : tensor<123x789xf32>
+}
+
+transform.sequence failures(propagate) {
+^bb1(%arg1: !transform.any_op):
+ %0 = transform.structured.match ops{["linalg.fill"]} in %arg1
+ : (!transform.any_op) -> !transform.any_op
+ %1 = transform.structured.match ops{["linalg.matmul"]} in %arg1
+ : (!transform.any_op) -> !transform.any_op
+ %forall_op, %tiled_op = transform.structured.tile_to_forall_op %1
+ num_threads [] tile_sizes [50, 16]
+ : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
+ // Note that we pass in %tiled_op, which isn't a container op.
+ // expected-error @+2 {{could not find next producer to fuse into container}}
+ %fused_op, %new_containing_op =
+ transform.structured.fuse_into_containing_op %0 into %tiled_op
+ : (!transform.any_op, !transform.any_op)
+ -> (!transform.any_op, !transform.any_op)
+}
More information about the Mlir-commits
mailing list