Simplifying ONNX Files

ONNX Simplifier is an open-source tool that simplifies ONNX models. By inferring the entire computational graph, redundant operators (also known as constant folding) are replaced with constant outputs.

Run the following commands to use the ONNX Simplifier tool:

pip install onnx-simplifier
onnxsim -h # View the parameter description.
onnxsim  --overwrite-input-shape="1,3,224,24" efficient.onnx efficient_sim.onnx

As shown in Figure 1, some ONNX operations are reduced after the onnxsim operation is performed on the exported ONNX files.

Figure 1 Using the ONNX Simplifier tool