allow non-final returns (#15463)
authorZachary DeVito <zdevito@fb.com>
Fri, 21 Dec 2018 21:46:12 +0000 (13:46 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 21 Dec 2018 22:01:33 +0000 (14:01 -0800)
commit6bf05bfde6f091a45385da924a18dc234700c9ac
treeb6fc0970100b5548a94d25e06e62ac39adb7c20c
parent3da4a0473368e9ac18376a9797c46c28cf0bb45d
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
test/test_jit.py
tools/build_variables.py
torch/CMakeLists.txt
torch/csrc/jit/script/compiler.cpp
torch/csrc/jit/script/final_returns.cpp [new file with mode: 0644]
torch/csrc/jit/script/final_returns.h [new file with mode: 0644]
torch/csrc/jit/script/tree.h
torch/csrc/jit/script/tree_views.h
torch/csrc/jit/script/type_parser.cpp
torch/csrc/jit/script/type_parser.h