module onnxrt.optim._onnx_optimisation_common

Short summary

module mlprodict.onnxrt.optim._onnx_optimisation_common

Common functions to reduce the number of nodes of an ONNX graphs.

source on GitHub

Functions

function

truncated documentation

_apply_optimisation_on_graph

Applies an optimisation function fct on a graph and not on the model.

_apply_remove_node_fct_node

Applies an optimizing function on a subgraphs.

_copy_value_info_proto

_make_att_graph

_make_node

Constructs a NodeProto.

_rename_graph_input

Renames an input and adds an Identity node to connect the dots.

_rename_graph_output

Renames an output and adds an Identity node to connect the dots.

_rename_node_input

Renames an input from a node.

_rename_node_output

Renames an output from a node.

_replace

Documentation

Common functions to reduce the number of nodes of an ONNX graphs.

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._apply_optimisation_on_graph(fct, onnx_model, recursive=True, debug_info=None, **kwargs)

Applies an optimisation function fct on a graph and not on the model.

Parameters
  • fct – function to optimise like onnx_remove_node_identity

  • onnx_model – onnx model

  • recursive – looks into subgraphs

  • debug_info – debug information (private)

  • kwargs – additional parameters

Returns

new onnx _model

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._apply_remove_node_fct_node(fct, node, recursive, debug_info)

Applies an optimizing function on a subgraphs.

Parameters
  • node – onnx node

  • recursive – does it in subgraphs as well

Returns

new node

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._copy_value_info_proto(new_name, obj)
mlprodict.onnxrt.optim._onnx_optimisation_common._make_att_graph(name, new_body)
mlprodict.onnxrt.optim._onnx_optimisation_common._make_node(op_type, inputs, outputs, name=None, doc_string=None, domain=None, attributes=None)

Constructs a NodeProto.

Parameters
  • op_type – (string): The name of the operator to construct

  • inputs – list of input names

  • outputs – list of output names

  • name – optional unique identifier for NodeProto

  • doc_string – optional documentation string for NodeProto

  • domain – optional domain for NodeProto. If it’s None, we will just use default domain (which is empty)

  • attributes – the attributes of the node. The acceptable values are documented in make_attribute().

Returns

node

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._rename_graph_input(graph, old_name, new_name)

Renames an input and adds an Identity node to connect the dots.

Parameters

graph – ONNX graph

Returns

modified graph

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._rename_graph_output(graph, old_name, new_name)

Renames an output and adds an Identity node to connect the dots.

Parameters

graph – ONNX graph

Returns

modified graph

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._rename_node_input(onnx_node, old_name, new_name=None)

Renames an input from a node.

Parameters
  • onnx_node – onnx_node

  • old_name – old name

  • new_name – new name or None if old_name is a dictionary

Returns

new node

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._rename_node_output(onnx_node, old_name, new_name)

Renames an output from a node.

Parameters
  • onnx_node – onnx_node

  • old_name – old name

  • new_name – new name

Returns

new node

source on GitHub

mlprodict.onnxrt.optim._onnx_optimisation_common._replace(name, old_name, new_name)