tree: 6c6f4a1e25ba3e237cc7eefc55ad5a01e0286e30 [path history] [tgz]
  1. build_static_emscripten_demo.sh
  2. CMakeLists.txt
  3. device_multithreaded.c
  4. device_sync.c
  5. index.html
  6. local_server.py
  7. main.c
  8. README.md
experimental/sample_web_static/README.md

Static Web Sample

This experimental sample demonstrates one way to target the web platform with IREE. The output artifact is a web page containing an interactive MNIST digits classifier.

Quickstart

  1. Install IREE's host tools (e.g. by building the install target with CMake)
  2. Install the Emscripten SDK by following these directions
  3. Initialize your Emscripten environment (e.g. run emsdk_env.bat)
  4. From this directory, run bash ./build_static_emscripten_demo.sh
    • You may need to set the path to your host tools install
  5. Open the localhost address linked in the script output

To rebuild most parts of the demo (C runtime, sample HTML, CMake config, etc.), just control + C to stop the local webserver and rerun the script.

How it works

This MNIST model, also used in the Vision sample, is compiled using the “static library” output setting of IREE's compiler (see the Static library sample). The resulting .h and .o files are compiled together with main.c, while the .vmfb is embedded into a C file that is similarly linked in.

Emscripten is used (via the emcmake CMake wrapper) to compile the output binary into WebAssembly and JavaScript files.

The provided index.html file can be served together with the output .js and .wasm files.

Multithreading

TODO(scotttodd): this is incomplete - more changes are needed to the C runtime