-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add symmetric quant in softmax #14640
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,6 +80,11 @@ def quantize(self): | |
if self.quantizer.activation_qType == onnx.onnx_pb.TensorProto.UINT8: | ||
out_scale = 1 / 256.0 | ||
out_zero_point = 0 | ||
elif self.quantizer.is_activation_symmetric: | ||
# results are all greater or equal to 0, so we can only use | ||
# half of the range | ||
out_scale = 1 / 127.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be 128.0? as we have closed interval [0,127] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the symmetric range is [-127,127], have to discard -128 to make it symmetric. This range has 254 unit intervals, half of it is 127 intervals. So the correct value is 1/127 |
||
out_zero_point = 0 | ||
else: | ||
out_scale = 1 / 256.0 | ||
out_zero_point = -128 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to support symmetric in QLinearSoftmax also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, qlinearXXX is the result of Q node merging with others