pytorch
890b52e0 - Reduce instability in runCleanUpPasses by reordering passes. (#41891)

Commit
4 years ago
Reduce instability in runCleanUpPasses by reordering passes. (#41891) Summary: Currently constant pooling runs before const propagation, which can create more constants that need pooling. This can get in the way of serialization/deserialization stability because each time user serializes and deserializes a module, runCleanUpPasses is called upon it. Doing so multiple times would lead to different saved module. This PR moves constant pooling after const propagation, which may slow down const propagation a little bit, but would otherwise side-step aforementioned problem. test_constant_insertion in test_jit.py is also updated because after fixing the pass ordering, the number of constants is no longer a constant and it is extremely difficult to get the exact number with the current convoluted test structure. So for now, I changed the test to check only that CSE doesn't change number of "prim::constant" rather than comparing against a known number. Also left a TODO to improve this test. ConstantPropagation pass is replaced by ConstantPropagationImmutableTypes because the latter is used in runCleanUpPasses. If not replaced, the former would create new CSE opportunities by folding more constants. This voids the purpose of the test case. Pull Request resolved: https://github.com/pytorch/pytorch/pull/41891 Reviewed By: colesbury Differential Revision: D22701540 Pulled By: gmagogsfm fbshipit-source-id: 8e60dbdcc54a93dac111d81b8d88fb39387224f5
Author
Parents
Loading