Print default values and introduce ir view classes (#14176)
authorZachary DeVito <zdevito@fb.com>
Tue, 27 Nov 2018 19:46:17 +0000 (11:46 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 27 Nov 2018 19:48:27 +0000 (11:48 -0800)
commite22cc7c0724ee308448d3c4d5dc4679c42faf37d
tree086182f746f3e07cbf625351cf20fbc389becf30
parent8408dff55af59cc264b0f55db8a8584241d7274c
Print default values and introduce ir view classes (#14176)

Summary:
[Stacked commit, only review the last commit]

This PR adds support for printing default values in python printing as well as the logic
for parsing default values back in using the parser. For simplicity, this PR simply
creates a subgraph of the constant expressions and then runs that graph to generate the defaults.
A more lightweight approach should be possible later, but would require more machinery.

To make reading code in the printer easier, this also add ir_views.h.
Similar to tree_views.h these classes can provide views of some commonly used IR nodes
that have complicated structure and common operations on that structure.

Currently it has only read-only views for prim::If and prim::Loop,
but we should eventually add helpers to manipulate If/Loop nodes as well.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14176

Differential Revision: D13198455

Pulled By: zdevito

fbshipit-source-id: dc99ab9692804ccaedb60a55040c0b89ac7a6a6d
24 files changed:
aten/src/ATen/core/function_schema.h
test/expect/TestJit.test_cu_escaped_number.expect
test/expect/TestJit.test_import_method.expect
test/expect/TestJit.test_pretty_printer-empty_float_list_test.expect
test/expect/TestJit.test_pretty_printer-empty_int_list_test.expect
test/expect/TestJit.test_pretty_printer-if_one.expect
test/expect/TestJit.test_pretty_printer-if_test.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_pretty_printer-python_op_name_test.expect
test/expect/TestJit.test_pretty_printer-while_if_test.expect
test/expect/TestJit.test_pretty_printer-while_test.expect
test/expect/TestScript.test_python_frontend.expect
test/test_jit.py
torch/csrc/jit/ir_views.h [new file with mode: 0644]
torch/csrc/jit/passes/alias_analysis.cpp
torch/csrc/jit/passes/python_print.cpp
torch/csrc/jit/passes/python_print.h
torch/csrc/jit/python_ir.cpp
torch/csrc/jit/script/compiler.cpp
torch/csrc/jit/script/init.cpp
torch/csrc/jit/script/parser.h
torch/csrc/jit/script/python_tree_views.cpp
torch/csrc/jit/script/tree_views.h