module utils.onnx_helper#

Short summary#

module onnxcustom.utils.onnx_helper

Onnx implementation of common functions used to train a model.

source on GitHub

Functions#

function

truncated documentation

_finalize_new_onnx

add_initializer

Adds an initializer to graph.

dtype_to_var_type

Converts a numpy dtype into a var type.

get_onnx_opset

Returns the opset associated to an opset.

onnx_rename_weights

Renames ONNX initializers to make sure their name follows the alphabetical order. The model is modified inplace. …

proto_type_to_dtype

Converts a ONNX TensorProto type into numpy type.

replace_initializers_into_onnx

Replaces initializers by other initializers, usually trained ones.

Documentation#

Onnx implementation of common functions used to train a model.

source on GitHub

onnxcustom.utils.onnx_helper._finalize_new_onnx(graph, onx)#
onnxcustom.utils.onnx_helper.add_initializer(model, name, value)#

Adds an initializer to graph.

Parameters:
  • model – onnx model

  • name – initializer name

  • value – value

Returns:

new ONNX graph

source on GitHub

onnxcustom.utils.onnx_helper.dtype_to_var_type(dtype)#

Converts a numpy dtype into a var type.

source on GitHub

onnxcustom.utils.onnx_helper.get_onnx_opset(onx, domain='')#

Returns the opset associated to an opset.

Parameters:
  • onx – onx graph

  • domain – domain

Returns:

value

source on GitHub

onnxcustom.utils.onnx_helper.onnx_rename_weights(onx)#

Renames ONNX initializers to make sure their name follows the alphabetical order. The model is modified inplace. This function calls onnx_rename_names.

Parameters:

onx – ONNX model

Returns:

same model

Note

The function does not go into subgraphs.

source on GitHub

onnxcustom.utils.onnx_helper.proto_type_to_dtype(proto_type)#

Converts a ONNX TensorProto type into numpy type.

Parameters:

proto_type – integer

Returns:

proto type

source on GitHub

onnxcustom.utils.onnx_helper.replace_initializers_into_onnx(model, results)#

Replaces initializers by other initializers, usually trained ones.

Parameters:
  • model – onnx graph

  • results – results to be added in a dictionary

Returns:

new onnx graph

source on GitHub