-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fixing reshape op so it supports reshaping of scalars #1322
base: main
Are you sure you want to change the base?
Conversation
Run
to fix failing check. |
There is another PR (PR #1252 by @uazizTT) for handling the same issue for |
Please add some tests for these changes. |
@@ -50,6 +50,10 @@ struct TTIRToTTIRDecompositionPass | |||
target.addIllegalOp<ttir::ConvolutionOp>(); | |||
target.addIllegalOp<ttir::GetDimensionSizeOp>(); | |||
target.addIllegalOp<ttir::PoolingOp>(); | |||
target.addDynamicallyLegalOp<ttir::ReshapeOp>([](ttir::ReshapeOp op) { |
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.
Is there a need for this? Do you not want to design it in such a way that this reshape op is either deleted specifically or removed by remove-dead-values pass?
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 I have implemented the pattern inside the TTIRtoTTIRDecompositionPass
, I have to mark the ReshapeOp conditionally illegal, so that the pattern will actually try to match the op. The other possible solution is to make a transform pass from scratch, as was done in #1252. Since we currently do not have a dedicated transformations pass, I put it here, but I am open to changing that and making a transformations pass folder.
The reshape of here is remove in the TTIR->TTIR decomposition, which is currently a part of the larger TTIR->TTNN conversion, not StableHLO->TTIR. Will look into the referenced PR to get the idea how it is solved there. |
As described in #1306, tt-xla produces some reshapes on scalars which are currently not supported by our stableHLO to TTIR dialect lowering (issue #1317). In addition, tt-metal currently throws an error when trying to reshape to a 1-dimensional shape (issue tenstorrent/tt-metal#15201).
To fix both of these issues and fully support scalar testing on tt-xla, I've ingested some of the changes from @mmanzoorTT 's change (#1319) - will merge this PR after it. In addition, I've added that the reshape lowering pass omits the
ttir.reshape
op completely if the types of the input op and the target shape are the same, which will fix the unnecessary calls to the ttnn reshape op from tt-xla.Fixes #1306