Pool constants during script compilation.#10231
Pool constants during script compilation.#10231resistor wants to merge 1 commit intopytorch:masterfrom
Conversation
torch/csrc/jit/script/compiler.cpp
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
ce822e5 to
f446208
Compare
10e5de4 to
fbcba68
Compare
zdevito
left a comment
There was a problem hiding this comment.
This is good, but it has submodule checkins for NNPACK, cpuinfo, and ONNX that need to be reverted.
fbcba68 to
97faf66
Compare
|
@zdevito Fixed |
97faf66 to
f2d6f45
Compare
9b9366e to
a1289f8
Compare
apaszke
left a comment
There was a problem hiding this comment.
Can't we implement this as a pass? There are many ways in which we introduce the constants into the graphs (both tracing and most of our rewrites do so!), and it would be good to fix those as well.
|
CSE already does the easy cases, but handling it generally requires full data flow analysis and code motion. It’s much easier and more efficient to avoid generating redundant comments in the first place. |
|
FWIW, this is exactly why constants are not instructions in LLVM IR. |
a1289f8 to
29838d1
Compare
This places all constants in the entry block of the graph, and de-duplicates them.
29838d1 to
d21055d
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
resistor has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This places all constants in the entry block of the graph, and de-duplicates them. Pull Request resolved: pytorch#10231 Differential Revision: D9601501 Pulled By: resistor fbshipit-source-id: daa10ed8c99e9894830d6f3e5d65c8d3ab5ea899
Summary: Add a pass to move all constants to the beginning of the graph, and deduplicate. This extends #10231 to also handle constants introduced in inlining, constant propagation, etc. Pull Request resolved: #12222 Reviewed By: driazati Differential Revision: D10201616 Pulled By: eellison fbshipit-source-id: bc9c5be26868c8b5414257a0d4462de025aeb9bd
This places all constants in the entry block of the graph, and de-duplicates them.