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

Skip onnx.check_model if model is too large #1515

Merged
merged 3 commits into from
Apr 18, 2023
Merged

Conversation

mgoin
Copy link
Member

@mgoin mgoin commented Apr 10, 2023

Gets ONNX export around the issue of checking models that are too large for check_model(). There are still probably issues with saving ONNX models that are too large

@mgoin mgoin requested review from a team, rahul-tuli, KSGulin and robertgshaw2-neuralmagic and removed request for a team April 10, 2023 20:01
bfineran
bfineran previously approved these changes Apr 10, 2023
@@ -87,7 +87,14 @@ def validate_onnx_file(path: str):
"""
try:
onnx_model = check_load_model(path)
onnx.checker.check_model(onnx_model)

if onnx_model.ByteSize() < onnx.checker.MAXIMUM_PROTOBUF:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea with this check. But checking >2Gb models is supported after they had been saved:image

The crux is, you should call the checker:

  • not on the variable that holds a model in the memory
  • ...but on the path (string) to the model on disk (assuming that the external data file is in the same folder side-by-side with the model)

I will approve this PR, but planning to audit the onnx pathways later and see whether we can easily account for the large models as well.

Copy link
Contributor

@dbogunowicz dbogunowicz Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, actually this pathway theoretically should work for both small and large onnx files - validate_path takes a path to the model as the input, this, in theory, should not fail...

@bfineran bfineran merged commit 48dbdf6 into main Apr 18, 2023
@bfineran bfineran deleted the onnx-check-external branch April 18, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants