module testing.onnx_backend#

Inheritance diagram of mlprodict.testing.onnx_backend

Short summary#

module mlprodict.testing.onnx_backend

Tests with onnx backend.

source on GitHub

Classes#

class

truncated documentation

OnnxBackendTest

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

assert_almost_equal_string

Compares two arrays knowing they contain strings. Raises an exception if the test fails.

enumerate_onnx_tests

Collects test from a sub folder of onnx/backend/test. Works as an enumerator to start processing them without …

Properties#

property

truncated documentation

name

Returns the test name.

Static Methods#

staticmethod

truncated documentation

_load

_read_proto_from_file

_sort

Methods#

method

truncated documentation

__init__

__len__

Returns the number of tests.

__repr__

usual

_compare_results

Compares the expected output and the output produced by the runtime. Raises an exception if not equal.

is_random

Tells if a test is random or not.

run

Executes a tests or all tests if index is None. The function crashes if the tests fails.

to_python

Returns a python code equivalent to the ONNX test.

Documentation#

Tests with onnx backend.

source on GitHub

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

source on GitHub

__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

source on GitHub

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

source on GitHub

to_python()#

Returns a python code equivalent to the ONNX test.

Returns:

code

source on GitHub

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

source on GitHub

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

source on GitHub