[PATCH] D78936: [mlir][linalg] Fix crash in tileAndFuseLinalgOpToParallelLoopsAndSetMarker

Lei Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 09:06:41 PDT 2020


antiagainst created this revision.
antiagainst added reviewers: nicolasvasilache, mravishankar.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.

Instead of using llvm_unreachable to guard against fusing linalg.conv,
reject fusing linalg.conv in isFusableInto.

tileLinalgOpImpl is a templated function now and it can operate on
loop.parellel. So we should avoid calling into getForInductionVarOwner
which always assumes loop.for.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78936

Files:
  mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
  mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp


Index: mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
===================================================================
--- mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
+++ mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
@@ -409,8 +409,10 @@
   // 5. Gather the newly created loops and return them with the new op.
   SmallVector<Operation *, 8> loops;
   loops.reserve(ivs.size());
-  for (auto iv : ivs)
-    loops.push_back(loop::getForInductionVarOwner(iv));
+  for (auto iv : ivs) {
+    loops.push_back(iv.cast<BlockArgument>().getOwner()->getParentOp());
+    assert(loops.back() && "no owner found for induction variable!");
+  }
 
   return TiledLinalgOp{res, loops};
 }
Index: mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
===================================================================
--- mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
+++ mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
@@ -161,17 +161,6 @@
   assert(consumer.hasBufferSemantics() &&
          "expected linalg op with buffer semantics");
 
-  if (auto convOp = dyn_cast<linalg::ConvOp>(producer.getOperation())) {
-    // TODO(ntv): add a level of indirection to linalg.generic.
-    if (convOp.padding())
-      llvm_unreachable("Unexpected conv with padding");
-  }
-  if (auto convOp = dyn_cast<linalg::ConvOp>(consumer.getOperation())) {
-    // TODO(ntv): add a level of indirection to linalg.generic.
-    if (convOp.padding())
-      llvm_unreachable("Unexpected conv with padding");
-  }
-
   auto subView = dyn_cast_or_null<SubViewOp>(
       consumer.getBuffer(consumerIdx).getDefiningOp());
   auto slice = dyn_cast_or_null<SliceOp>(
@@ -287,6 +276,16 @@
                       << *producer.getOperation());
     return false;
   }
+  if (auto convOp = dyn_cast<linalg::ConvOp>(producer.getOperation())) {
+    // TODO(ntv): add a level of indirection to linalg.generic.
+    if (convOp.padding())
+      return false;
+  }
+  if (auto convOp = dyn_cast<linalg::ConvOp>(consumer.getOperation())) {
+    // TODO(ntv): add a level of indirection to linalg.generic.
+    if (convOp.padding())
+      return false;
+  }
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78936.260349.patch
Type: text/x-patch
Size: 2130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200427/5a7dcdbd/attachment.bin>


More information about the llvm-commits mailing list