module onnx_tools.exports.numpy_helper#

Inheritance diagram of mlprodict.onnx_tools.exports.numpy_helper

Short summary#

module mlprodict.onnx_tools.exports.numpy_helper

Numpy helpers for the conversion from onnx to numpy.

source on GitHub

Classes#

class

truncated documentation

NumpyCode

Converts an ONNX operators into numpy code.

Functions#

function

truncated documentation

argmax_use_numpy_select_last_index

Needed or operator ArgMax.

argmin_use_numpy_select_last_index

Needed or operator ArgMin.

array_feature_extrator

Implementation of operator ArrayFeatureExtractor with numpy.

make_numpy_code

Converts an ONNX operators into numpy code.

make_slice

Implements operator slice in numpy.

Static Methods#

staticmethod

truncated documentation

_make_tuple

Methods#

method

truncated documentation

__init__

_getat

_make_numpy_code_onnx

_make_numpy_code_onnxml

_make_numpy_code_others

_make_sure_inputs

_make_sure_opsets

_simplify

make_numpy_code

Main method, returns the python code for a given operator.

Documentation#

Numpy helpers for the conversion from onnx to numpy.

source on GitHub

class mlprodict.onnx_tools.exports.numpy_helper.NumpyCode(opset, name=None, op_type=None, domain='', inputs=None, outputs=None, attributes=None, used=None, context=None, mark_inits=None, indent='', **unused)#

Bases: object

Converts an ONNX operators into numpy code.

Parameters:
  • opset – target opset for the conversion (usually unused)

  • name – node name

  • op_type – operator type

  • domain – domain

  • inputs – inputs

  • outputs – outputs

  • attributes – attributes

  • used – dictionary {k: v}, list of nodes taking k as input

  • context – whole context

  • mark_inits – marks initializer as replaced

  • indent – indentation of the second line and following

Returns:

code as str

source on GitHub

__init__(opset, name=None, op_type=None, domain='', inputs=None, outputs=None, attributes=None, used=None, context=None, mark_inits=None, indent='', **unused)#
_getat(name, defval=None, format=None)#
_make_numpy_code_onnx()#
_make_numpy_code_onnxml()#
_make_numpy_code_others()#
_make_sure_inputs(n, m=None)#
_make_sure_opsets(mi, ma=None)#
static _make_tuple(val)#
_simplify(name, kind)#
make_numpy_code()#

Main method, returns the python code for a given operator.

source on GitHub

mlprodict.onnx_tools.exports.numpy_helper.argmax_use_numpy_select_last_index(data, axis=0, keepdims=True, select_last_index=False)#

Needed or operator ArgMax.

source on GitHub

mlprodict.onnx_tools.exports.numpy_helper.argmin_use_numpy_select_last_index(data, axis=0, keepdims=True, select_last_index=False)#

Needed or operator ArgMin.

source on GitHub

mlprodict.onnx_tools.exports.numpy_helper.array_feature_extrator(data, indices)#

Implementation of operator ArrayFeatureExtractor with numpy.

source on GitHub

mlprodict.onnx_tools.exports.numpy_helper.make_numpy_code(opset, name=None, op_type=None, domain='', inputs=None, outputs=None, attributes=None, used=None, context=None, mark_inits=None, indent='', **unused)#

Converts an ONNX operators into numpy code.

Parameters:
  • opset – target opset for the conversion (usually unused)

  • name – node name

  • op_type – operator type

  • domain – domain

  • inputs – inputs

  • outputs – outputs

  • attributes – attributes

  • used – dictionary {k: v}, list of nodes taking k as input

  • context – whole context

  • mark_inits – marks initializer as replaced

  • indent – indentation of the second line and following

Returns:

code as str

source on GitHub

mlprodict.onnx_tools.exports.numpy_helper.make_slice(data, starts, ends, axes=None, steps=None)#

Implements operator slice in numpy.

Parameters:
  • data – input

  • starts – mandatory

  • ends – mandatory

  • axes – optional

  • steps – optional

Returns:

results

source on GitHub