apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.76k stars 3.47k forks source link

Emscripten Runtime Error while linking #4843

Closed videetparekh closed 4 years ago

videetparekh commented 4 years ago

I'm trying to get the following tutorial (https://github.com/apache/incubator-tvm/tree/master/web) up and running within a Docker container. I'm using a pre-installed version of TVM, installing Emscripten(clang-tag-e1.38.30_32bit) and patching the two through TVM's config.

I'm able to generate the test_add_one.bc file, but the linking fails at Runtime with the following error:

RuntimeError: Compilation error:
Traceback (most recent call last):
  File "/usr/emsdk/upstream/emscripten/emcc.py", line 3841, in <module>
    sys.exit(run(sys.argv))
  File "/usr/emsdk/upstream/emscripten/emcc.py", line 2312, in run
    final = do_emscripten(final, shared.replace_or_append_suffix(target, '.mem'))
  File "/usr/emsdk/upstream/emscripten/emcc.py", line 475, in do_emscripten
    emscripten.run(infile, outfile, memfile)
  File "/usr/emsdk/upstream/emscripten/emscripten.py", line 2792, in run
    return temp_files.run_and_clean(lambda: emscripter(
  File "/usr/emsdk/upstream/emscripten/tools/tempfiles.py", line 105, in run_and_clean
    return func()
  File "/usr/emsdk/upstream/emscripten/emscripten.py", line 2793, in <lambda>
    infile, outfile_obj, memfile, shared.NODE_JS, temp_files, shared.DEBUG)
  File "/usr/emsdk/upstream/emscripten/emscripten.py", line 95, in emscript_fastcomp
    glue, forwarded_data = compiler_glue(metadata, compiler_engine, temp_files, DEBUG)
  File "/usr/emsdk/upstream/emscripten/emscripten.py", line 242, in compiler_glue
    assert not (metadata['simd'] and shared.Settings.WASM), 'SIMD is used, but not supported in WASM mode yet'
AssertionError: SIMD is used, but not supported in WASM mode yet

I believe Emscripten no longer supports fastcomp and so clang-tag-e1.38.30_32bit would be the version to use?

Please let me know how I can resolve this?

tqchen commented 4 years ago

This thread perhaps duplicates https://github.com/apache/incubator-tvm/issues/4843 unfortunately, we do not yet have any effort on recovering the emcc support, please chime in that thread if you are interested.

videetparekh commented 4 years ago

Hi Tianqi, Not sure which thread you're referring to. I've managed to compile a Mobilenet TensorFlow model down through TVM to .wasm and .js files (the JS file being a wrapper over the wasm). This includes SIMD instructions, using vanilla upstream LLVM. I'd be happy to share details on how to get there, hopefully it'll add value to someone out there.

I'm struggling now with the tvm_runtime.js to ingest the module and infer using it. It seems Emscripten changed their API interface in 2018, and those changes broke TVM code in the tvm_runtime.js. So far this is a blocking error:

Assertion failed: Missing signature argument to addFunction
Assertion failed: Missing signature argument to addFunction
RuntimeError: abort(Assertion failed: Missing signature argument to addFunction). Build with -s ASSERTIONS=1 for more info.
    at abort (.../test_module.js:1:15394)
    at assert (.../test_module.js:1:7675)
    at addFunctionWasm (.../test_module.js:1:5852)
    at Object.addFunction (.../test_module.js:1:6047)
    at Object.TVMRuntime (.../tvm_runtime.js:526:36)
    at Object.create (.../tvm_runtime.js:1262:16)
    at Object.<anonymous> (.../test.js:8:25)
    at Module._compile (internal/modules/cjs/loader.js:936:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
    at Module.load (internal/modules/cjs/loader.js:790:32)

Will TVM reviving support for WASM/emcc anytime soon? Where are your efforts currently and what kind of support do you require?

tqchen commented 4 years ago

Sorry, the corresponding thread is here https://github.com/apache/incubator-tvm/issues/2425