Skip to content

Commit 527594f

Browse files
authored
Use uv (#1007)
1 parent d171b39 commit 527594f

File tree

4 files changed

+20
-24
lines changed

4 files changed

+20
-24
lines changed

onnx.sh

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,19 @@ function makeOnnxFiles () {
8787
if [ ! -d "${WORK_DIR}/onnx" ]; then
8888
git clone https://github.com/onnx/onnx.git "${WORK_DIR}/onnx"
8989
fi
90-
export PYENV_ROOT="${WORK_DIR}/.pyenv"
91-
PYENV="${PYENV_ROOT}/bin/pyenv"
92-
PYENV_PYTHON_VERSION=3.12.9
93-
if [ ! -d "${PYENV_ROOT}" ]; then
94-
git clone https://github.com/pyenv/pyenv.git "${PYENV_ROOT}"
95-
pushd "${PYENV_ROOT}"
96-
src/configure && make -C src
97-
popd
98-
99-
sudo apt update
100-
sudo apt -y install build-essential libssl-dev zlib1g-dev \
101-
libbz2-dev libreadline-dev libsqlite3-dev curl \
102-
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
103-
"$PYENV" install "$PYENV_PYTHON_VERSION"
90+
UV_PROJECT_NAME=onnx_test_create
91+
PYTHON_VERSION=3.13.9
92+
if ! command -v uv >/dev/null 2>&1; then
93+
curl -LsSf https://astral.sh/uv/install.sh | sh
10494
fi
105-
eval "$(${PYENV} init --path)"
106-
"$PYENV" local "$PYENV_PYTHON_VERSION"
107-
pip install --upgrade pip
108-
pip install --no-cache black numpy onnx
109-
pip install --no-cache torch --index-url https://download.pytorch.org/whl/cpu
110-
black "${TEST_ONNX_DIR}"
95+
if [ ! -d "${WORK_DIR}/${UV_PROJECT_NAME}" ]; then
96+
uv init -p ${PYTHON_VERSION} ${UV_PROJECT_NAME}
97+
fi
98+
cd "${WORK_DIR}/${UV_PROJECT_NAME}"
99+
uv add --index https://download.pytorch.org/whl/cpu torch
100+
uv add numpy onnx onnxscript ruff
101+
uv run ruff check --fix "${TEST_ONNX_DIR}"
102+
uv run ruff format "${TEST_ONNX_DIR}"
111103

112104
rm -f "${TEST_ONNX_DIR}"/**/*.onnx
113105
rm -f "${TEST_ONNX_DIR}"/*.onnx
@@ -151,7 +143,7 @@ if len(failed_scripts) > 0:
151143
sys.exit(1)
152144
EOS
153145

154-
python "${WORK_DIR}/create_onnx.py"
146+
uv run "${WORK_DIR}/create_onnx.py"
155147
}
156148

157149
if [ $TEST_MODE -eq 0 ]; then

tests/lib/model/nns/onnx/operators/clip.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import sys
32

43
import onnx
54

tests/lib/model/nns/onnx/operators/gemm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535
for i in range(
3636
b_shape[0] * b_shape[1]
3737
if len(b_shape) == 2
38-
else b_shape[0] if len(b_shape) == 1 else 1
38+
else b_shape[0]
39+
if len(b_shape) == 1
40+
else 1
3941
)
4042
],
4143
)
@@ -87,7 +89,9 @@
8789
for i in range(
8890
b_shape[0] * b_shape[1]
8991
if len(b_shape) == 2
90-
else b_shape[0] if len(b_shape) == 1 else 1
92+
else b_shape[0]
93+
if len(b_shape) == 1
94+
else 1
9195
)
9296
],
9397
)

tests/lib/model/nns/onnx/test_pytorch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@ def forward(self, x):
3838
"input": {0: "batch_size"}, # variable length axes
3939
"output": {0: "batch_size"},
4040
},
41+
dynamo=False,
4142
)

0 commit comments

Comments
 (0)