-
Notifications
You must be signed in to change notification settings - Fork 321
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
Shape inference for Reshape if the data is unranked tensor #2539
Conversation
Signed-off-by: chentong319 <[email protected]>
Signed-off-by: chentong319 <[email protected]>
// TODO: Infer shape without data rank if shape is a constant | ||
// without -1 and without 0 and allowzero. | ||
if (!hasShapeAndRank(getData()) || !hasStaticShape(getShape().getType())) | ||
if (!hasShapeAndRank(getData()) && !hasStaticShape(getShape().getType())) |
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.
As the comment at L125 said, even though shape
of Reshape
is a constant, it may contain symbolic value, e.g. 0
, meaning taking the dimension from the input dimension. Not sure the code afterward can handle such a case: input is unranked and shape contains 0
. Otherwise, we need to check shape
values in details.
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.
Add the code to handle 0 or -1 for shape. Since we just need to handle them for shape inference, those dimensions are conservatively given unknown (QuestionmarkIndexExpr). When coming to lowering, the data can not be unranked.
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.
Also test cases are added to lit test.
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.
Thanks!
Signed-off-by: chentong319 <[email protected]>
Signed-off-by: chentong319 <[email protected]>
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!
Jenkins Linux ppc64le Build #11905 [push] Shape inference for Resh... started at 15:30 |
Jenkins Linux s390x Build #12912 [push] Shape inference for Resh... started at 15:23 |
Jenkins Linux amd64 Build #12888 [push] Shape inference for Resh... started at 14:23 |
Jenkins Linux amd64 Build #12888 [push] Shape inference for Resh... failed after 1 hr 19 min |
Jenkins Linux s390x Build #12912 [push] Shape inference for Resh... passed after 1 hr 39 min |
Jenkins Linux ppc64le Build #11905 [push] Shape inference for Resh... passed after 1 hr 50 min |
We can get the rank of the output tensor if the shape() has static shape. This could be useful in the middle of iteration.
I didn't change the symbolic computation of dims in computeShape() because unranked tensor is not allowed when the expression is used in lowering.
The error is mentioned by #2524 .