-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Validate type consistency in reintepret cast sizes #140032
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1052,7 +1052,7 @@ struct DimOfMemRefReshape : public OpRewritePattern<DimOp> { | |
} | ||
} // else dim.getIndex is a block argument to reshape->getBlock and | ||
// dominates reshape | ||
} // Check condition 2 | ||
} // Check condition 2 | ||
else if (dim->getBlock() != reshape->getBlock() && | ||
!dim.getIndex().getParentRegion()->isProperAncestor( | ||
reshape->getParentRegion())) { | ||
|
@@ -1835,6 +1835,15 @@ LogicalResult ReinterpretCastOp::verify() { | |
// Match sizes in result memref type and in static_sizes attribute. | ||
for (auto [idx, resultSize, expectedSize] : | ||
llvm::enumerate(resultType.getShape(), getStaticSizes())) { | ||
// Check that dynamic sizes are not mixed with static sizes | ||
if (ShapedType::isDynamic(resultSize) && | ||
!ShapedType::isDynamic(expectedSize)) | ||
return emitError( | ||
"expectedSize is static but received a dynamic resultSize "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: It's a bit difficult to understand what "expectedSize" means in the error message. Maybe: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it sounds more understandable but it seems that in the context of these functions they consistently use expected size and not specified size to name. |
||
if (!ShapedType::isDynamic(resultSize) && | ||
ShapedType::isDynamic(expectedSize)) | ||
return emitError( | ||
"expectedSize is dynamic but received a static resultSize "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
if (!ShapedType::isDynamic(resultSize) && resultSize != expectedSize) | ||
return emitError("expected result type with size = ") | ||
<< (ShapedType::isDynamic(expectedSize) | ||
|
@@ -2008,7 +2017,7 @@ struct ReinterpretCastOpExtractStridedMetadataFolder | |
// Second, check the sizes. | ||
if (!llvm::equal(extractStridedMetadata.getConstifiedMixedSizes(), | ||
op.getConstifiedMixedSizes())) | ||
return false; | ||
return false; | ||
|
||
// Finally, check the offset. | ||
assert(op.getMixedOffsets().size() == 1 && | ||
|
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.
Can you add the same check for the offset and the strides?
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.
Yes!