diff --git a/build/test_wheel_install.sh b/build/test_wheel_install.sh new file mode 100755 index 00000000000..a7fadb4dfcd --- /dev/null +++ b/build/test_wheel_install.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -euxo pipefail + +CONDA_ENV=executorch-tmp +PYTHON_VERSION=3.10.0 + +# Create a temp dir that we can create files under. +WORK_DIR="$(mktemp -d /tmp/test-wheel-install-XXXXXXXXXX)" +readonly WORK_DIR +# trap 'rm -rf "${WORK_DIR}"' EXIT + +# Creates or resets a conda environment named ${CONDA_ENV} +clean_conda() { + eval "$(conda shell.bash hook)" + conda activate base + conda remove -y --name "${CONDA_ENV}" --all || echo "(ignoring error)" + conda create -yn "${CONDA_ENV}" python="${PYTHON_VERSION}" + conda activate "${CONDA_ENV}" +} + +test_xnnpack_e2e() { + # Create a .pte file that delegates to XNNPACK. + python3 -m examples.xnnpack.aot_compiler --model_name="mv2" --delegate + local pte="mv2_xnnpack_fp32.pte" + test -f "${pte}" + + # Test python script + local test_py="${WORK_DIR}/test_xnnpack_e2e.py" + cat > "${test_py}" << HERE +import torch +from executorch.extension.pybindings import portable_lib +m = portable_lib._load_for_executorch("${pte}") +t = torch.randn((1, 3, 224, 224)) +output = m.forward([t]) +print(output) +print("PASS") +HERE + python "${test_py}" +} + +main() { + if [ "$#" -ne 1 ]; then + echo "Usage: $(basename "$0") " >&2 + exit 1 + fi + local wheel="$1" + +# clean_conda +# +# # Install the deps but not the pip package. +# ./install_requirements.sh --deps-only +# +# # Install the provided wheel. +# pip install "${wheel}" + + test_xnnpack_e2e +} + +main "$@"