The surgeon
tool uses ONNX-GraphSurgeon to modify an ONNX model.
surgeon
provides subtools to perform different functions:
extract
can extract subgraphs from models. It can also be used for changing the shapes/datatypes of the model inputs/outputs by specifying the existing inputs/outputs, but with different shapes/datatypes. This can be useful to make an input dimension dynamic, for example.insert
can insert a node into a model. Currently, this subtool does not support specifiying attributes.sanitize
can remove unused nodes, topologically sort, and fold constants in an ONNX model.See polygraphy surgeon -h
for usage information.
For examples, see this directory