Skip to content
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

[QNN] Align output_scale/zero_point of sigmoid to Torch #12624

Merged
merged 2 commits into from
Aug 29, 2022

Conversation

zhaoyang-star
Copy link
Contributor

@zhaoyang-star zhaoyang-star commented Aug 27, 2022

Align output_scale/zero_point of sigmoid to Torch.
cc @masahi

@github-actions github-actions bot requested a review from masahi August 28, 2022 02:05
@masahi
Copy link
Member

masahi commented Aug 29, 2022

Interesting, this might explain the large accuracy difference I saw between TVM and PT when running quantized mobilenet v3 model.

output_scale = _expr.const(inputs[1])
output_zero_point = _expr.const(inputs[2])
input_scale = _expr.const(inputs[3])
input_zero_point = _expr.const(inputs[4])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that output params occur before input? Your change seem to be calling _add_output_quant_params_to_sigmoid_op after we call _get_quant_param_for_input, which adds the input qparams first?.

Copy link
Contributor Author

@zhaoyang-star zhaoyang-star Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. One example printing the inputs[1-4] is 0.00390625, 0, 0.09818686544895172, 96 , in which 0.00390625, 0 are the fixed output's scale/zp.
The index of output quantized params is set on Line 275: "aten::sigmoid": (1, 2),

@masahi masahi merged commit c5c99a4 into apache:main Aug 29, 2022
@zhaoyang-star zhaoyang-star deleted the fix_qnn_sigmoid branch August 30, 2022 00:55
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
* [QNN] Align output_scale/zero_point of sigmoid to Torch

* [QNN] Align output_scale/zero_point of sigmoid to Torch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants