Skip to content
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

[Pattern] Reshape-Transpose-Reshape -> Reshape #1775

Open
justinchuby opened this issue Aug 5, 2024 · 4 comments
Open

[Pattern] Reshape-Transpose-Reshape -> Reshape #1775

justinchuby opened this issue Aug 5, 2024 · 4 comments
Labels
contribution welcome We welcome code contributions for this topic: optimizer

Comments

@justinchuby
Copy link
Collaborator

image

@justinchuby justinchuby changed the title [Pattern] Reshape-Transpose-Reshape [Pattern] Reshape-Transpose-Reshape -> Reshape Aug 5, 2024
@justinchuby justinchuby added the contribution welcome We welcome code contributions for this label Aug 8, 2024
@titaiwangms
Copy link
Contributor

Is there a situation that Reshape-Transpose-Reshape is actually un-rewritable (condition function needed)? Otherwise, this should be simple.

@justinchuby
Copy link
Collaborator Author

Is there a situation that Reshape-Transpose-Reshape is actually un-rewritable (condition function needed)? Otherwise, this should be simple.

Potentially. I haven't thought deeply on this yet

@gramalingam
Copy link
Collaborator

We can't rewrite this Reshape-Transpose-Reshape to Reshape (and that's true always, unless the Transpose is an identity operation). This can be checked because a Reshape does NOT require any data-movement (it will not change the relative ordering of elements in the tensor), but a Transpose does (unless it does not really tranpose any axes).

@gramalingam
Copy link
Collaborator

gramalingam commented Sep 5, 2024

But we can eliminate the Reshapes. So, maybe the title should be changed to "Transpose" as the target, not "Reshape"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome We welcome code contributions for this topic: optimizer
Projects
None yet
Development

No branches or pull requests

3 participants