videetparekh opened a new issue #6330:
URL: https://github.com/apache/incubator-tvm/issues/6330


   ### Issue
   While trying to load a wasm file into TVM web runtime, I get: 
   
   ```
   Error: Cannot find global function runtime.SystemLib
   Error: Cannot find global function runtime.SystemLib
   
   /path/to/wasm/tvmjs_runtime.wasi.js:3
   var Module=typeof Module!=="undefined"?Module:{};var __wasmLib={};function 
__wasmLibInstantiateWasm(imports,successCallback){__wasmLib.imports=imports;__wasmLib.successCallback=successCallback}function
 
__wasmLibStart(wasmInstance){__wasmLib.successCallback(wasmInstance)}__wasmLib.start=__wasmLibStart;var
 
Module={"instantiateWasm":__wasmLibInstantiateWasm,"wasmLibraryProvider":__wasmLib};var
 moduleOverrides={};var key;for(key in 
Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var 
arguments_=[];var thisProgram="./this.program";var 
quit_=function(status,toThrow){throw toThrow};var ENVIRONMENT_IS_WEB=false;var 
ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var 
ENVIRONMENT_HAS_NODE=false;var 
ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof 
window==="object";ENVIRONMENT_IS_WORKER=typeof 
importScripts==="function";ENVIRONMENT_HAS_NODE=typeof process==="object
   abort(Error: Cannot find global function runtime.SystemLib). Build with -s 
ASSERTIONS=1 for more info.
   (Use `node --trace-uncaught ...` to show where the exception was thrown)
   ```
   
   ### Steps to Reproduce
   
   Build Steps:
   `make` in `tvm/web` gives me the following but proceeds to generate the 
`dist` folder:
   ```sh
   warning: undefined symbol: TVMWasmPackedCFunc
   warning: undefined symbol: TVMWasmPackedCFuncFinalizer
   python3 emcc/decorate_as_wasi.py dist/wasm/tvmjs_runtime.js 
dist/wasm/tvmjs_runtime.wasi.js
   ```
   
   Compiling a model to WASM:
   ```py
   graph, lib, params = tvm.relay.build(relay_function, target='llvm 
-mtriple=wasm32-unknown-emscripten -system-lib', params=relay_function_params)
   lib.save('path/to/modelLibrary.bc')
   emcc.create_tvmjs_wasm('path/to/modelLibrary.js', 'path/to/modelLibrary.bc', 
options=["-s", "USE_GLFW=3"])
   ```
   
   The model compiles as expected and generates a wasm file. The runtime fails 
while loading the systemLibrary as follows.
   ```js
   const lrejs = require("../runtime_dist");
   const wasmPath = lrejs.wasmPath();
   const EmccWASI = require(path.join(wasmPath, "tvmjs_runtime.wasi.js"));
   var WasiObj = new EmccWASI()
   const wasmSource = fs.readFileSync('path/to/modelLibrary.wasm')
   const lre = await lrejs.instantiate(wasmSource, WasiObj)
   var ctx = lre.cpu(0)
   const sysLib = lre.systemLib() // Fails
   const executor = lre.createGraphRuntime(graphJson, sysLib, ctx)
   executor.loadParams(paramsBinary)
   ```
   ### Env
   EMSDK: 1.39.0
   LLVM: release/10.x _(LLVM 12 breaks `make` in `tvm/web`)_
   TVM Commit ID: 5046ff2


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to