[Mlir-commits] [mlir] 11d7507 - [sparse] Make GenericOpSparsifier not crash on multi-output dense linalg.generic

Benjamin Kramer llvmlistbot at llvm.org
Tue Oct 4 12:48:34 PDT 2022


Author: Benjamin Kramer
Date: 2022-10-04T21:48:18+02:00
New Revision: 11d75076aa6ca90ce192cc944c3d3bf01b6a0c50

URL: https://github.com/llvm/llvm-project/commit/11d75076aa6ca90ce192cc944c3d3bf01b6a0c50
DIFF: https://github.com/llvm/llvm-project/commit/11d75076aa6ca90ce192cc944c3d3bf01b6a0c50.diff

LOG: [sparse] Make GenericOpSparsifier not crash on multi-output dense linalg.generic

The actual transformation doesn't support multi-output GenericOps, but
if we encounter one without sparse annotations we can just leave it
alone.

Differential Revision: https://reviews.llvm.org/D135176

Added: 
    

Modified: 
    mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
index ed6edd1e5e04..ec11393d6279 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp
@@ -1854,7 +1854,8 @@ struct GenericOpSparsifier : public OpRewritePattern<linalg::GenericOp> {
                                 PatternRewriter &rewriter) const override {
     // Detects sparse annotations and translate the per-dimension sparsity
     // information for all tensors to loop indices in the kernel.
-    assert(op.getNumOutputs() == 1);
+    if (op.getNumOutputs() != 1)
+      return failure();
     unsigned numTensors = op.getNumInputsAndOutputs();
     unsigned numLoops = op.iterator_types().getValue().size();
     Merger merger(numTensors, numLoops);


        


More information about the Mlir-commits mailing list