Skip to content

Commit

Permalink
Skip onnx.check_model if model is too large (#1515)
Browse files Browse the repository at this point in the history
* Skip onnx.check_model if model is too large

* Quality

---------

Co-authored-by: Benjamin Fineran <bfineran@users.noreply.github.com>
  • Loading branch information
mgoin and bfineran committed Apr 18, 2023
1 parent b442abc commit 48dbdf6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/sparseml/onnx/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
onnx.checker.check_model(onnx_model)
else:
_LOGGER.warning(
"onnx check_model skipped as model exceeds maximum protobuf size of 2GB"
)

if not onnx_model.opset_import:
raise ValueError("could not parse opset_import")
except Exception as err:
Expand Down

0 comments on commit 48dbdf6

Please sign in to comment.