ytfeng commited on
Commit
4b236af
·
1 Parent(s): f4c5d90

use QuantFormat.QOperator by default to avoid fake quantization (#88)

Browse files
Files changed (1) hide show
  1. tools/quantize/quantize-ort.py +2 -1
tools/quantize/quantize-ort.py CHANGED
@@ -12,7 +12,7 @@ import cv2 as cv
12
  import onnx
13
  from onnx import version_converter
14
  import onnxruntime
15
- from onnxruntime.quantization import quantize_static, CalibrationDataReader, QuantType
16
 
17
  from transform import Compose, Resize, CenterCrop, Normalize, ColorConvert
18
 
@@ -70,6 +70,7 @@ class Quantize:
70
  self.check_opset()
71
  output_name = '{}-act_{}-wt_{}-quantized.onnx'.format(self.model_path[:-5], self.act_type, self.wt_type)
72
  quantize_static(self.model_path, output_name, self.dr,
 
73
  per_channel=self.per_channel,
74
  weight_type=self.type_dict[self.wt_type],
75
  activation_type=self.type_dict[self.act_type])
 
12
  import onnx
13
  from onnx import version_converter
14
  import onnxruntime
15
+ from onnxruntime.quantization import quantize_static, CalibrationDataReader, QuantType, QuantFormat
16
 
17
  from transform import Compose, Resize, CenterCrop, Normalize, ColorConvert
18
 
 
70
  self.check_opset()
71
  output_name = '{}-act_{}-wt_{}-quantized.onnx'.format(self.model_path[:-5], self.act_type, self.wt_type)
72
  quantize_static(self.model_path, output_name, self.dr,
73
+ quant_format=QuantFormat.QOperator, # start from onnxruntime==1.11.0, quant_format is set to QuantFormat.QDQ by default, which performs fake quantization
74
  per_channel=self.per_channel,
75
  weight_type=self.type_dict[self.wt_type],
76
  activation_type=self.type_dict[self.act_type])