Onnx Manipulations

Extract a subgraph

Both functions below are usually to extract a small piece of an existing model to create unit tests.

Function onnx_remove_node_unused removes every node whose outputs are not used.

Function select_model_inputs_outputs creates an onnx graph taking any intermediate results as new inputs or new outputs.

Analyze

Loops or tests are based on onnx GraphProto. These subgraphs takes inputs but can also use any intermediated results computed so far. These results are part of the local context but they are not explicit mentioned and that sometimes makes it difficult to understand what subgraph is doing or needs. Function get_hidden_inputs retrieves that information.

Function enumerate_onnx_node_types quickly gives the list of operators a model uses.