Skip to content

Commit e810112

Browse files
committed
Fix quant modelproto error
1 parent 4134cd9 commit e810112

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

onnxruntime/python/tools/quantization/quant_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# --------------------------------------------------------------------------
66
from __future__ import annotations
77

8+
import copy
89
import logging
910
import os
1011
import tempfile
@@ -988,8 +989,9 @@ def load_model_with_shape_infer(model_path: Path) -> ModelProto:
988989

989990
def save_and_reload_model_with_shape_infer(model: ModelProto) -> ModelProto:
990991
with tempfile.TemporaryDirectory(prefix="ort.quant.") as quant_tmp_dir:
992+
model_copy = copy.deepcopy(model)
991993
model_path = Path(quant_tmp_dir).joinpath("model.onnx")
992-
onnx.save_model(model, model_path.as_posix(), save_as_external_data=True)
994+
onnx.save_model(model_copy, model_path.as_posix(), save_as_external_data=True)
993995
return load_model_with_shape_infer(model_path)
994996

995997

0 commit comments

Comments
 (0)