Xop API#
API#
Automated gathering of operators#
mlprodict.npy.xop.ClassFactory
(class_name, op_name, inputs, outputs, input_range, output_range, domain, attr_names, doc, deprecated, since_version, past_version)
Dynamically creates a class for a specific operator.
mlprodict.npy.xop._dynamic_class_creation
(operator_names = None, cache = False, include_past = False, verbose = 0, fLOG = <built-in function print>)
mlprodict.npy.xop._GraphBuilder
(self)
Graph builder. It takes a graph structure made with instances of
OnnxOperatorBase
. The main method is to_onnx.
initializer: list of initializers to add to the ONNX graph
node: list of nodes to add to the ONNX graph
input: list of inputs to add to the ONNX graph
output: list of inputs to add to the ONNX graph
opsets: opsets of the ONNX graph
- input_names: dictionary of input names
{name: InputDetectedVariable}
- node_output_names: memorizes a name for a node output
when the user did not specify any {(id(node), index): OutputDetectedVariable}
- reserved_names: dictionary { name : (node, index) },
name which should remain unchanged in the ONNX graph
names: list of uniques names
functions: dictionary { domain, name: function_proto }
function_hashes: dictionary { domain, name: hash of function_proto }
Main classes#
mlprodict.npy.xop_variable.Variable
(self, name, dtype = None, shape = None, added_dtype = None, added_shape = None)
An input or output to an ONNX graph.
mlprodict.npy.xop.OnnxOperator
(self, inputs, op_version = None, output_names = None, domain = None, global_context = None, kwargs)
Ancestor to every ONNX operator exposed in
mlprodict.npy.xops
andmlprodict.npy.xops_ml
.
mlprodict.npy.xop.OnnxOperatorItem
(self, onx_op, index, op_version = None)
Accessor to one of the output returned by a
OnnxOperator
.
mlprodict.npy.xop_convert.OnnxSubOnnx
(self, model, inputs, output_names = None)
This operator is used to insert existing ONNX into the ONNX graph being built.
mlprodict.npy.xop_convert.OnnxSubEstimator
(self, model, inputs, op_version = None, output_names = None, options = None, initial_types = None, kwargs)
This operator is used to call the converter of a model to insert the node coming from the conversion into a bigger ONNX graph. It supports model from scikit-learn using sklearn-onnx.
Helpers to handle API changing with opsets#
mlprodict.npy.xop_opset.OnnxReduceSumApi11
(x, axes = None, keepdims = 1, op_version = None, output_names = None)
Adds operator ReduceSum with opset>=13 following API from opset 12.
mlprodict.npy.xop_opset.OnnxSplitApi11
(x, axis = 0, split = None, op_version = None, output_names = None)
Adds operator Split with opset>=13 following API from opset 11.
mlprodict.npy.xop_opset.OnnxSqueezeApi11
(x, axes = None, op_version = None, output_names = None)
Adds operator Squeeze with opset>=13 following API from opset 11.
mlprodict.npy.xop_opset.OnnxUnsqueezeApi11
(x, axes = None, op_version = None, output_names = None)
Adds operator Unsqueeze with opset>=13 following API from opset 11.
mlprodict.npy.xop_opset.OnnxReduceL2_typed
(dtype, x, axes = None, keepdims = 1, op_version = None, output_names = None)
Adds operator ReduceL2 for float or double.
mlprodict.npy.xop_opset.OnnxReshapeApi13
(x, allowzero = 0, op_version = None, output_names = None)
Adds operator Reshape with opset>=14 following API from opset 13.