diff --git a/onnxruntime/python/tools/quantization/shape_inference.py b/onnxruntime/python/tools/quantization/shape_inference.py index 4b5cb9b242..eff3dc0bcd 100644 --- a/onnxruntime/python/tools/quantization/shape_inference.py +++ b/onnxruntime/python/tools/quantization/shape_inference.py @@ -81,7 +81,17 @@ def quant_pre_process( if not skip_symbolic_shape: # Need to save the inferenced model to file so as to run the optimizer input_model_path = str(temp_path / "symbolic_shape_inferred.onnx") - onnx.save(model, input_model_path) + if save_as_external_data: + onnx.save_model( + model, + input_model_path, + save_as_external_data=True, + all_tensors_to_one_file=all_tensors_to_one_file, + size_threshold=external_data_size_threshold, + convert_attribute=False, + ) + else: + onnx.save(model, input_model_path) model = None opt_model_path = str(temp_path / "optimized.onnx")