Skip to content

Commit

Permalink
test_wheel_install.sh tests installed prebuilt wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
dbort committed Apr 18, 2024
1 parent b869d6a commit c96ffa0
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions build/test_wheel_install.sh
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 "$@"

0 comments on commit c96ffa0

Please sign in to comment.