module testing.test_utils.utils_backend_python#

Inheritance diagram of mlprodict.testing.test_utils.utils_backend_python

Short summary#

module mlprodict.testing.test_utils.utils_backend_python

Inspired from sklearn-onnx, handles two backends.

source on GitHub

Classes#

class

truncated documentation

MockVariableName

A string.

MockVariableNameShape

A string and a shape.

MockVariableNameShapeType

A string and a shape and a type.

OnnxInference2

onnxruntime API

Functions#

function

truncated documentation

compare_runtime

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

Properties#

property

truncated documentation

input_names

Returns the names of all inputs. It does not include the optional inputs.

input_names_shapes

Returns the names and shapes of all inputs. This method assumes all inputs are tensors. It does not include …

input_names_shapes_types

Returns the names, shapes, types of all inputs. This method assumes all inputs are tensors. It does not …

output_names

Returns the names of all outputs.

output_names_shapes

Returns the names and shapes of all outputs. This method assumes all inputs are tensors.

output_names_shapes_types

Returns the names, shapes, types of all outputs. This method assumes all inputs are tensors. It does not …

shape

returns shape

shape

returns shape

shape

returns shape

type

returns type

type

returns type

type

returns type

Methods#

method

truncated documentation

__init__

__init__

__init__

get_inputs

onnxruntime API

get_outputs

onnxruntime API

run

onnxruntime API

run_in_scan

Instance to run in operator scan.

Documentation#

Inspired from sklearn-onnx, handles two backends.

source on GitHub

class mlprodict.testing.test_utils.utils_backend_python.MockVariableName(name)#

Bases: object

A string.

__init__(name)#
property shape#

returns shape

property type#

returns type

class mlprodict.testing.test_utils.utils_backend_python.MockVariableNameShape(name, sh)#

Bases: MockVariableName

A string and a shape.

__init__(name, sh)#
property shape#

returns shape

class mlprodict.testing.test_utils.utils_backend_python.MockVariableNameShapeType(name, sh, stype)#

Bases: MockVariableNameShape

A string and a shape and a type.

__init__(name, sh, stype)#
property type#

returns type

class mlprodict.testing.test_utils.utils_backend_python.OnnxInference2(onnx_or_bytes_or_stream, runtime=None, skip_run=False, inplace=True, input_inplace=False, ir_version=None, target_opset=None, runtime_options=None, session_options=None, inside_loop=False, static_inputs=None, new_outputs=None, new_opset=None, existing_functions=None)#

Bases: OnnxInference

onnxruntime API

get_inputs()#

onnxruntime API

get_outputs()#

onnxruntime API

run(name, inputs, *args, **kwargs)#

onnxruntime API

run_in_scan(inputs, attributes=None, verbose=0, fLOG=None)#

Instance to run in operator scan.

mlprodict.testing.test_utils.utils_backend_python.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 the runtime may 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