ThanatosShinji / onnx-tool

A parser, editor and profiler tool for ONNX models.
https://pypi.org/project/onnx-tool/
MIT License
383 stars 51 forks source link

Onnx checker failed for bertsquad_mha_layernorm.onnx model #71

Open sreedattaSanjay opened 6 months ago

sreedattaSanjay commented 6 months ago

Steps to reproduce:

1 Run bert_mha_layernorm_fuse() function in benchmark/examples.py with bertsquad-12.onnx model 2 It will output bertsquad_mha_layernorm.onnx model 3 Load the model and check with onnx checker

Code to reproduce : onnx_model=onnx.load(' bertsquad_mha_layernorm.onnx') onnx.checker.check_model(onnx_model)

Can you please let me know how to solve this error?

ThanatosShinji commented 6 months ago

Hi, what's your purpose for performing a check_model? The fused graph has custom-defined operators like layernorm and MHA. It won't pass this check anyway. Nodes in a graph must be topologically sorted this can be done by g.graph_reorder_nodes()

ThanatosShinji commented 6 months ago

update code here

sreedattaSanjay commented 6 months ago

Thank you @ThanatosShinji for your prompt response