Skip to content

[mlir] Fix handling of "no rank reduction" case in two Patterns #71293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

ubfx
Copy link
Member

@ubfx ubfx commented Nov 4, 2023

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().

@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2023

@llvm/pr-subscribers-mlir-memref
@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-tensor

Author: Felix Schneider (ubfx)

Changes

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 --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.

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()`.
@ubfx ubfx force-pushed the dropped-dims-none branch from 78be4d2 to b0bd8a2 Compare November 5, 2023 10:13
@ubfx ubfx merged commit 6343ee7 into llvm:main Nov 10, 2023
@ubfx ubfx deleted the dropped-dims-none branch November 10, 2023 07:20
zahiraam pushed a commit to zahiraam/llvm-project that referenced this pull request Nov 20, 2023
…#71293)

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()`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants