onnx_light.onnx.backend#

class onnx_light.onnx.backend.TestCase(*args, **kwargs)#

A single C++-generated backend test case (mirrors onnx_light.backend.test.case.base.TestCase).

property atol#

(self) -> float

property data_sets#

(self) -> list[onnx_light.onnx_py._onnxpybackend.backend_test.DataSet]

property kind#

(self) -> str

property model#

Returns the ModelProto of this test case, resolved against the binding registered by _onnxpyprotoop.

property model_name#

(self) -> str

property name#

(self) -> str

property rtol#

(self) -> float

property tag#

(self) -> str

onnx_light.onnx.backend.collect_test_case() dict[str, TestCase]#

Collects all backend test cases.

The canonical node test cases are produced by the C++ lib_onnx_backend_test library and exposed through the onnx_light.onnx_py._onnxpy.backend_test Python bindings. In addition, any user-defined Base subclass with export* class methods is executed so that downstream code can still register extra Python-defined cases through the expect() helper. Python-defined cases take precedence over C++ cases of the same name.

Returns:

A dictionary mapping test case names to TestCase instances.

onnx_light.onnx.backend.collect_test_cases_by_name(pattern: str | Pattern[str]) list[TestCase]#

Returns the C++-implemented backend test cases whose name matches pattern.

The actual filtering happens in C++ (onnx_kernels::CollectTestCasesByName) using std::regex_search with ECMAScript syntax. A compiled re.Pattern is accepted for convenience and is forwarded as its source string.

Parameters:

pattern – A regular expression (as a string or a pre-compiled re.Pattern) matched against TestCase.name. Use "^...$" to require a full match.

Returns:

The list of TestCase instances (in their natural registration order) whose name matches pattern.

Raises:
  • TypeError – If pattern is neither a string nor a compiled regular expression.

  • ValueError – If pattern is not a valid regular expression.

onnx_light.onnx.backend.make_test_class(rt: Callable, include_regex: Sequence[str] | None = None, exclude_regex: Sequence[str] | None = None, atols: dict[str, float] | None = None, rtols: dict[str, float] | None = None)#

Collects all test cases with collect_test_case. Keeps or removes tests based on include_regex and exclude_regex. Creates a test class which has a test method per test, like test_{name}. Compares outputs.

If rt declares a single positional parameter (i.e. rt(model)), it is treated as a model-level validator: it is invoked once per test case as rt(tc.model) and no output comparison is performed. This is the path used by onnx_light.onnx.checker (check_model).