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
[GraphOptimizer] graph optimizer doesn't optimize away non-inverses consecutive Tranposes #2013
Comments
I doubt someone would intentionally write a network like this, but could this sequence appear as a by-product of existing optimisations? |
@SplitInfinity one of the things that GraphOptimizer does is try to sink transposes below other nodes so that those transposes are more likely end up next to each other in the graph so that they can be eliminated. So two transposes that may not have initially been next to one another often end up next to each other after some graph optimization passes. |
@jackm321 Can I work on this? |
We'd love contributions @Squadrick |
@rdzhabarov I've read the Also, could one of you give me an elaborate explanation of the optimization? In
How is what's mentioned here any different? |
@Squadrick Right now we eliminate two consecutive transposes when they are the inverse of each other -- that is, we eliminate both of them, because when combined they are a noop. Here's the check for this: glow/lib/Optimizer/GraphOptimizer.cpp Lines 120 to 124 in 8b08395
The new optimization would be to merge two consecutive transposes that aren't the inverse of each other into a single transpose. E.g.:
This could be done with a single transpose:
|
Yup, that's good. Also look https://github.com/pytorch/glow/blob/master/docs/CodingStandards.md. |
Got it, I'll make a PR in a couple of hours, just started working on it. |
Sorry about the delay. Submitted the PR. |
### Description * Before: GraphOptimizer would only combine consecutive tranposes if the resultant was an identity transpose. * After: GraphOptimizer combines all consecutive tranposes, including non-inverse pairs. ### Testing * `mergeNonInverseTransposes` replaces `dontCancelTwoTransposesIfNotMatching` unit test in `GraphOptzTest.cpp`. * The unit test checks that multiple consecutive non-inverse transposes are combined into a single transpose node. ### Documentation * Documentation has been updated in `docs/Optimizations.md` under graph optimization. ### Issues * Fixes #2013
Two tranposes next to each other in the graph could be collapsed into a single tranpose but this isn't done by the GraphOptimizer. I haven't seen this in any network and maybe it's not a situation that is likely to arise from any real network.
The text was updated successfully, but these errors were encountered: