Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tools/quantize/quantize-ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import onnx
from onnx import version_converter
import onnxruntime
from onnxruntime.quantization import quantize_static, CalibrationDataReader, QuantType, QuantFormat
from onnxruntime.quantization import quantize_static, CalibrationDataReader, QuantType, QuantFormat, quant_pre_process

from transform import Compose, Resize, CenterCrop, Normalize, ColorConvert, HandAlign

Expand Down Expand Up @@ -76,6 +76,7 @@ def check_opset(self):
def run(self):
print('Quantizing {}: act_type {}, wt_type {}'.format(self.model_path, self.act_type, self.wt_type))
new_model_path = self.check_opset()
quant_pre_process(new_model_path, new_model_path)
output_name = '{}_{}.onnx'.format(self.model_path[:-5], self.wt_type)
quantize_static(new_model_path, output_name, self.dr,
quant_format=QuantFormat.QOperator, # start from onnxruntime==1.11.0, quant_format is set to QuantFormat.QDQ by default, which performs fake quantization
Expand Down