-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Apps] [RFC] Bundled interpreter demonstration #2297
Conversation
e2798fa
to
e549ebf
Compare
Thanks, @ajtulloch ! please request reviews |
e549ebf
to
6c60775
Compare
cc @yidawang (might be interesting for you folks, possibly along the lines of existing deployment models where you bundle model + interpreter for trees in https://github.com/dmlc/treelite), @tqchen (author of apps/howto_deploy), @merrymercy (could be an interesting deployment model for TVM on constrained mobile devices). |
6c60775
to
6a5251d
Compare
@junrushao1994 this might be relevant to your comments in #2122 (comment) about:
|
} | ||
|
||
int main(int argc, char **argv) { | ||
auto *bundle = dlopen(argv[1], RTLD_LAZY | RTLD_LOCAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggest to print the usage, or describe it in README.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks for the suggestion.
6a5251d
to
dd9aae5
Compare
LTGM, I will let @yzhliu moderate this and merge if he thinks it is OK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the work!
Thanks @ajtulloch @tqchen @yidawang This is now merged :) |
Should we add test for apps? |
@merrymercy absolutely - I’ll add a test in integration tests invoking this Makefile (ie ensuring “make test” runs and returns exit code 0) as a follow up to this diff? |
This is an example/RFC for a usecase mentioned at the recent TVM conference - specifically, allowing single-file deployment of TVM models ab initio, without having the predeploy the TVM runtime. This is done by building a single "bundled" shared object, prebaking the graph/params into this shared object, and exposing the user-visible functions to be invoked via
dlopen
/dlsym
.I'm not sure how generally useful this is, but I thought I'd put it up in case folks have thoughts on better ways to achieve the main goal, etc.
(the
README.md
is embedded below):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, andthe params) into a single, self-contained shared object (
bundle.so
) whichexposes 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 to load this shared object and invoke the
packaged TVM model instance.
Type the following command to run the sample code under the current folder,
after building TVM first.
This will:
bundle.so
shared object containing the model specification and parametersdemo
executable thatdlopen
'sbundle.so
, instantiates thecontained graph runtime, and invokes the run function on a random input.