tree: c22ac58b63d37543afba33e5d9ad7632d1cef8d0 [path history] [tgz]
  1. crt_config/
  2. backtrace.c
  3. backtrace.h
  4. build_model.py
  5. bundle.c
  6. bundle.cc
  7. bundle.h
  8. bundle_static.c
  9. demo.cc
  10. demo_static.c
  11. Makefile
  12. README.md
  13. runtime.cc
  14. test.cc
  15. test_static.c
apps/bundle_deploy/README.md

How to Bundle TVM Modules

This folder contains an example on how to bundle a TVM module (with the required interpreter runtime modules such as runtime::GraphRuntime, the graph JSON, and the params) into a single, self-contained shared object (bundle.so) which exposes a C API wrapping the appropriate runtime::GraphRuntime instance.

This is useful for cases where we'd like to avoid deploying the TVM runtime components to the target host in advance - instead, we simply deploy the bundled shared-object to the host, which embeds both the model and the runtime components. The bundle should only depend on libc/libc++.

It also contains an example code (demo.cc) to load this shared object and invoke the packaged TVM model instance. This is a dependency-free binary that uses the functionality packaged in bundle.so (which means that bundle.so can be deployed lazily at runtime, instead of at compile time) to invoke TVM functionality.

Type the following command to run the sample code under the current folder, after building TVM first.

make demo_dynamic

This will:

  • Download the mobilenet0.25 model from the MXNet Gluon Model Zoo
  • Compile the model with Relay
  • Build a bundle.so shared object containing the model specification and parameters
  • Build a demo_dynamic executable that dlopen's bundle.so (or bundle_c.so in terms of the MISRA-C runtime), instantiates the contained graph runtime, and invokes the GraphRuntime::Run function on a cat image, then prints the output results.

Type the following command to run the sample code with static linking.

make demo_static

This will:

  • Download the mobilenet0.25 model from the MXNet Gluon Model Zoo
  • Compile the model with Relay and outputs model.o
  • Build a bundle_static.o object containing the runtime functions
  • Build a demo_static executable which has static link to bundle_static.o and model.o, functions on a cat image, then prints the output results.