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
[quant] Add quantized Sigmoid module #45883
Conversation
Summary: Test Plan: python test/test_quantization.py TestStaticQuantizedModule.test_sigmoid Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Codecov Report
@@ Coverage Diff @@
## gh/jerryzh168/454/base #45883 +/- ##
=======================================================
Coverage 68.33% 68.33%
=======================================================
Files 410 410
Lines 52997 53008 +11
=======================================================
+ Hits 36213 36222 +9
- Misses 16784 16786 +2
Continue to review full report at Codecov.
|
zero_point: quantization zero point of the output tensor | ||
""" | ||
|
||
def __init__(self, output_scale: float, output_zero_point: int): |
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.
Can we have default args? It is safe to assume those for this function
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.
not sure, it's not likely that user is going to construct quantized model from quantized modules from scratch anyways, what is the benefit of having default args?
Summary: Test Plan: python test/test_quantization.py TestStaticQuantizedModule.test_sigmoid Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D24129116](https://our.internmc.facebook.com/intern/diff/D24129116) [ghstack-poisoned]
Summary: Test Plan: python test/test_quantization.py TestStaticQuantizedModule.test_sigmoid Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D24129116](https://our.internmc.facebook.com/intern/diff/D24129116) [ghstack-poisoned]
This pull request has been merged in 83d2c9a. |
@@ -149,3 +149,24 @@ def _get_name(self): | |||
def from_float(cls, mod): | |||
scale, zero_point = mod.activation_post_process.calculate_qparams() | |||
return cls(float(scale), int(zero_point), mod.negative_slope, mod.inplace) | |||
|
|||
class Sigmoid(torch.nn.Sigmoid): | |||
r"""This is the quantized equivalent of :class:`~torch.nn.LeakyReLU`. |
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.
The docs are off here, can we refer to sigmoid instead of leakyRelu?
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.
oh sorry, will fix in next PR
Stack from ghstack:
Summary:
Test Plan:
python test/test_quantization.py TestStaticQuantizedModule.test_sigmoid
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: D24129116