Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
Signed-off-by: yuwenzho <[email protected]>
  • Loading branch information
yuwenzho committed Sep 21, 2023
1 parent 8a9a8aa commit c050880
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion neural_compressor/model/onnx_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,15 @@ def check_large_model(self):
"""Check model > 2GB."""
init_size = 0
for init in self._model.graph.initializer:
init_size += sys.getsizeof(init.SerializeToString())
# if raise error of initializer size > 2GB, return True
try:
init_bytes = init.SerializeToString()
init_size += sys.getsizeof(init_bytes)
except Exception as e:
if "exceeds maximum protobuf size of 2GB" in str(e):
return True
else:
raise e
if init_size > MAXIMUM_PROTOBUF:
return True
return False
Expand Down

0 comments on commit c050880

Please sign in to comment.