[Mlir-commits] [mlir] [mlir][transform] Fix failure in flattening already flattened linalg ops (PR #86037)

Oleksandr Alex Zinenko llvmlistbot at llvm.org
Thu Mar 21 03:29:56 PDT 2024


================
@@ -3269,15 +3269,20 @@ DiagnosedSilenceableFailure transform::FlattenElementwiseLinalgOp::applyToOne(
     transform::ApplyToEachResultList &results,
     transform::TransformState &state) {
   rewriter.setInsertionPoint(target);
-  if (target.getNumLoops() <= 1)
+  if (!isElementwise(target)) {
+    failed(rewriter.notifyMatchFailure(
+        target, "only elementwise flattening is supported"));
+    return emitDefaultSilenceableFailure(target);
----------------
ftynse wrote:

Instead of sending the error message to the non-existent rewrite driver, this should rather emit it as a silenceable failure! The default failure messages produced by `emitDefaultSilenceableFailure` are extremely unhelpful and must only be used as last resort.

I also haven't seen the usage of `failed` as a way to suppress the compiler warning about `LogicalResult` being unused. The common idiom is to use the C-style cast to void.

https://github.com/llvm/llvm-project/pull/86037


More information about the Mlir-commits mailing list