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

fix removal of consecutive tranposes with branches #162

Closed
wants to merge 1 commit into from

Conversation

jicampos
Copy link
Contributor

This PR adds logic to handle and remove consecutive Transpose operations with branches. Originally, the package only removed consecutive Transpose operations when no branches were involved.

  • Added a check to ensure correct removal of redundant Transpose nodes without affecting graph structure in RemoveConsecutiveChanFirstAndChanLastTrafos.
  • Additionally, a check has been added to prevent redundant Transpose operations in MoveChanFirstDownstream when handling forked branches in the graph.

@jicampos jicampos requested a review from maltanar December 17, 2024 17:58
@jicampos
Copy link
Contributor Author

Attached is a screenshot of the issue I see. This PR should be able to handle transposes with branches.

test-model
issue

@maltanar
Copy link
Collaborator

Thanks for the PR @jicampos ! It seems you have identified a bug, but the solution isn't quite correct. When we have a pattern that looks like this, where the first transpose is branching and has a opposing transpose in the following branch:
image
...we actually need to skip removing those two transposes in RemoveConsecutiveChanFirstAndChanLastTrafos because there is now no tensor that can correctly feed the branch that used to fork from the output of the first transpose. The correct (and simpler) solution is to skip RemoveConsecutiveChanFirstAndChanLastTrafos when the first transpose has a forking output, and instead let the MoveTransposePastFork make copies of it on both branches later on. Afterwards, we get opposing transposes with no branching in between, and can remove them safely. I'll open a separate PR that implements this simpler solution, and add your testcase to the test suite. I'm closing this PR since the proposed solution is unfortunately not valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants