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
ModelProtoof 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_testlibrary and exposed through theonnx_light.onnx_py._onnxpy.backend_testPython bindings. In addition, any user-definedBasesubclass withexport*class methods is executed so that downstream code can still register extra Python-defined cases through theexpect()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) usingstd::regex_searchwith ECMAScript syntax. A compiledre.Patternis 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 againstTestCase.name. Use"^...$"to require a full match.- Returns:
The list of
TestCaseinstances (in their natural registration order) whosenamematches 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
rtdeclares a single positional parameter (i.e.rt(model)), it is treated as a model-level validator: it is invoked once per test case asrt(tc.model)and no output comparison is performed. This is the path used byonnx_light.onnx.checker(check_model).