pytorch
c65f332d - torch::deploy unity and its demo (#67134)

Commit
3 years ago
torch::deploy unity and its demo (#67134) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/67134 This diff demos torch::deploy unity which builds the model, the dependencies and the runtime as a unity! The end user only need to use the build_unity rule to replace the python_binary rule to define the python application. Under the hood, we build the python application (an xar file), build the torch deploy runtime, and then embed the python application (the xar file) into the torch deploy runtime. When starting the torch::deploy runtime, the xar will be written to the filesystem and extracted. We put the extracted path to python sys.path so all the model files and all the python dependencies can be found! As a demo, the model here is just a simple python program using numpy and scipy. But theoretically, it can be as complex as we want. I'll check how bento_kernel works. Maybe we can learn from bento_kernel to simplify things a bit. ghstack-source-id: 142085742 Test Plan: ``` #build buck build mode/opt unity:unity # make sure the path exists before we start torch::deploy runtime # Otherwise the dynamic loader will just skip this non-existing path # even though we create it after the runtime starts. mkdir -p /tmp/torch_deploy_python_app/python_app_root #run LD_LIBRARY_PATH=/tmp/torch_deploy_python_app/python_app_root ~/fbcode/buck-out/gen/caffe2/torch/csrc/deploy/unity/unity ``` Reviewed By: suo Differential Revision: D31816526 fbshipit-source-id: 8eba97952aad10dcf1c86779fb3f7e500773d7ee
Author
Parents
  • torch/csrc/deploy
    • File
      CMakeLists.txt
    • File
      deploy.cpp
    • File
      deploy.h
    • File
      environment.h
    • File
      interactive_embedded_interpreter.cpp
    • File
      noop_environment.h
    • File
      path_environment.cpp
    • File
      path_environment.h
    • unity
      • File
        example.py
      • File
        example2.py
      • File
        main.cpp
      • tests
        • File
          simple_model.py
        • File
          sum.py
        • File
          test_unity.h
        • File
          test_unity_simple_model.cpp
        • File
          test_unity_sum.cpp
      • File
        xar_environment.cpp
      • File
        xar_environment.h
Loading