module testing.test_utils.utils_backend_onnxruntime#

Inheritance diagram of mlprodict.testing.test_utils.utils_backend_onnxruntime

Short summary#

module mlprodict.testing.test_utils.utils_backend_onnxruntime

Inspired from sklearn-onnx, handles two backends.

source on GitHub

Classes#

class

truncated documentation

InferenceSession2

Overwrites class InferenceSession to capture the standard output and error.

Functions#

function

truncated documentation

_capture_output

compare_runtime

The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output …

Methods#

method

truncated documentation

__init__

Overwrites the constructor.

get_inputs

Overwrites method get_inputs.

get_outputs

Overwrites method get_outputs.

run

Overwrites method run.

Documentation#

Inspired from sklearn-onnx, handles two backends.

source on GitHub

class mlprodict.testing.test_utils.utils_backend_onnxruntime.InferenceSession2(*args, **kwargs)#

Bases: object

Overwrites class InferenceSession to capture the standard output and error.

source on GitHub

Overwrites the constructor.

__init__(*args, **kwargs)#

Overwrites the constructor.

get_inputs(*args, **kwargs)#

Overwrites method get_inputs.

get_outputs(*args, **kwargs)#

Overwrites method get_outputs.

run(*args, **kwargs)#

Overwrites method run.

mlprodict.testing.test_utils.utils_backend_onnxruntime._capture_output(fct, kind)#
mlprodict.testing.test_utils.utils_backend_onnxruntime.compare_runtime(test, decimal=5, options=None, verbose=False, context=None, comparable_outputs=None, intermediate_steps=False, classes=None, disable_optimisation=False)#

The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output produced with module onnxruntime or mlprodict.

Parameters
  • test – dictionary with the following keys: - onnx: onnx model (filename or object) - expected: expected output (filename pkl or object) - data: input data (filename pkl or object)

  • decimal – precision of the comparison

  • options – comparison options

  • context – specifies custom operators

  • verbose – in case of error, the function may print more information on the standard output

  • comparable_outputs – compare only these outputs

  • intermediate_steps – displays intermediate steps in case of an error

  • classes – classes names (if option ‘nocl’ is used)

  • disable_optimisation – disable optimisation onnxruntime could do

Returns

tuple (outut, lambda function to run the predictions)

The function does not return anything but raises an error if the comparison failed.

source on GitHub