[Relay][Pass] Update SimplifyTranspose to correctly simplify rank changing layout transforms#7807
Conversation
comaniac
left a comment
There was a problem hiding this comment.
Thanks for the fix! Overall LGTM. Please add more comments to help future maintaners catch up the logic easily.
ANSHUMAN87
left a comment
There was a problem hiding this comment.
Thanks @csullivan for the PR!
Please find some comments.
Overall LGTM!
|
Thanks @comaniac @ANSHUMAN87! I've extended the support for various rank changing layout transform + transpose patterns. Please see the additional tests for an overview and let me know other change requests you may have. |
comaniac
left a comment
There was a problem hiding this comment.
LGTM. One bonus suggestion is it would be great to have one comment on the top of each new added test cases to brief explain what's testing.
|
@csullivan Thanks for the contribution. What's the status on this? I looks like it has a lint error. |
when layout transformation changes rank.
|
Thanks @csullivan @ANSHUMAN87 |
…nging layout transforms (apache#7807)
…nging layout transforms (apache#7807)
…nging layout transforms (apache#7807)
…nging layout transforms (apache#7807)
…nging layout transforms (apache#7807)
This PR adds support to SimplifyTranspose to simplify consecutive transpose<->layout_transform operations when the layout transform involves a rank expansion or contraction. The added unit test fails on main because the current SimplifyTranspose only doesn't consider the case when the layout transform and transpose may act on tensors of different rank. As an example,
NCHW4c -> LayoutTransform -> NCHW -> Transpose -> NHWCnow simplifies to
NCHW4c -> LayoutTransform -> NHWC.The reverse, rank expansion, is also supported.