Hello,
Wanted to know if there has been any success in stripping away the current web runtime down to the bare minimum for executing TVM-compiled modules bare-bones on the CPU.
So far, I’ve tried stripping away RPC support, OpenGL support from web/web_runtime.cc
, though the compiled web runtime still has traces of GLFW and other potentially unneeded libraries.
Apart from the Makefile
in the main directory, is there anywhere else in the TVM stack that may possibly link GLFW and anything else other than the core C runtime and CPU runtime which I could strip away?
Main goal is to compile modules down to a barebones WASM module holding the bare minimum imports necessary for having as much cross-compatibility as possible.
Current list of required imports: https://pastebin.com/RkpZnBva
Modified web_runtime.cc
:
#include <sys/stat.h>
#include "../src/runtime/c_runtime_api.cc"
#include "../src/runtime/cpu_device_api.cc"
#include "../src/runtime/workspace_pool.cc"
#include "../src/runtime/module_util.cc"
#include "../src/runtime/system_lib_module.cc"
#include "../src/runtime/module.cc"
#include "../src/runtime/registry.cc"
#include "../src/runtime/dso_module.cc"
#include "../src/runtime/graph/graph_runtime.cc"
// dummy parallel runtime
int TVMBackendParallelLaunch(
FTVMParallelLambda flambda,
void* cdata,
int num_task) {
TVMAPISetLastError("Parallel is not supported in Web runtime");
return -1;
}
int TVMBackendParallelBarrier(int task_id, TVMParallelGroupEnv* penv) {
return 0;
}
Modified Makefile
:
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
-Os -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s TOTAL_MEMORY=1073741824\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\
$(INCLUDE_FLAGS)
web: build/libtvm_web_runtime.js build/libtvm_web_runtime.bc
build/libtvm_web_runtime.bc: web/web_runtime.cc
@mkdir -p build/web
@mkdir -p $(@D)
emcc $(EMCC_FLAGS) -MM -MT build/libtvm_web_runtime.bc $< >build/web/web_runtime.d
emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc
build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc
@mkdir -p $(@D)
emcc $(EMCC_FLAGS) -o $@ build/libtvm_web_runtime.bc