Skip to content

Commit a21942d

Browse files
committed
Applied suggestions
1 parent 4b0e1af commit a21942d

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
727727
target_link_libraries(executor_runner ${_executor_runner_libs})
728728
target_compile_options(executor_runner PUBLIC ${_common_compile_options})
729729

730+
# Automatically set when using `emcmake cmake` for Wasm build.
730731
if(EMSCRIPTEN)
731732
# Directory of model pte files to embed in the wasm binary.
732733
if(NOT DEFINED WASM_MODEL_DIR)

examples/wasm/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
This guide describes how to build ExecuTorch for WebAssembly (Wasm).
44

5+
## Quick Start
6+
7+
To quickly test the build, you can run the following commands
8+
9+
```bash
10+
cd executorch # To the top level dir
11+
12+
source .ci/scripts/setup-emscripten.sh # Install Emscripten and set up the environment variables
13+
14+
bash examples/wasm/test_build_wasm.sh # Run the test build script
15+
```
16+
517
## Prerequisites
618

719
- [Emscripten](https://emscripten.org/docs/getting_started/Tutorial.html)
@@ -62,3 +74,24 @@ python3 -m http.server --directory cmake-out-wasm
6274
```
6375

6476
The page will be available at http://localhost:8000/executor_runner.html.
77+
78+
## Common Issues
79+
80+
### CompileError: WebAssembly.instantiate() [...] failed: expected table index 0...
81+
82+
This seems to be an issue with Node.js v16. Emscripten should come preinstalled with a compatible version of Node.js. You can use the Emscripten-provided version by running `$EMSDK_NODE` instead of `node`.
83+
84+
```bash
85+
echo $EMSDK_NODE
86+
.../emsdk/node/22.16.0_64bit/bin/node # example output
87+
```
88+
89+
### Failed to open [...]: No such file or directory (44)
90+
91+
The file may not have been present while building the Wasm binary. You can rebuild with the following command
92+
93+
```bash
94+
cmake --build cmake-out-wasm -j32 --target executor_runner --clean-first
95+
```
96+
97+
The path may also be incorrect. The files in the `WASM_MODEL_DIR` are placed into the root directory of the virtual file system, so you would use `--model_path mv2.pte` instead of `--model_path models/mv2.pte`, for example.

0 commit comments

Comments
 (0)