module npy.onnx_numpy_annotation#

Inheritance diagram of mlprodict.npy.onnx_numpy_annotation

Short summary#

module mlprodict.npy.onnx_numpy_annotation

numpy annotations.

Classes#

class

truncated documentation

_NDArrayAlias

Ancestor to custom signature.

NDArray

Used to annotation ONNX numpy functions.

NDArraySameType

Shortcut to simplify signature description.

NDArraySameTypeSameShape

Shortcut to simplify signature description.

NDArrayType

Shortcut to simplify signature description.

NDArrayTypeSameShape

Shortcut to simplify signature description.

Functions#

function

truncated documentation

get_args_kwargs

Extracts arguments and optional parameters of a function.

Static Methods#

staticmethod

truncated documentation

__class_getitem__

Overwrites this method.

_process_type

Nicknames such as floats, int, ints, all can be used to describe multiple inputs for a signature. …

_process_type

Nicknames such as floats, int, ints, all can be used to describe multiple inputs for a signature. …

_process_type

Nicknames such as floats, int, ints, all can be used to describe multiple inputs for a signature. …

_process_type

Nicknames such as floats, int, ints, all can be used to describe multiple inputs for a signature. …

_process_type

Nicknames such as floats, int, ints, all can be used to describe multiple inputs for a signature. …

Methods#

method

truncated documentation

__init__

__init__

__init__

__init__

__init__

constructor

__repr__

usual

__repr__

usual

__repr__

usual

__repr__

usual

__repr__

usual

_get_output_types

Tries to infer output types.

_get_output_types

Tries to infer output types.

_get_output_types

Tries to infer output types.

_get_output_types

Tries to infer output types.

_get_output_types

Tries to infer output types.

get_inputs_outputs

Returns the list of inputs, outputs.

get_inputs_outputs

Returns the list of inputs, outputs.

get_inputs_outputs

Returns the list of inputs, outputs.

get_inputs_outputs

Returns the list of inputs, outputs.

get_inputs_outputs

Returns the list of inputs, outputs.

shape_calculator

Returns expected dimensions given the input dimensions.

shape_calculator

Returns expected dimensions given the input dimensions.

shape_calculator

Returns expected dimensions given the input dimensions.

shape_calculator

Returns expected dimensions given the input dimensions.

shape_calculator

Returns expected dimensions given the input dimensions.

Documentation#

numpy annotations.

New in version 0.6.

source on GitHub

class mlprodict.npy.onnx_numpy_annotation.NDArray#

Bases: ndarray, Generic[Shape, DType]

Used to annotation ONNX numpy functions.

New in version 0.6.

source on GitHub

class ShapeType(params)#

Bases: object

Stores shape information.

__init__(params)#
classmethod __class_getitem__(params)#

Overwrites this method.

__orig_bases__ = (<class 'numpy.ndarray'>, typing.Generic[~Shape, ~DType])#
__parameters__ = (~Shape, ~DType)#
class mlprodict.npy.onnx_numpy_annotation.NDArraySameType(dtypes=None)#

Bases: NDArrayType

Shortcut to simplify signature description.

Parameters:

dtypes – input dtypes

New in version 0.6.

source on GitHub

constructor

__init__(dtypes=None)#

constructor

__repr__()#

usual

class mlprodict.npy.onnx_numpy_annotation.NDArraySameTypeSameShape(dtypes=None)#

Bases: NDArraySameType

Shortcut to simplify signature description.

Parameters:

dtypes – input dtypes

New in version 0.6.

source on GitHub

constructor

__init__(dtypes=None)#

constructor

class mlprodict.npy.onnx_numpy_annotation.NDArrayType(dtypes=None, dtypes_out=None, n_optional=None, nvars=False)#

Bases: _NDArrayAlias

Shortcut to simplify signature description.

Parameters:
  • dtypes – input dtypes

  • dtypes_out – output dtypes

  • n_optional – number of optional parameters, 0 by default

  • nvars – True if the function allows an infinite number of inputs, this is incompatible with parameter n_optional.

New in version 0.6.

source on GitHub

constructor

__init__(dtypes=None, dtypes_out=None, n_optional=None, nvars=False)#

constructor

class mlprodict.npy.onnx_numpy_annotation.NDArrayTypeSameShape(dtypes=None, dtypes_out=None, n_optional=None, nvars=False)#

Bases: NDArrayType

Shortcut to simplify signature description.

Parameters:
  • dtypes – input dtypes

  • dtypes_out – output dtypes

  • n_optional – number of optional parameters, 0 by default

  • nvars – True if the function allows an infinite number of inputs, this is incompatible with parameter n_optional.

New in version 0.6.

source on GitHub

constructor

__init__(dtypes=None, dtypes_out=None, n_optional=None, nvars=False)#

constructor

class mlprodict.npy.onnx_numpy_annotation._NDArrayAlias(dtypes=None, dtypes_out=None, n_optional=None, nvars=False)#

Bases: object

Ancestor to custom signature.

Parameters:
  • dtypes – input dtypes

  • dtypes_out – output dtypes

  • n_optional – number of optional parameters, 0 by default

  • nvars – True if the function allows an infinite number of inputs, this is incompatible with parameter n_optional.

dtypes, dtypes_out by default are a tuple of tuple:

  • first dimension: type of every input

  • second dimension: list of types for one input

New in version 0.6.

source on GitHub

constructor

__init__(dtypes=None, dtypes_out=None, n_optional=None, nvars=False)#

constructor

__repr__()#

usual

_get_output_types(key)#

Tries to infer output types.

source on GitHub

static _process_type(dtypes, mapped_types, index)#

Nicknames such as floats, int, ints, all can be used to describe multiple inputs for a signature. This function intreprets that.

<<<

from mlprodict.npy.onnx_numpy_annotation import _NDArrayAlias
for name in ['all', 'int', 'ints', 'floats', 'T']:
    print(name, _NDArrayAlias._process_type(name, {'T': 0}, 0))

>>>

    all (<class 'numpy.float32'>, <class 'numpy.float64'>, <class 'numpy.int32'>, <class 'numpy.int64'>, <class 'numpy.uint32'>, <class 'numpy.uint64'>)
    int (<class 'numpy.int64'>,)
    ints (<class 'numpy.int32'>, <class 'numpy.int64'>)
    floats (<class 'numpy.float32'>, <class 'numpy.float64'>)
    T ('T',)

source on GitHub

get_inputs_outputs(args, kwargs, version)#

Returns the list of inputs, outputs.

Parameters:
  • args – list of arguments

  • kwargs – list of optional arguments

  • version – required version

Returns:

tuple(inputs, kwargs, outputs, optional), inputs and outputs are tuple, kwargs are the arguments, optional is the number of optional arguments

source on GitHub

shape_calculator(dims)#

Returns expected dimensions given the input dimensions.

source on GitHub

mlprodict.npy.onnx_numpy_annotation.get_args_kwargs(fct, n_optional)#

Extracts arguments and optional parameters of a function.

Parameters:
  • fct – function

  • n_optional – number of arguments to consider as optional arguments and not parameters, this parameter skips the first n_optional paramerters

Returns:

arguments, OrderedDict

Any optional argument ending with ‘_’ is ignored.

source on GitHub