module npy.xop_variable#

Inheritance diagram of mlprodict.npy.xop_variable

Short summary#

module mlprodict.npy.xop_variable

Xop API to build onnx graphs. Inspired from sklearn-onnx.

Classes#

class

truncated documentation

DetectedVariable

Wrapper around a Variable to detect inputs and outputs of a graph.

ExistingVariable

Temporary name.

InputDetectedVariable

Instance of DetectedVariable. Only for inputs.

NodeResultName

Defines a result name for a node.

OutputDetectedVariable

Instance of DetectedVariable. Only for outputs.

Variable

An input or output to an ONNX graph.

Functions#

function

truncated documentation

guess_numpy_type

Guesses the corresponding numpy type based on data_type.

is_numpy_dtype

Tells if a dtype is a numpy dtype.

max_supported_opset

Returns the latest supported opset for the main domain.

numpy_type_prototype

Converts a numpy dtyp into a TensorProto dtype.

Properties#

property

truncated documentation

added_dtype

Unknown type, returns None.

added_dtype

Returns self.added_dtype_.

dtype

Unknown type, returns None.

dtype

Returns self.dtype_.

name

Returns variable name.

name

Returns variable name.

name

Returns variable name.

name

Returns the variable name (self.name_).

proto_added_shape

Returns the shape for self.added_shape_ or self.shape.

proto_added_type

Returns the proto type for self.added_dtype_ or self.dtype_.

proto_type

Returns the proto type for self.dtype_.

shape

Returns self.shape_.

Static Methods#

staticmethod

truncated documentation

from_pb

Creates a Variable from a protobuf object.

from_skl2onnx

Converts variable from sklearn-onnx into this class.

from_skl2onnx_tuple

Converts variable from sklearn-onnx into this class defined as a tuple.

Methods#

method

truncated documentation

__eq__

Compares every attributes.

__init__

__init__

__init__

__init__

__init__

__init__

__repr__

usual

__repr__

usual

__repr__

usual

__repr__

Usual

__repr__

usual

__repr__

usual

copy_add

Returns a copy of this variable with a new dtype.

copy_merge

Merges information from both Variable.

copy_name

Returns a copy with a new name.

get_name

Returns a name from output_names or a suggestion for a name.

is_named

Tells the variable is named like that.

make_value_info

Converts the variable into onnx.ValueInfoProto.

to_skl2onnx

Converts this instance into an instance of Variable from sklearn-onnx.

Documentation#

Xop API to build onnx graphs. Inspired from sklearn-onnx.

New in version 0.9.

source on GitHub

class mlprodict.npy.xop_variable.DetectedVariable(node, var, index)#

Bases: object

Wrapper around a Variable to detect inputs and outputs of a graph.

Parameters:
  • node – node where the variable was detected

  • var – instance of Variable

  • index – index, only used if it is an output

source on GitHub

__init__(node, var, index)#
__repr__()#

usual

property name#

Returns variable name.

class mlprodict.npy.xop_variable.ExistingVariable(name, op)#

Bases: object

Temporary name.

Parameters:
  • name – variable name

  • op – operator it comes from

source on GitHub

__init__(name, op)#
__repr__()#

usual

property added_dtype#

Unknown type, returns None.

property dtype#

Unknown type, returns None.

class mlprodict.npy.xop_variable.InputDetectedVariable(node, var)#

Bases: DetectedVariable

Instance of DetectedVariable. Only for inputs.

source on GitHub

__init__(node, var)#
class mlprodict.npy.xop_variable.NodeResultName(node, index)#

Bases: object

Defines a result name for a node.

Parameters:
  • node – node it comes from

  • index – index of the output

source on GitHub

__init__(node, index)#
__repr__()#

Usual

get_name()#

Returns a name from output_names or a suggestion for a name.

source on GitHub

class mlprodict.npy.xop_variable.OutputDetectedVariable(node, var, index)#

Bases: DetectedVariable

Instance of DetectedVariable. Only for outputs.

source on GitHub

class mlprodict.npy.xop_variable.Variable(name, dtype=None, shape=None, added_dtype=None, added_shape=None)#

Bases: object

An input or output to an ONNX graph.

Parameters:
  • name – name

  • dtypenumpy dtype (can be None)

  • shape – shape (can be None)

  • added_dtypenumpy dtype specified at conversion type (can be None)

  • added_shapenumpy shape specified at conversion type (can be None)

source on GitHub

__eq__(other)#

Compares every attributes.

source on GitHub

__hash__ = None#
__init__(name, dtype=None, shape=None, added_dtype=None, added_shape=None)#
__repr__()#

usual

property added_dtype#

Returns self.added_dtype_.

copy_add(dtype)#

Returns a copy of this variable with a new dtype.

Parameters:

dtype – added type

Returns:

Variable

source on GitHub

copy_merge(var, shape=None)#

Merges information from both Variable.

source on GitHub

copy_name(name)#

Returns a copy with a new name.

source on GitHub

property dtype#

Returns self.dtype_.

static from_pb(obj)#

Creates a Variable from a protobuf object.

Parameters:

obj – initializer, tensor

Returns:

Variable

source on GitHub

static from_skl2onnx(var)#

Converts variable from sklearn-onnx into this class.

source on GitHub

static from_skl2onnx_tuple(var)#

Converts variable from sklearn-onnx into this class defined as a tuple.

source on GitHub

is_named(name)#

Tells the variable is named like that.

make_value_info()#

Converts the variable into onnx.ValueInfoProto.

Returns:

instance of onnx.ValueInfoProto

source on GitHub

property name#

Returns the variable name (self.name_).

property proto_added_shape#

Returns the shape for self.added_shape_ or self.shape.

property proto_added_type#

Returns the proto type for self.added_dtype_ or self.dtype_.

property proto_type#

Returns the proto type for self.dtype_.

property shape#

Returns self.shape_.

to_skl2onnx(scope=None)#

Converts this instance into an instance of Variable from sklearn-onnx.

source on GitHub

mlprodict.npy.xop_variable.guess_numpy_type(data_type)#

Guesses the corresponding numpy type based on data_type.

source on GitHub

mlprodict.npy.xop_variable.is_numpy_dtype(dtype)#

Tells if a dtype is a numpy dtype.

Parameters:

dtype – anything

Returns:

boolean

source on GitHub

mlprodict.npy.xop_variable.max_supported_opset()#

Returns the latest supported opset for the main domain.

<<<

from mlprodict.npy.xop_variable import max_supported_opset
print("max_supported_opset() returns", max_supported_opset())

>>>

    max_supported_opset() returns 15

source on GitHub

mlprodict.npy.xop_variable.numpy_type_prototype(dtype)#

Converts a numpy dtyp into a TensorProto dtype.

Parameters:

dtype – dtype

Returns:

proto dtype

source on GitHub