[RUNTIME] Introduce MetadataModule to separate code compilation/interpretation and weight initialization - #5770
Conversation
22a3bf6 to
e7a137c
Compare
|
@tqchen I removed all wrappers, made |
|
cc @mbaret @FrozenGene @comaniac it would be great if you can help to take a look as well |
|
Maybe I miss something. so maybe this is considered. That is I don't see with relay.build_config(opt_level=3):
complied_graph_lib = relay.build_module.build(
mod, "llvm", params=params)
from tvm.contrib import util
temp = util.tempdir()
file_name = "deploy_lib.so"
path_lib = temp.relpath(file_name)
complied_graph_lib.export_library(path_lib)
loaded_lib = tvm.runtime.load_module(path_lib)
ctx = tvm.cpu(0)
gmod = loaded_lib['default'](ctx)
set_input = gmod["set_input"]
run = gmod["run"]
get_output = gmod["get_output"]
data = np.random.uniform(-1, 1, size=(1, 3, 224, 224)).astype("float32")
set_input("data", tvm.nd.array(data))
run()
out = get_output(0).asnumpy()As you could see we will wrap THANKS! |
|
@FrozenGene The current implementation doesn't actually change any user/frontend APIs. We added the As you can see, In other words, it should not affect the way we package the final artifacts, but it changes the way we compile certain modules (e.g. CSourceModule) and the way we initialize modules that need constant data. |
comaniac
left a comment
There was a problem hiding this comment.
Overall LGTM. Only miner comments. Thanks!
…pretation and weight initialization (apache#5770)
…pretation and weight initialization (apache#5770)
This PR attempts to separate metadata initialization and source code compilation (when necessary). The discussion can be found here: https://discuss.tvm.ai/t/byoc-runtime-json-runtime-for-byoc/6579/15
The goal is to have a standalone wrapper (
MetadataModule) to take care of module initialization for different runtimes. In the BYOC case, we save constants and code separately. The constant would be loaded by the wrapper while the code is handled by csourcemodule.