module onnxrt.onnx_micro_runtime
#
Short summary#
module mlprodict.onnxrt.onnx_micro_runtime
Micro runtime for ONNX.
Classes#
class |
truncated documentation |
---|---|
Implements a micro runtime for ONNX graphs. It does not implements all the operator types. |
Properties#
property |
truncated documentation |
---|---|
Returns input names. |
|
Returns output names. |
Methods#
method |
truncated documentation |
---|---|
Runtime for operator Op.Abs. |
|
Runtime for operator Op.Add. |
|
Runtime for operator Op.Concat. |
|
Runtime for operator Op.Gather. |
|
Runtime for operator Op.Gemm. |
|
Runtime for operator Op.Identity. |
|
Runtime for operator Op.MatMul. |
|
Runtime for operator Op.Max. |
|
Runtime for operator Op.Mul. |
|
Runtime for operator Op.ReduceProd. |
|
Runtime for operator Op.ReduceSum. |
|
Runtime for operator Op.Reshape. |
|
Runtime for operator Op.Shape. |
|
Runtime for operator Op.Squeeze. |
|
Runtime for operator Op.Transpose. |
|
Runtime for operator Op.Unsqueeze. |
|
Computes the outputs of the graph. |
Documentation#
Micro runtime for ONNX.
New in version 0.6.
- class mlprodict.onnxrt.onnx_micro_runtime.OnnxMicroRuntime(model_onnx)#
Bases:
object
Implements a micro runtime for ONNX graphs. It does not implements all the operator types.
- Parameters:
model_onnx – ONNX model
<<<
import pprint import numpy from mlprodict.onnxrt.onnx_micro_runtime import OnnxMicroRuntime from mlprodict.npy.xop import loadop OnnxAdd = loadop('Add') dtype = numpy.float32 opset = 15 x = numpy.array([1, 2, 4, 5, 5, 4]).astype( numpy.float32).reshape((3, 2)) cop = OnnxAdd('X', numpy.array([1], dtype=dtype), op_version=opset) cop4 = OnnxAdd(cop, numpy.array([2], dtype=dtype), op_version=opset, output_names=['Y']) model_def = cop4.to_onnx({'X': x}, target_opset=opset) rt = OnnxMicroRuntime(model_def) out = rt.run({'X': x}) pprint.pprint(out)
>>>
somewhere/workspace/mlprodict/mlprodict_UT_39_std/_doc/sphinxdoc/source/mlprodict/npy/xop_variable.py:64: DeprecationWarning: `mapping.NP_TYPE_TO_TENSOR_TYPE` is now deprecated and will be removed in the next release or so.To silence this warning, please use `helper.{self._future_function}` instead. return NP_TYPE_TO_TENSOR_TYPE[dtype] {'X': array([[1., 2.], [4., 5.], [5., 4.]], dtype=float32), 'Y': array([[4., 5.], [7., 8.], [8., 7.]], dtype=float32), 'init': array([1.], dtype=float32), 'init_1': array([2.], dtype=float32), 'out_add_0': array([[2., 3.], [5., 6.], [6., 5.]], dtype=float32)}
- __init__(model_onnx)#
- _op_gemm(a, b, c=None, alpha=None, beta=None, transA=False, transB=False)#
Runtime for operator Op.Gemm.
- _op_identity(x)#
Runtime for operator Op.Identity.
- _op_reduceprod(data, axes=None, keepdims=None)#
Runtime for operator Op.ReduceProd.
- _op_reducesum(data, axes, keepdims=None, noop_with_empty_axes=None)#
Runtime for operator Op.ReduceSum.
- _op_reshape(x, shape)#
Runtime for operator Op.Reshape.
- _op_squeeze(x, axes=None)#
Runtime for operator Op.Squeeze.
- _op_transpose(x, perm=None)#
Runtime for operator Op.Transpose.
- _op_unsqueeze(x, axes=None)#
Runtime for operator Op.Unsqueeze.
- property input_names#
Returns input names.
- property output_names#
Returns output names.
- run(inputs)#
Computes the outputs of the graph.
- Parameters:
inputs – dictionary
- Returns:
all intermediates results and output as a dictionary