module utils.onnx_helper
#
Short summary#
module onnxcustom.utils.onnx_helper
Onnx implementation of common functions used to train a model.
Functions#
function |
truncated documentation |
---|---|
Adds an initializer to graph. |
|
Converts a numpy dtype into a var type. |
|
Returns the opset associated to an opset. |
|
Renames ONNX initializers to make sure their name follows the alphabetical order. The model is modified inplace. … |
|
Converts a ONNX TensorProto type into numpy type. |
|
Replaces initializers by other initializers, usually trained ones. |
Documentation#
Onnx implementation of common functions used to train a model.
- 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
- onnxcustom.utils.onnx_helper.dtype_to_var_type(dtype)#
Converts a numpy dtype into a var type.
- onnxcustom.utils.onnx_helper.get_onnx_opset(onx, domain='')#
Returns the opset associated to an opset.
- Parameters:
onx – onx graph
domain – domain
- Returns:
value
- 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.
- 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
- 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