This experimental sample demonstrates one way to target the web platform with IREE, using WebGPU. The output artifact is a web page that loads separately provided IREE .vmfb
(compiled ML model) files and allows for calling functions on them.
Note: you will need a WebGPU-compatible browser. Chrome Canary with the #enable-unsafe-webgpu
flag is a good choice (you may need the flag or an origin trial token for localhost
).
install
target with CMake)emsdk_env.bat
)bash ./build_sample.sh [path to install] && bash ./serve_sample.sh
To rebuild most parts of the sample (C runtime, sample HTML, CMake config, etc.), just control + C
to stop the local webserver and rerun the script.
Emscripten is used (via the emcmake
CMake wrapper) to compile the runtime into WebAssembly and JavaScript files.
Any supported IREE program, such as simple_abs.mlir, is compiled using the WebGPU compiler target. This generates WGSL shader code and IREE VM bytecode, which the IREE runtime is able to load and run using the browser's WebGPU APIs.
index.html