-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_wheel_install.sh tests installed prebuilt wheels
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") <path-to-whl-file>" >&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 "$@" |