mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-28 20:11:22 +00:00
clean up calibration model (#12255)
This commit is contained in:
parent
45c0be8a25
commit
a18b080513
1 changed files with 13 additions and 9 deletions
|
|
@ -4,6 +4,7 @@
|
|||
# license information.
|
||||
# --------------------------------------------------------------------------
|
||||
import logging
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from onnx import onnx_pb as onnx_proto
|
||||
|
|
@ -142,15 +143,18 @@ def quantize_static(
|
|||
calib_extra_options = {
|
||||
key: extra_options.get(name) for (name, key) in calib_extra_options_keys if name in extra_options
|
||||
}
|
||||
calibrator = create_calibrator(
|
||||
model,
|
||||
op_types_to_quantize,
|
||||
calibrate_method=calibrate_method,
|
||||
use_external_data_format=use_external_data_format,
|
||||
extra_options=calib_extra_options,
|
||||
)
|
||||
calibrator.collect_data(calibration_data_reader)
|
||||
tensors_range = calibrator.compute_range()
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="ort.quant.") as quant_tmp_dir:
|
||||
calibrator = create_calibrator(
|
||||
model,
|
||||
op_types_to_quantize,
|
||||
augmented_model_path=Path(quant_tmp_dir).joinpath("augmented_model.onnx").as_posix(),
|
||||
calibrate_method=calibrate_method,
|
||||
use_external_data_format=use_external_data_format,
|
||||
extra_options=calib_extra_options,
|
||||
)
|
||||
calibrator.collect_data(calibration_data_reader)
|
||||
tensors_range = calibrator.compute_range()
|
||||
|
||||
check_static_quant_arguments(quant_format, activation_type, weight_type)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue