Issue #17098: Shape inferencing fails during quantization for large models (#17100)

This commit is contained in:
shaahji 2023-08-15 18:38:14 -07:00 committed by GitHub
parent 789bac1dc8
commit 3cdf42548f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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")