module npy.onnx_variable#

Inheritance diagram of mlprodict.npy.onnx_variable

Short summary#

module mlprodict.npy.onnx_variable

Intermediate class between numpy and onnx.

Classes#

class

truncated documentation

MultiOnnxVar

Class used to return multiple OnnxVar at the same time.

OnnxVar

Variables used into onnx computation.

Properties#

property

truncated documentation

inputs

Returns self.onxvar.inputs.

onnx_op

Returns self.onxvar.onnx_op.

onnx_op_kwargs

Returns self.onxvar.onnx_op_kwargs.

shape

Shape

size

Size

T

Transpose.

Methods#

method

truncated documentation

__add__

Addition.

__and__

And.

__eq__

Equality.

__floordiv__

Division, no difference between / and //.

__ge__

Greater or Equal.

__getitem__

Returns the ith elements.

__getitem__

Deals with multiple scenarios.

__gt__

Greater.

__init__

constructor

__init__

__invert__

not.

__le__

Less or Equal.

__lt__

Less.

__matmul__

Matrix multiplication.

__mod__

Modulo.

__mul__

Multiplication.

__ne__

Difference.

__neg__

Neg.

__or__

And.

__pow__

Power.

__radd__

Right Addition.

__repr__

usual

__rmul__

Right multiplication.

__rsub__

Right subtraction.

__rtruediv__

Division, no difference between / and //.

__setitem__

Only supports vectors (1D tensor).

__sub__

Subtraction.

__truediv__

Division, no difference between / and //.

_custom_op

This could be handled before a call to this method but this method can change the conversion of an non-existing …

_custom_op_filter

This could be handled before a call to this method but this method can change the conversion of an non-existing …

_guess_dtype

Guesses dtype when not specified.

_guess_dtype

Guesses dtype when not specified.

_make_array

Converts y into an array if not.

_setitem1i_

_setitem2i_

astype

Cast

copy

Returns a copy of self (use of Identity node).

flatten

Flattens a matrix (see numpy.ndarray.flatten).

not_

Not.

reshape

Reshape

set_onnx_name

Forces this variable to get this name during

to_algebra

Converts the variable into an operator.

to_algebra

Converts the variable into an operator.

Documentation#

Intermediate class between numpy and onnx.

New in version 0.6.

source on GitHub

class mlprodict.npy.onnx_variable.MultiOnnxVar(*inputs, op=None, dtype=None, **kwargs)#

Bases: object

Class used to return multiple OnnxVar at the same time.

source on GitHub

constructor

__getitem__(index)#

Returns the ith elements.

source on GitHub

__init__(*inputs, op=None, dtype=None, **kwargs)#

constructor

_guess_dtype(dtype)#

Guesses dtype when not specified.

property inputs#

Returns self.onxvar.inputs.

property onnx_op#

Returns self.onxvar.onnx_op.

property onnx_op_kwargs#

Returns self.onxvar.onnx_op_kwargs.

to_algebra(op_version=None)#

Converts the variable into an operator.

source on GitHub

class mlprodict.npy.onnx_variable.OnnxVar(*inputs, op=None, select_output=None, dtype=None, **kwargs)#

Bases: object

Variables used into onnx computation.

Parameters:
  • inputs – variable name or object

  • opONNX operator

  • select_output – if multiple output are returned by ONNX operator op, it takes only one specifed by this argument

  • dtype – specifies the type of the variable held by this class (op is None) in that case

  • kwargs – addition argument to give operator op

New in version 0.6.

source on GitHub

property T#

Transpose.

__add__(y)#

Addition.

__and__(y)#

And.

__array_ufunc__ = None#
__eq__(y)#

Equality.

__floordiv__(y)#

Division, no difference between / and //.

__ge__(y)#

Greater or Equal.

__getitem__(index)#

Deals with multiple scenarios.

  • index is an integer or a slice, a tuple of integers and slices, example: [0, 1], [:5, :6], [::2] (scenario 1)

  • index is an ONNX object (more precisely an instance of OnnxVar), then the method assumes it is an array of boolean to select a subset of the tensor along the first axis, example: mat[mat == 0] (scenario 2)

source on GitHub

__gt__(y)#

Greater.

__hash__ = None#
__init__(*inputs, op=None, select_output=None, dtype=None, **kwargs)#
__invert__()#

not.

__le__(y)#

Less or Equal.

__lt__(y)#

Less.

__matmul__(y)#

Matrix multiplication.

__mod__(y)#

Modulo.

__mul__(y)#

Multiplication.

__ne__(y)#

Difference.

__neg__()#

Neg.

__or__(y)#

And.

__pow__(y)#

Power.

__radd__(y)#

Right Addition.

__repr__()#

usual

__rmul__(y)#

Right multiplication.

__rsub__(y)#

Right subtraction.

__rtruediv__(y)#

Division, no difference between / and //.

__setitem__(index, value)#

Only supports vectors (1D tensor).

  • index is an integer or a slice, a tuple of integers and slices, example: [0], [:5], [::2] (scenario 1)

  • index is an ONNX object (more precisely an instance of OnnxVar), then the method assumes it is an array of boolean to select a subset of the tensor along the first axis, example: mat[mat == 0] (scenario 2)

This processing is applied before the operator it contains. A copy should be made (Identity node or copy method).

source on GitHub

__sub__(y)#

Subtraction.

__truediv__(y)#

Division, no difference between / and //.

_custom_op(*args, op_version=None, runtime=None, **kwargs)#

This could be handled before a call to this method but this method can change the conversion of an non-existing operator depending on the given opset.

source on GitHub

_custom_op_filter(*args, op_version=None, runtime=None, **kwargs)#

This could be handled before a call to this method but this method can change the conversion of an non-existing operator depending on the given opset.

source on GitHub

_guess_dtype(dtype, from_init=False)#

Guesses dtype when not specified.

_make_array(y)#

Converts y into an array if not.

source on GitHub

_setitem1i_(index, value)#
_setitem2i_(index, value)#
astype(dtype)#

Cast

copy()#

Returns a copy of self (use of Identity node).

source on GitHub

flatten(axis=0)#

Flattens a matrix (see numpy.ndarray.flatten).

Parameters:

axis – only flatten from axis to the end.

Returns:

OnnxVar.

source on GitHub

not_()#

Not.

reshape(shape)#

Reshape

set_onnx_name(name_type)#

Forces this variable to get this name during

Parameters:

name_type – a tuple (name, type)

source on GitHub

property shape#

Shape

property size#

Size

to_algebra(op_version=None)#

Converts the variable into an operator.

source on GitHub