2021-10-06 04:16:12 +08:00
|
|
|
#!/bin/bash
|
2022-07-07 05:39:30 +08:00
|
|
|
set -eu -o pipefail
|
2021-10-06 04:16:12 +08:00
|
|
|
|
|
|
|
if [ -z "$PYTHON" ]; then
|
|
|
|
PYTHON="$(which python)"
|
|
|
|
fi
|
|
|
|
version="$("$PYTHON" --version)"
|
|
|
|
echo "Using python: $PYTHON (version $version)"
|
|
|
|
|
2022-07-07 05:39:30 +08:00
|
|
|
repo_root="$(cd "$(dirname "$0")"/.. && pwd)"
|
2021-10-06 04:16:12 +08:00
|
|
|
wheelhouse="$repo_root/wheelhouse"
|
|
|
|
package_test_venv="$wheelhouse/package-test.venv"
|
2022-07-07 05:39:30 +08:00
|
|
|
mkdir -p "$wheelhouse"
|
|
|
|
cd "$wheelhouse"
|
2021-10-06 04:16:12 +08:00
|
|
|
|
|
|
|
echo "---- BUILDING torch-mlir ----"
|
2022-04-14 10:31:07 +08:00
|
|
|
CMAKE_GENERATOR=Ninja \
|
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"
|
|
|
|
|
2022-04-21 07:00:09 +08:00
|
|
|
# Install the Torch-MLIR package.
|
|
|
|
# Note that we also need to pass in the `-r requirements.txt` here to pick up
|
|
|
|
# the right --find-links flag for the nightly PyTorch wheel registry.
|
|
|
|
echo "---- INSTALLING torch-mlir and dependencies ----"
|
|
|
|
$VENV_PYTHON -m pip install -f "$wheelhouse" --force-reinstall torch_mlir -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 "---- RUNNING SMOKE TEST ----"
|
2022-03-29 03:09:03 +08:00
|
|
|
$VENV_PYTHON "$repo_root/examples/torchscript_resnet18.py"
|