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

Make 'validate_onnx' function robust against the models loaded without external data #317

Conversation

dbogunowicz
Copy link
Contributor

Accounting for the scenario, where the in-memory model passed to the validate_onnx is loaded without the external data.
Right now, the validator simply fails. What it should do, it should skip the validation and emit a verbose warning - this is what has been implemented.

Testing:

import onnx
from sparsezoo.utils.onnx import validate_onnx
model = onnx.load("/network/damian/sparsegpt_webinar_fp32/sparsegpt_1.3b/model.onnx", load_external_data=False)
validate_onnx(model)
model_ = onnx.load("/network/damian/sparsegpt_webinar_fp32/sparsegpt_1.3b/model.onnx", load_external_data=True)
validate_onnx(model_)
Attempting to validate an in-memory ONNX model that has been loaded without external data. This is currently not supported by the ONNX checker. The validation will be skipped.
Attempting to validate an in-memory ONNX model with size > 2000000000 bytes.`validate_onnx` skipped, as large ONNX models cannot be validated in-memory. To validate this model, save it to disk and call `validate_onnx` on the file path.

@dbogunowicz dbogunowicz requested review from natuan, a team, bfineran and Chibukach and removed request for a team May 24, 2023 12:11
Copy link
Member

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

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

A few suggestions, but the diff looks real nice!

Copy link
Contributor

@KSGulin KSGulin left a comment

Choose a reason for hiding this comment

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

LGTM pending Rahul's comments

@dbogunowicz dbogunowicz merged commit c2b5ae5 into main May 25, 2023
4 checks passed
@dbogunowicz dbogunowicz deleted the feature/damian/adapt_validate_onnx_to_model_loaded_without_ext_data branch May 25, 2023 12:29
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

3 participants