tools/onnx-graphsurgeon/examples/04_modifying_a_model/README.md
This example first generates a basic model, then modifies the resulting model in various ways.
By importing an ONNX graph into the ONNX GraphSurgeon IR, it is possible to modify virtually every aspect of the graph. We can then export the modified IR back to ONNX.
Generate a model with several nodes and save it to model.onnx by running:
python3 generate.py
The generated model computes Y = x0 + (a * x1 + b):
Modify the model in various ways, and save it to modified.onnx by running:
python3 modify.py
This script does the following:
b input of the first Add nodeAdd to a LeakyReluIdentity node after the first AddIdentity nodecleanup() which removes the x0 tensor and second Add node due to the previous change to the graph outputs.The resulting graph computes identity_out = leaky_relu(a * x1):