module testing.onnx_backend
#
Short summary#
module mlprodict.testing.onnx_backend
Tests with onnx backend.
Classes#
class |
truncated documentation |
---|---|
Definition of a backend test. It starts with a folder, in this folder, one onnx file must be there, then a subfolder … |
Functions#
function |
truncated documentation |
---|---|
Compares two arrays knowing they contain strings. Raises an exception if the test fails. |
|
Collects test from a sub folder of onnx/backend/test. Works as an enumerator to start processing them without … |
Properties#
property |
truncated documentation |
---|---|
Returns the test name. |
Static Methods#
staticmethod |
truncated documentation |
---|---|
Methods#
method |
truncated documentation |
---|---|
Returns the number of tests. |
|
usual |
|
Compares the expected output and the output produced by the runtime. Raises an exception if not equal. |
|
Tells if a test is random or not. |
|
Executes a tests or all tests if index is None. The function crashes if the tests fails. |
|
Returns a python code equivalent to the ONNX test. |
Documentation#
Tests with onnx backend.
- class mlprodict.testing.onnx_backend.OnnxBackendTest(folder)#
Bases:
object
Definition of a backend test. It starts with a folder, in this folder, one onnx file must be there, then a subfolder for each test to run with this model.
- Parameters:
folder – test folder
onnx_path – onnx file
onnx_model – loaded onnx file
tests – list of test
- __init__(folder)#
- __len__()#
Returns the number of tests.
- __repr__()#
usual
- _compare_results(index, i, e, o, decimal=None)#
Compares the expected output and the output produced by the runtime. Raises an exception if not equal.
- Parameters:
index – test index
i – output index
e – expected output
o – output
decimal – precision
- static _load(folder, names)#
- static _read_proto_from_file(full)#
- static _sort(filenames)#
- is_random()#
Tells if a test is random or not.
- property name#
Returns the test name.
- run(load_fct, run_fct, index=None, decimal=None)#
Executes a tests or all tests if index is None. The function crashes if the tests fails.
- Parameters:
load_fct – loading function, takes a loaded onnx graph, and returns an object
run_fct – running function, takes the result of previous function, the inputs, and returns the outputs
index – index of the test to run or all.
decimal – requested precision to compare results
- to_python()#
Returns a python code equivalent to the ONNX test.
- Returns:
code
- mlprodict.testing.onnx_backend.assert_almost_equal_string(expected, value)#
Compares two arrays knowing they contain strings. Raises an exception if the test fails.
- Parameters:
expected – expected array
value – value
- mlprodict.testing.onnx_backend.enumerate_onnx_tests(series, fct_filter=None)#
Collects test from a sub folder of onnx/backend/test. Works as an enumerator to start processing them without waiting or storing too much of them.
- Parameters:
series – which subfolder to load, possible values: (‘node’, …)
fct_filter – function lambda testname: boolean to load or skip the test, None for all
- Returns:
list of
OnnxBackendTest