[RFC] Modularize functions of parsing bytecode (#61862)
authorMartin Yuan <myuan@fb.com>
Sun, 12 Sep 2021 05:22:28 +0000 (22:22 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Sun, 12 Sep 2021 05:24:05 +0000 (22:24 -0700)
commit30a7c768d77d870c6194f5b6cb0bbd6fe1211069
tree2ba911e56009c58d48e85f0c7244e67ffae04aa8
parentdd2d48df07d6b9354f3e448bf66655941a22d1e1
[RFC] Modularize functions of parsing bytecode (#61862)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61862

Modularize functions of parsing bytecode tables so that they can be used as needed in situations other than mobile lite interpreter.
* The decoupled functions are re-used by current lite interpreter loader.
* The bytecode can be serialized/deserialized from other formats.
* The decoupled functions have minimum dependencies on other PyTorch components.

Next:
Build a driver binary to include the parser and interpreter, but only has necessary dependency on other PyTorch components.
ghstack-source-id: 137867287

Test Plan:
As an example, a simple bytecode is parsed to a mobile function, and directly run in the added unit test, `RunTimeTest:ParseBytecode`. It contains basic control flow (if, else) and basic data orchestration (list construction).
CI

Reviewed By: larryliu0820

Differential Revision: D29798382

Pulled By: iseeyuan

fbshipit-source-id: 1c173a5f5d37097e3a97baec3f3e48e1eea1400f
12 files changed:
caffe2/CMakeLists.txt
test/cpp/jit/test_lite_interpreter.cpp
tools/build_variables.bzl
torch/csrc/jit/mobile/function.cpp
torch/csrc/jit/mobile/function.h
torch/csrc/jit/mobile/import.cpp
torch/csrc/jit/mobile/parse_bytecode.cpp [new file with mode: 0644]
torch/csrc/jit/mobile/parse_bytecode.h [new file with mode: 0644]
torch/csrc/jit/serialization/export.h
torch/csrc/jit/serialization/export_module.cpp
torch/csrc/jit/serialization/import_export_functions.h
torch/csrc/jit/serialization/import_source.cpp