Method returns a single argument (#15289)
authorZachary DeVito <zdevito@fb.com>
Tue, 18 Dec 2018 18:27:26 +0000 (10:27 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 18 Dec 2018 18:44:09 +0000 (10:44 -0800)
commit056cfaf3ff3dc3672e9923237b5e3867e0c76040
tree82525a585d53524fec50312590a661d4ba2276d2
parent12cf5178aa1cdf8c395d326a9e9b175970a2f62a
Method returns a single argument (#15289)

Summary:
This PR changes Method (just Method not all graphs) to always have a single
return argument.

This is part 1 in a set of changes that will enable us to have better handling if early return statements.
The simplification that this change provides greatly reduces the work for the next step.

This change makes it so that Method and Python handle multiple returns in the same way:
* 0 - None
* 1 - <single value>
* many - Tuple[...]

The result is that a lot of special-case handling in compiler.cpp and its
bindings can be removed. It also fixes several bugs in return handling,
including one where return values were not always checked against their
attributed values.

Notes:
* inferTypeFrom is renamed to be more accurate and discourage use.
* This has uncovered some bugs in other components, which are noted in
  the diff.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15289

Differential Revision: D13481649

Pulled By: zdevito

fbshipit-source-id: 0e2242a40bb28cca2d0e8be48bede96195e4858c
40 files changed:
aten/src/ATen/core/jit_type.h
aten/src/ATen/core/type.cpp
test/expect/TestBatched.test_for.expect
test/expect/TestBatched.test_if_else.expect
test/expect/TestBatched.test_if_else_with_scalar.expect
test/expect/TestBatched.test_if_noelse.expect
test/expect/TestBatched.test_if_noelse_with_scalar.expect
test/expect/TestBatched.test_while.expect
test/expect/TestFuser.test_lstm_cuda-forward.expect
test/expect/TestFuser.test_lstm_traced_cuda.expect
test/expect/TestFuser.test_milstm_cuda-forward.expect
test/expect/TestJit.test_cu_escaped_number.expect
test/expect/TestJit.test_pretty_printer-loop_use_test.expect
test/expect/TestJit.test_pretty_printer-print_weird_test.expect
test/expect/TestJit.test_repeated_output.expect
test/expect/TestJit.test_trace_tuple.expect
test/expect/TestScript.test_augmented_assign.expect
test/expect/TestScript.test_constant_pooling.expect
test/expect/TestScript.test_if_supertype.expect
test/expect/TestScript.test_mutable_dce_graph_input.expect
test/expect/TestScript.test_python_frontend.expect
test/expect/TestScript.test_tuple_indexing.expect
test/expect/TestScript.test_tuple_slicing.expect
test/test_jit.py
torch/csrc/jit/init.cpp
torch/csrc/jit/passes/python_print.cpp
torch/csrc/jit/passes/to_batch.cpp
torch/csrc/jit/passes/to_batch.h
torch/csrc/jit/pybind_utils.h
torch/csrc/jit/python_ir.cpp
torch/csrc/jit/python_tracer.cpp
torch/csrc/jit/script/compiler.cpp
torch/csrc/jit/script/compiler.h
torch/csrc/jit/script/init.cpp
torch/csrc/jit/script/module.h
torch/csrc/jit/script/parser.cpp
torch/csrc/jit/script/python_tree_views.cpp
torch/csrc/jit/script/tree_views.h
torch/csrc/jit/tracer.h
torch/jit/frontend.py