2021-10-06 04:16:12 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ -z "$PYTHON" ]; then
|
|
|
|
PYTHON="$(which python)"
|
|
|
|
fi
|
|
|
|
version="$("$PYTHON" --version)"
|
|
|
|
echo "Using python: $PYTHON (version $version)"
|
|
|
|
|
|
|
|
repo_root="$(cd $(dirname $0)/.. && pwd)"
|
|
|
|
wheelhouse="$repo_root/wheelhouse"
|
|
|
|
package_test_venv="$wheelhouse/package-test.venv"
|
|
|
|
mkdir -p $wheelhouse
|
|
|
|
cd $wheelhouse
|
|
|
|
|
|
|
|
echo "---- BUILDING torch-mlir ----"
|
|
|
|
CMAKE_GENERATOR=Ninja CMAKE_C_COMPILER_LAUNCHER=ccache CMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
2021-10-06 07:26:26 +08:00
|
|
|
$PYTHON "${repo_root}/setup.py" bdist_wheel --dist-dir "$wheelhouse" -v
|
2021-10-06 04:16:12 +08:00
|
|
|
|
|
|
|
# Smoke test: create a venv, install the package, and run an example.
|
|
|
|
|
|
|
|
echo "---- CREATING VENV ----"
|
|
|
|
python -m venv "$package_test_venv"
|
|
|
|
VENV_PYTHON="$package_test_venv/bin/python"
|
|
|
|
|
|
|
|
echo "---- INSTALLING torch ----"
|
2022-03-30 04:49:35 +08:00
|
|
|
$VENV_PYTHON -m pip install -r "${repo_root}/requirements.txt"
|
2021-10-06 07:26:26 +08:00
|
|
|
echo "---- INSTALLING other deps for smoke test ----"
|
2021-10-06 04:16:12 +08:00
|
|
|
$VENV_PYTHON -m pip install requests pillow
|
|
|
|
echo "---- INSTALLING torch-mlir ----"
|
2021-10-06 07:26:26 +08:00
|
|
|
$VENV_PYTHON -m pip install -f "$wheelhouse" --force-reinstall torch_mlir
|
2021-10-06 04:16:12 +08:00
|
|
|
|
|
|
|
echo "---- RUNNING SMOKE TEST ----"
|
2022-03-29 03:09:03 +08:00
|
|
|
$VENV_PYTHON "$repo_root/examples/torchscript_resnet18.py"
|