ONNX helpers

Functions to help understand models. (model, simplify = True)

Returns informations, statistics about a model, its number of nodes, its size…

mlprodict.onnxrt.onnx_inference_manipulations.enumerate_model_node_outputs (model, add_node = False)

Enumerates all the nodes of a model. (fct, obj, code, gl, debug)

Creates a callable function able to cope with default values as the combination of functions compile and exec does not seem able to take them into account.

mlprodict.onnxrt.model_checker.onnx_shaker (oinf, inputs, output_fct, n = 100, dtype = <class ‘numpy.float32’>, force = 1)

Shakes a model ONNX. Explores the ranges for every prediction. Uses astype_range


mlprodict.onnxrt.optim.onnx_statistics (onnx_model, recursive = True, optim = True)

Computes statistics on ONNX models, extracts informations about the model such as the number of nodes.

mlprodict.onnxrt.onnx_inference_manipulations.select_model_inputs_outputs (model, outputs = None, inputs = None)

Takes a model and changes its outputs.

mlprodict.testing.verify_code (source, exc = True)

Verifies python code.

mlprodict.testing.script_testing.verify_script (file_or_name, try_onnx = True, existing_loc = None, options)

Checks that models fitted in an example from scikit-learn documentation can be converted into ONNX.


mlprodict.plotting.plotting_benchmark.plot_benchmark_metrics (metric, xlabel = None, ylabel = None, middle = 1.0, transpose = False, ax = None, cbar_kw = None, cbarlabel = None, valfmt = ‘{x:.2f}x’)

Plots a heatmap which represents a benchmark. See example below.

mlprodict.onnxrt.doc.nb_helper.onnxview (graph, recursive = False, local = False, add_rt_shapes = False)

Displays an ONNX graph into a notebook.

mlprodict.plotting.plotting_validate_graph.plot_validate_benchmark (df)

Plots a graph which summarizes the performances of a benchmark validating a runtime for ONNX.


mlprodict.onnxrt.onnx2py_helper.from_bytes (b)

Retrieves an array from bytes then protobuf.

mlprodict.onnxrt.onnx2py_helper.to_bytes (val)

Converts an array into protobuf and then into bytes.

Versions (benchmark = True)

Retuns the current onnx IR_VERSION based on the installed version of onnx. (benchmark = True)

Retuns the current onnx opset based on the installed version of onnx.