Optimize boolean expressions & unwraps (#18259)
authoreellison <elias_ellison@brown.edu>
Tue, 26 Mar 2019 04:48:11 +0000 (21:48 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 26 Mar 2019 04:50:57 +0000 (21:50 -0700)
commitdc6b5b2a52d182019f6f3f5f21b58e2fb592d993
tree9573b62e403afd295da897e883298b49f7213cb9
parenta729630cbfa5fe02d4b8651845f293d6c70e728f
Optimize boolean expressions & unwraps (#18259)

Summary:
Simplify or eliminate boolean and/or expressions, optimize unwrapping a value that cannot be None, and optimize using `is` with a None and a non-None value

Since peephole optimize is now introducing constants, i added another constant propagation pass after running it.

Previously i had a PR that did this & optimized shape ops - i will add the shape optimizations in a separate PR.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18259

Differential Revision: D14602749

Pulled By: eellison

fbshipit-source-id: 1c3f5a67067d8dfdf55d7b78dcb616472ea8a267
test/cpp/jit/test.cpp
test/cpp/jit/test_peephole_optimize.h [new file with mode: 0644]
test/test_jit.py
torch/csrc/jit/graph_executor.cpp
torch/csrc/jit/ir.cpp
torch/csrc/jit/ir.h
torch/csrc/jit/passes/constant_propagation.cpp
torch/csrc/jit/passes/peephole.cpp
torch/csrc/jit/script/compiler.cpp
torch/csrc/jit/script/schema_type_parser.cpp