-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][Vector] Fix an assertion on failing cast in vector-transfer-flatten-patterns #86030
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
Conversation
When the result is not a vectorType, there is an assert. This patch will do the check and bail when the result is not a VectorType.
@llvm/pr-subscribers-mlir-vector @llvm/pr-subscribers-mlir Author: Balaji V. Iyer. (bviyer) ChangesWhen the result is not a vectorType, there is an assert. This patch will do the check Full diff: https://github.com/llvm/llvm-project/pull/86030.diff 1 Files Affected:
diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp
index 7ca03537049812..38536de43f13f2 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp
@@ -22,9 +22,9 @@ using namespace mlir;
static bool isLessThanTargetBitWidth(Operation *op, unsigned targetBitWidth) {
auto resultTypes = op->getResultTypes();
for (auto resType : resultTypes) {
- VectorType vecType = cast<VectorType>(resType);
+ VectorType vecType = dyn_cast<VectorType>(resType);
// Reject index since getElementTypeBitWidth will abort for Index types.
- if (vecType.getElementType().isIndex())
+ if (!vecType || vecType.getElementType().isIndex())
return false;
unsigned trailingVecDimBitWidth =
vecType.getShape().back() * vecType.getElementTypeBitWidth();
|
Thanks for the fix! Can you add a test that shows how the assert is triggered? |
@joker-eph I added a test that will fail without the fix. |
I don't hit the assert when |
I'm confused, the test does not match the code change: did you try running the test at HEAD and confirm it is crashing? |
✅ With the latest revision this PR passed the Python code formatter. |
✅ With the latest revision this PR passed the C/C++ code formatter. |
@joker-eph and @banach-space The test was correct one but I accidentally put in the wrong file. Very sorry about the mess/confusion. Now, if you revert this check-in (afc2639) and then run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG, thanks!
Hi @joker-eph and @banach-space, Please let me know if you have any more questions. I would like to land the patch by Monday (March 25th 2024) evening if I don't hear any objections. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to land the patch by Monday (March 25th 2024) evening if I don't hear any objections.
Thanks for the update. I've made a suggestion how to improve the test - I'd like that to be addressed before this is merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for addressing my comments!
When the result is not a vectorType, there is an assert. This patch will do the check
and bail when the result is not a VectorType.