diff --git a/neural_compressor/model/onnx_model.py b/neural_compressor/model/onnx_model.py index 60005d6e882..ad031a29c96 100644 --- a/neural_compressor/model/onnx_model.py +++ b/neural_compressor/model/onnx_model.py @@ -65,10 +65,10 @@ def check_large_model(self): """Check model > 2GB.""" init_size = 0 for init in self._model.graph.initializer: - # if size of the initializer > 2GB, return True + # if raise error of initializer size > 2GB, return True try: init_bytes = init.SerializeToString() - init_size += sys.getsizeof(init.SerializeToString()) + init_size += sys.getsizeof(init_bytes) except Exception as e: if "exceeds maximum protobuf size of 2GB" in str(e): return True