Skip to content
Merged

Use uv #1007

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions onnx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,19 @@ function makeOnnxFiles () {
if [ ! -d "${WORK_DIR}/onnx" ]; then
git clone https://github.com/onnx/onnx.git "${WORK_DIR}/onnx"
fi
export PYENV_ROOT="${WORK_DIR}/.pyenv"
PYENV="${PYENV_ROOT}/bin/pyenv"
PYENV_PYTHON_VERSION=3.12.9
if [ ! -d "${PYENV_ROOT}" ]; then
git clone https://github.com/pyenv/pyenv.git "${PYENV_ROOT}"
pushd "${PYENV_ROOT}"
src/configure && make -C src
popd

sudo apt update
sudo apt -y install build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev curl \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
"$PYENV" install "$PYENV_PYTHON_VERSION"
UV_PROJECT_NAME=onnx_test_create
PYTHON_VERSION=3.13.9
if ! command -v uv >/dev/null 2>&1; then
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
eval "$(${PYENV} init --path)"
"$PYENV" local "$PYENV_PYTHON_VERSION"
pip install --upgrade pip
pip install --no-cache black numpy onnx
pip install --no-cache torch --index-url https://download.pytorch.org/whl/cpu
black "${TEST_ONNX_DIR}"
if [ ! -d "${WORK_DIR}/${UV_PROJECT_NAME}" ]; then
uv init -p ${PYTHON_VERSION} ${UV_PROJECT_NAME}
fi
cd "${WORK_DIR}/${UV_PROJECT_NAME}"
uv add --index https://download.pytorch.org/whl/cpu torch
uv add numpy onnx onnxscript ruff
uv run ruff check --fix "${TEST_ONNX_DIR}"
uv run ruff format "${TEST_ONNX_DIR}"

rm -f "${TEST_ONNX_DIR}"/**/*.onnx
rm -f "${TEST_ONNX_DIR}"/*.onnx
Expand Down Expand Up @@ -151,7 +143,7 @@ if len(failed_scripts) > 0:
sys.exit(1)
EOS

python "${WORK_DIR}/create_onnx.py"
uv run "${WORK_DIR}/create_onnx.py"
}

if [ $TEST_MODE -eq 0 ]; then
Expand Down
1 change: 0 additions & 1 deletion tests/lib/model/nns/onnx/operators/clip.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import sys

import onnx

Expand Down
8 changes: 6 additions & 2 deletions tests/lib/model/nns/onnx/operators/gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
for i in range(
b_shape[0] * b_shape[1]
if len(b_shape) == 2
else b_shape[0] if len(b_shape) == 1 else 1
else b_shape[0]
if len(b_shape) == 1
else 1
)
],
)
Expand Down Expand Up @@ -87,7 +89,9 @@
for i in range(
b_shape[0] * b_shape[1]
if len(b_shape) == 2
else b_shape[0] if len(b_shape) == 1 else 1
else b_shape[0]
if len(b_shape) == 1
else 1
)
],
)
Expand Down
1 change: 1 addition & 0 deletions tests/lib/model/nns/onnx/test_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ def forward(self, x):
"input": {0: "batch_size"}, # variable length axes
"output": {0: "batch_size"},
},
dynamo=False,
)