Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onnx checker failed for bertsquad_mha_layernorm.onnx model #71

Open
sreedattaSanjay opened this issue Mar 6, 2024 · 3 comments
Open
Labels
question Further information is requested

Comments

@sreedattaSanjay
Copy link

  • Onnx checker failed for "bertsquad_mha_layernorm.onnx" model
  • with the following error
    "onnx.onnx_cpp2py_export.checker.ValidationError: Nodes in a graph must be topologically sorted, however input 'bert/encoder/Reshape__27:0' of node:
    name: bert/encoder/Reshape OpType: Reshape"

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
Copy link
Owner

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 ThanatosShinji added the question Further information is requested label Mar 6, 2024
@ThanatosShinji
Copy link
Owner

update code here

@sreedattaSanjay
Copy link
Author

Thank you @ThanatosShinji for your prompt response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants