module npy.xop_variable
#
Short summary#
module mlprodict.npy.xop_variable
Xop API to build onnx graphs. Inspired from sklearn-onnx.
Classes#
class |
truncated documentation |
---|---|
Wrapper around a |
|
Temporary name. |
|
Instance of |
|
Defines a result name for a node. |
|
Instance of |
|
An input or output to an ONNX graph. |
Functions#
function |
truncated documentation |
---|---|
Guesses the corresponding numpy type based on data_type. |
|
Tells if a dtype is a numpy dtype. |
|
Returns the latest supported opset for the main domain. |
|
Converts a numpy dtyp into a TensorProto dtype. |
Properties#
property |
truncated documentation |
---|---|
Unknown type, returns None. |
|
Returns self.added_dtype_. |
|
Unknown type, returns None. |
|
Returns self.dtype_. |
|
Returns variable name. |
|
|
Returns variable name. |
|
Returns variable name. |
Returns the variable name (self.name_). |
|
Returns the shape for self.added_shape_ or self.shape. |
|
Returns the proto type for self.added_dtype_ or self.dtype_. |
|
Returns the proto type for self.dtype_. |
|
Returns self.shape_. |
Static Methods#
staticmethod |
truncated documentation |
---|---|
Creates a Variable from a protobuf object. |
|
Converts variable from sklearn-onnx into this class. |
|
Converts variable from sklearn-onnx into this class defined as a tuple. |
Methods#
method |
truncated documentation |
---|---|
Compares every attributes. |
|
|
|
usual |
|
usual |
|
|
usual |
Usual |
|
|
usual |
usual |
|
Returns a copy of this variable with a new dtype. |
|
Merges information from both Variable. |
|
Returns a copy with a new name. |
|
Returns a name from output_names or a suggestion for a name. |
|
Tells the variable is named like that. |
|
Converts the variable into onnx.ValueInfoProto. |
|
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.
- 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
- __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
- __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.- __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
- __init__(node, index)#
- __repr__()#
Usual
- get_name()#
Returns a name from output_names or a suggestion for a name.
- class mlprodict.npy.xop_variable.OutputDetectedVariable(node, var, index)#
Bases:
DetectedVariable
Instance of
DetectedVariable
. Only for outputs.
- 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:
- __eq__(other)#
Compares every attributes.
- __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:
- copy_merge(var, shape=None)#
Merges information from both Variable.
- copy_name(name)#
Returns a copy with a new name.
- property dtype#
Returns self.dtype_.
- static from_pb(obj)#
Creates a Variable from a protobuf object.
- Parameters:
obj – initializer, tensor
- Returns:
- static from_skl2onnx(var)#
Converts variable from sklearn-onnx into this class.
- static from_skl2onnx_tuple(var)#
Converts variable from sklearn-onnx into this class defined as a tuple.
- is_named(name)#
Tells the variable is named like that.
- make_value_info()#
Converts the variable into onnx.ValueInfoProto.
- Returns:
instance of onnx.ValueInfoProto
- 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.
- mlprodict.npy.xop_variable.guess_numpy_type(data_type)#
Guesses the corresponding numpy type based on data_type.
- mlprodict.npy.xop_variable.is_numpy_dtype(dtype)#
Tells if a dtype is a numpy dtype.
- Parameters:
dtype – anything
- Returns:
boolean
- 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 17
- mlprodict.npy.xop_variable.numpy_type_prototype(dtype)#
Converts a numpy dtyp into a TensorProto dtype.
- Parameters:
dtype – dtype
- Returns:
proto dtype