Skip to content

Commit b322cb8

Browse files
committed
Added build test script for wasm example
1 parent e6c7666 commit b322cb8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

examples/wasm/test_build_wasm.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
set -e
3+
4+
source "$(dirname "${BASH_SOURCE[0]}")/../../.ci/scripts/utils.sh"
5+
6+
test_build_wasm() {
7+
local model_name=$1
8+
local model_export_name="${model_name}.pte"
9+
local model_dir_name="./models_test/"
10+
echo "Exporting ${model_name}"
11+
mkdir -p "${model_dir_name}"
12+
${PYTHON_EXECUTABLE} -m examples.portable.scripts.export --model_name="${model_name}" --output_dir="$model_dir_name"
13+
14+
local example_dir=examples/wasm
15+
local build_dir=cmake-out/${example_dir}
16+
rm -rf ${build_dir}
17+
retry emcmake cmake -DWASM_MODEL_DIR="$(realpath "${model_dir_name}")" -B${build_dir} .
18+
19+
echo "Building ${example_dir}"
20+
cmake --build ${build_dir} -j9 --target executor_runner
21+
22+
echo "Removing ${model_dir_name}"
23+
rm -rf "${model_dir_name}"
24+
25+
echo 'Running wasm build test'
26+
node ${build_dir}/executor_runner.js --model_path="${model_export_name}"
27+
}
28+
29+
if [[ -z $PYTHON_EXECUTABLE ]];
30+
then
31+
PYTHON_EXECUTABLE=python3
32+
fi
33+
34+
cmake_install_executorch_lib
35+
36+
test_build_wasm add_mul
37+
test_build_wasm mv2

0 commit comments

Comments
 (0)