daquexian / onnx-simplifier

Simplify your onnx model
Apache License 2.0
3.89k stars 384 forks source link

onnxsim error #93

Open onexuan opened 4 years ago

onexuan commented 4 years ago

Traceback (most recent call last): File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.8/site-packages/onnxsim/main.py", line 52, in main() File "/usr/local/lib/python3.8/site-packages/onnxsim/main.py", line 39, in main model_opt, check_ok = onnxsim.simplify( File "/usr/local/lib/python3.8/site-packages/onnxsim/onnx_simplifier.py", line 321, in simplify onnx.checker.check_model(model) File "/usr/local/lib/python3.8/site-packages/onnx/checker.py", line 93, in check_model C.check_model(model.SerializeToString()) onnx.onnx_cpp2py_export.checker.ValidationError: Nodes in a graph must be topologically sorted, however input 'transpose_output' of node: input: "transpose_output" output: "refinement_pred/Sigmoid:0" name: "Identity1" op_type: "Identity" doc_string: "" domain: "" is not output of any previous nodes.

daquexian commented 4 years ago

Thanks for your report! Could you please send your model to daquexian566@gmail.com?

SStarver commented 1 year ago

Traceback (most recent call last): File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.8/site-packages/onnxsim/main.py", line 52, in main() File "/usr/local/lib/python3.8/site-packages/onnxsim/main.py", line 39, in main model_opt, check_ok = onnxsim.simplify( File "/usr/local/lib/python3.8/site-packages/onnxsim/onnx_simplifier.py", line 321, in simplify onnx.checker.check_model(model) File "/usr/local/lib/python3.8/site-packages/onnx/checker.py", line 93, in check_model C.check_model(model.SerializeToString()) onnx.onnx_cpp2py_export.checker.ValidationError: Nodes in a graph must be topologically sorted, however input 'transpose_output' of node: input: "transpose_output" output: "refinement_pred/Sigmoid:0" name: "Identity1" op_type: "Identity" doc_string: "" domain: "" is not output of any previous nodes. topologically sort demo.zip

One possible solution can be found in another opensource project. (refer to:https://github.com/onnx/sklearn-onnx/issues/424) This error seems to be an incorrect operation during the generation of onnx or export of onnx model from other framework. (Refer to : https://zhuanlan.zhihu.com/p/378083258) I've writen a simplified script to topologically sort onnx model like this (topologically sort demo.zip), hope this can help solve your problem.