neural_compressor.model.onnx_model

Class for ONNX model.

Module Contents

Classes

ONNXModel

Build ONNX model.

class neural_compressor.model.onnx_model.ONNXModel(model, **kwargs)

Bases: neural_compressor.model.base_model.BaseModel

Build ONNX model.

property large_size

Return large size.

property model_path

Return model path.

property q_config

Return q_config.

property model

Return model itself.

property graph_info

Return ORT Graph Info object holding information about backend graph.

property input_name_to_nodes

Return input names of nodes.

property output_name_to_node

Return output names of nodes.

framework()

Return framework.

input()

Return input of model.

output()

Return output of model.

update()

Update model info.

save(root)

Save ONNX model.

nodes()

Return model nodes.

initializer()

Return model initializer.

graph()

Return model graph.

ir_version()

Return model ir_version.

opset_import()

Return model opset_import.

remove_node(node)

Remove a node from model.

remove_nodes(nodes_to_remove)

Remove nodes from model.

add_node(node)

Add a node to model.

add_nodes(nodes_to_add)

Add nodes to model.

add_initializer(tensor)

Add a initializer to model.

add_initializers(tensors)

Add initializers to model.

get_initializer(name)

Get an initializer by name.

remove_initializer(tensor)

Remove an initializer from model.

remove_initializers(init_to_remove)

Remove initializers from model.

set_initializer(tensor, array)

Update initializer.

get_children(node, input_name_to_nodes=None)

Get children nodes.

get_parents(node, output_name_to_node=None)

Get parents nodes.

get_parent(node, idx, output_name_to_node=None)

Get parent node by idx.

find_node_by_name(node_name, new_nodes_list, graph)

Find out node by name.

find_nodes_by_initializer(graph, initializer)

Find all nodes with given initializer as an input.

get_scale_zero(tensor)

Help function to get scale and zero_point.

save_model_to_file(output_path, use_external_data_format=False)

Save model to external data, which is needed for model size > 2GB.

static replace_node_input(node, old_input_name, new_input_name)

Replace input of a node.

replace_input_of_all_nodes(old_input_name, new_input_name, white_optype=[], black_optype=[])

Replace inputs of all nodes.

static replace_node_output(node, old_output_name, new_output_name)

Replace output of a node.

replace_output_of_all_nodes(old_output_name, new_output_name, white_optype=[], black_optype=[])

Replace outputs of all nodes.

remove_unused_constant()

Remove unused constant.

topological_sort(enable_subgraph=False)

Topological sort the model.

get_nodes_chain(start_node, stop_node, result_chain=[])

Get nodes chain with given start node and stop node.

export(save_path, conf)

Export Qlinear to QDQ model.