55import packaging .version as pv
66import numpy
77from numpy .testing import assert_allclose
8+ from onnx .defs import onnx_opset_version
89import onnx .backend .base
910import onnx .backend .test
1011import onnx .shape_inference
3132
3233class ReferenceImplementationError (RuntimeError ):
3334"Fails, export cannot be compared."
34- pass
3535
3636
3737class ExportWrapper :
@@ -64,7 +64,8 @@ def run(
6464expected = self .expected_sess .run (names ,feeds )
6565except (RuntimeError ,AssertionError ,TypeError ,KeyError )as e :
6666raise ReferenceImplementationError (
67- f"ReferenceImplementation fails with{ onnx_simple_text_plot (self .model )} "
67+ f"ReferenceImplementation fails with "
68+ f"{ onnx_simple_text_plot (self .model )} "
6869f"\n --RAW--\n { self .model } "
6970 )from e
7071
@@ -85,7 +86,7 @@ def run(
8586new_code = "\n " .join (
8687 [f"{ i + 1 :04} { line } " for i ,line in enumerate (code .split ("\n " ))]
8788 )
88- raise AssertionError (f"ERROR{ e } \n { new_code } " )
89+ raise AssertionError (f"ERROR{ e } \n { new_code } " )# noqa: B904
8990
9091locs = {
9192"np" :numpy ,
@@ -154,7 +155,8 @@ def run(
154155 ):
155156if a .tolist ()!= b .tolist ():
156157raise AssertionError (
157- f"Text discrepancies for api{ api !r} with a.dtype={ a .dtype } "
158+ f"Text discrepancies for api{ api !r} "
159+ f"with a.dtype={ a .dtype } "
158160f"and b.dtype={ b .dtype } "
159161f"\n --BASE--\n { onnx_simple_text_plot (self .model )} "
160162f"\n --EXP[{ api } ]--\n { onnx_simple_text_plot (export_model )} "
@@ -275,6 +277,22 @@ def run_node(cls, node, inputs, device=None, outputs_info=None, **kwargs):
275277")"
276278)
277279
280+ if onnx_opset_version ()< 22 :
281+ backend_test .exclude (
282+ "("
283+ "test_dft_inverse_cpu"
284+ "|test_dft_inverse_opset19_cpu"
285+ "|test_lppool_1d_default_cpu"
286+ "|test_lppool_2d_default_cpu"
287+ "|test_lppool_2d_dilations_cpu"
288+ "|test_lppool_2d_pads_cpu"
289+ "|test_lppool_2d_same_lower_cpu"
290+ "|test_lppool_2d_same_upper_cpu"
291+ "|test_lppool_2d_strides_cpu"
292+ "|test_lppool_3d_default_cpu"
293+ ")"
294+ )
295+
278296if pv .Version (onnx_version )< pv .Version ("1.16.0" ):
279297backend_test .exclude ("(test_strnorm|test_range_)" )
280298