allow non-final returns (#15463)
Summary:
This PR allows a subclass of programs that have return statements that are not final in the graph.
`final_returns.h` contains the a comment describing how this is accomplished.
To minimize complexity in `compiler.cpp`, this pass is done as an AST-to-AST rewrite before the compiler runs.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15463
Differential Revision:
D13538962
Pulled By: zdevito
fbshipit-source-id:
67105ca873351825b4a364092ab1873779f3e462