module testing.test_utils.utils_backend_python
#
Short summary#
module mlprodict.testing.test_utils.utils_backend_python
Inspired from sklearn-onnx, handles two backends.
Classes#
class |
truncated documentation |
---|---|
A string. |
|
A string and a shape. |
|
A string and a shape and a type. |
|
onnxruntime API |
Functions#
function |
truncated documentation |
---|---|
The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output … |
Properties#
property |
truncated documentation |
---|---|
|
Returns the names of all inputs. It does not include the optional inputs. |
|
Returns the names and shapes of all inputs. This method assumes all inputs are tensors. It does not include … |
|
Returns the names, shapes, types of all inputs. This method assumes all inputs are tensors. It does not … |
|
Returns the list of optional inputs (the model has an initalizer of the same name as one input). |
|
Returns the names of all outputs. |
|
Returns the names and shapes of all outputs. This method assumes all inputs are tensors. |
|
Returns the names, shapes, types of all outputs. This method assumes all inputs are tensors. It does not … |
returns shape |
|
returns shape |
|
|
returns shape |
returns type |
|
|
returns type |
returns type |
Methods#
method |
truncated documentation |
---|---|
onnxruntime API |
|
onnxruntime API |
|
onnxruntime API |
|
Instance to run in operator scan. |
Documentation#
Inspired from sklearn-onnx, handles two backends.
- 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.