pytorch
ca76c82c - Add early returns to JIT (#19179)

Commit
5 years ago
Add early returns to JIT (#19179) Summary: Add early returns to JIT with minimal changes to compiler.cpp and an IR->IR pass that will transform the graph so that there is only one return value. In compiler.cpp, record when a block will exit so that in the following example will work: ``` if cond: a = torch.zeros([2]) else: return 2 a += 2 ... ``` To match block outputs with values that will not be used, like in the above example with `a`, I add a Bottom Type that subtypes everything else. This allows shape propagation to continue to work, and makes it so that we don't need many extra nodes filling up the graph. The IR transform currently doesn't work on Loops, I didn't add that to this PR to avoid too much complexity, but will add it as a stack (and it should be very little extra code). the IR transform is commented at the top of the file. Pull Request resolved: https://github.com/pytorch/pytorch/pull/19179 Differential Revision: D16519819 Pulled By: eellison fbshipit-source-id: 322a27f69966d1fd074ebe723c3e948b458b0e68
Author
Elias Ellison
Parents
Loading