Skip to content

Commit 132ac9d

Browse files
committed
skip unsupported test
Signed-off-by: Gal Hubara Agam <96368689+galagam@users.noreply.github.com>
1 parent fc4d541 commit 132ac9d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tests/unit/onnx/test_quantize_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
import os
1919

2020
import onnx
21+
import onnxruntime
2122
import pytest
2223
import torch
2324
from _test_utils.onnx.lib_test_models import SimpleMLP, export_as_onnx
25+
from packaging import version
2426

2527
import modelopt.onnx.quantization as moq
2628
from modelopt.onnx.utils import get_opset_version
@@ -32,6 +34,9 @@
3234
"int4": 21,
3335
}
3436

37+
# onnxruntime version that supports opset 22+
38+
ORT_VERSION_FOR_OPSET_22 = version.parse("1.23.0")
39+
3540

3641
@pytest.mark.parametrize("quant_mode", ["int8", "fp8", "int4"])
3742
def test_opset_below_minimum_upgrades_to_minimum(tmp_path, quant_mode):
@@ -66,6 +71,13 @@ def test_opset_below_original_uses_original(tmp_path, quant_mode):
6671
min_opset = MIN_OPSET[quant_mode]
6772
higher_opset = min_opset + 1
6873

74+
# Skip if required opset exceeds onnxruntime support
75+
ort_version = version.parse(onnxruntime.__version__)
76+
if higher_opset >= 22 and ort_version < ORT_VERSION_FOR_OPSET_22:
77+
pytest.skip(
78+
f"Opset {higher_opset} requires onnxruntime >= {ORT_VERSION_FOR_OPSET_22}, have {ort_version}"
79+
)
80+
6981
onnx_path = os.path.join(tmp_path, "model.onnx")
7082
export_as_onnx(model_torch, input_tensor, onnx_filename=onnx_path, opset=higher_opset)
7183

0 commit comments

Comments
 (0)