-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir][memref.expand_shape] Add verifier check to ensure correct output_shape is provided by user #91245
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
[mlir][memref.expand_shape] Add verifier check to ensure correct output_shape is provided by user #91245
Changes from all commits
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 |
---|---|---|
|
@@ -2353,6 +2353,16 @@ LogicalResult ExpandShapeOp::verify() { | |
<< " dynamic dims while output_shape has " << getOutputShape().size() | ||
<< " values"; | ||
|
||
// Verify if provided output shapes are in agreement with output type. | ||
DenseI64ArrayAttr staticOutputShapes = getStaticOutputShapeAttr(); | ||
ArrayRef<int64_t> resShape = getResult().getType().getShape(); | ||
unsigned staticShapeNum = 0; | ||
|
||
for (auto [pos, shape] : llvm::enumerate(resShape)) | ||
if (!ShapedType::isDynamic(shape) && | ||
shape != staticOutputShapes[staticShapeNum++]) | ||
emitOpError("invalid output shape provided at pos ") << pos; | ||
|
||
Comment on lines
+2359
to
+2365
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. Is this correct? Concretely, this verifier is producing an error when 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. If my understanding is correct, I would suggest this modification: diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index 78201ae29cd9..4f33137dcff4 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -2356,11 +2356,8 @@ LogicalResult ExpandShapeOp::verify() {
// Verify if provided output shapes are in agreement with output type.
DenseI64ArrayAttr staticOutputShapes = getStaticOutputShapeAttr();
ArrayRef<int64_t> resShape = getResult().getType().getShape();
- unsigned staticShapeNum = 0;
-
for (auto [pos, shape] : llvm::enumerate(resShape))
- if (!ShapedType::isDynamic(shape) &&
- shape != staticOutputShapes[staticShapeNum++])
+ if (!ShapedType::isDynamic(shape) && shape != staticOutputShapes[pos])
emitOpError("invalid output shape provided at pos ") << pos;
return success(); 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. That makes sense... does this fix the issue you were hitting? 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. yes it does. |
||
return success(); | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.