Skip to content

Commit 41f4ebc

Browse files
committed
fix
1 parent 1cf41ae commit 41f4ebc

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

_unittests/ut_tasks/try_export.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
import onnx
55
import textwrap
66
import torch
7-
from onnx_diagnostic.ext_test_case import ExtTestCase, never_test, ignore_warnings
7+
from onnx_diagnostic.ext_test_case import (
8+
ExtTestCase,
9+
never_test,
10+
ignore_warnings,
11+
has_onnxruntime,
12+
)
813
from onnx_diagnostic.torch_export_patches import torch_export_patches
914
from onnx_diagnostic.torch_models.hghub.model_inputs import get_untrained_model_with_inputs
1015
from onnx_diagnostic.export.api import to_onnx
@@ -157,6 +162,8 @@ def _config_reduction(config, task):
157162

158163
# fake_inputs = make_fake_with_dynamic_dimensions(inputs, dynamic_shapes)[0]
159164
for attention in attention_options:
165+
if attention == "LOOPA24" and not has_onnxruntime("1.24"):
166+
continue
160167
with self.subTest(attention=attention):
161168
print()
162169
print(f"-- attention={attention!r}")

onnx_diagnostic/ext_test_case.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,21 @@ def requires_onnxruntime(version: str, msg: str = "") -> Callable:
610610
return lambda x: x
611611

612612

613+
def has_onnxruntime(version: str, msg: str = "") -> Callable:
614+
"""Skips a unit test if :epkg:`onnxruntime` is not recent enough."""
615+
import packaging.version as pv
616+
import onnxruntime
617+
618+
if not hasattr(onnxruntime, "__version__"):
619+
# development version
620+
return True
621+
622+
if pv.Version(onnxruntime.__version__) < pv.Version(version):
623+
msg = f"onnxruntime version {onnxruntime.__version__} < {version}: {msg}"
624+
return False
625+
return True
626+
627+
613628
def has_onnxruntime_training(push_back_batch: bool = False):
614629
"""Tells if onnxruntime_training is installed."""
615630
try:

0 commit comments

Comments
 (0)