You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The input shape in this model is static, so what I expected is
However, I got the following complicated model instead:
Our solution
ONNX Simplifier is presented to simplify the ONNX model. It infers the whole computation graph
and then replaces the redundant operators with their constant outputs (a.k.a. constant folding).
Web version
We have published ONNX Simplifier on convertmodel.com. It works out of the box and doesn't need any installation. Note that it runs in the browser locally and your model is completely safe.
Python version
pip3 install -U pip && pip3 install onnxsim
Then
onnxsim input_onnx_model output_onnx_model
For more advanced features, try the following command for help message
onnxsim -h
Demonstration
An overall comparison between
a complicated model
and its simplified version:
In-script workflow
If you would like to embed ONNX simplifier python package in another script, it is just that simple.
importonnxfromonnxsimimportsimplify# load your predefined ONNX modelmodel=onnx.load(filename)
# convert modelmodel_simp, check=simplify(model)
assertcheck, "Simplified ONNX model could not be validated"# use model_simp as a standard ONNX model object