[Mlir-commits] [mlir] [mlir] Fix handling of "no rank reduction" case in two Patterns (PR #71293)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Nov 4 12:49:31 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-tensor

Author: Felix Schneider (ubfx)

<details>
<summary>Changes</summary>

This patch fixes two checks where a `SmallBitVector` containing the potential dropped dims of a SubView/ExtractSlice operation was queried via `empty()` instead of `none()`.

---
Full diff: https://github.com/llvm/llvm-project/pull/71293.diff


2 Files Affected:

- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Tensor/Transforms/MergeConsecutiveInsertExtractSlicePatterns.cpp (+1-1) 


``````````diff
diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index 215a8f5e7d18be0..aba46dc0a0d33ca 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -3099,7 +3099,7 @@ struct SubViewReturnTypeCanonicalizer {
 
     // Directly return the non-rank reduced type if there are no dropped dims.
     llvm::SmallBitVector droppedDims = op.getDroppedDims();
-    if (droppedDims.empty())
+    if (droppedDims.none())
       return nonReducedType;
 
     // Take the strides and offset from the non-rank reduced type.
diff --git a/mlir/lib/Dialect/Tensor/Transforms/MergeConsecutiveInsertExtractSlicePatterns.cpp b/mlir/lib/Dialect/Tensor/Transforms/MergeConsecutiveInsertExtractSlicePatterns.cpp
index e32ddf08a769fe0..5257310f5b005b9 100644
--- a/mlir/lib/Dialect/Tensor/Transforms/MergeConsecutiveInsertExtractSlicePatterns.cpp
+++ b/mlir/lib/Dialect/Tensor/Transforms/MergeConsecutiveInsertExtractSlicePatterns.cpp
@@ -91,7 +91,7 @@ struct DropRedundantInsertSliceRankExpansion
                                 PatternRewriter &rewriter) const override {
     // Nothing to do if no dims are dropped.
     llvm::SmallBitVector droppedDims = extractSliceOp.getDroppedDims();
-    if (droppedDims.empty())
+    if (droppedDims.none())
       return failure();
 
     // Look for tensor.insert_slice op that has an inverse rank expansion.

``````````

</details>


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


More information about the Mlir-commits mailing list