[Mlir-commits] [mlir] dbdb4af - [mlir][sparse] avoid slice rewriting when conditions are not met

Aart Bik llvmlistbot at llvm.org
Fri Apr 21 16:09:16 PDT 2023


Author: Aart Bik
Date: 2023-04-21T16:09:08-07:00
New Revision: dbdb4affa00785c31675be0535b4dc89136b8502

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

LOG: [mlir][sparse] avoid slice rewriting when conditions are not met

Reviewed By: Peiming

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
index 4e1e66d8bc0f7..c1cb0926622f6 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
@@ -1165,11 +1165,9 @@ class SparseExtractSliceConverter
     MLIRContext *ctx = op.getContext();
     auto srcEnc = getSparseTensorEncoding(op.getSourceType());
     auto dstEnc = getSparseTensorEncoding(op.getResult().getType());
-    if (!srcEnc && !dstEnc)
-      return failure();
-
     // TODO: We should check these in ExtractSliceOp::verify.
-    assert(srcEnc && dstEnc && dstEnc.isSlice());
+    if (!srcEnc || !dstEnc || !dstEnc.isSlice())
+      return failure();
     assert(srcEnc.getDimLevelType() == dstEnc.getDimLevelType());
     assert(srcEnc.getDimOrdering() == dstEnc.getDimOrdering());
     assert(srcEnc.getHigherOrdering() == dstEnc.getHigherOrdering());


        


More information about the Mlir-commits mailing list