-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add quantized CELU operator by adding additional parameters to quantized ELU #39199
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
Conversation
[ghstack-poisoned]
Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
ghstack-source-id: f83f79f Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: f83f79f Pull Request resolved: #39200 Added tests ghstack-source-id: f83f79f Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: f83f79f Pull Request resolved: #39202
💊 CI failures summary and remediationsAs of commit d48959e (more details on the Dr. CI page):
XLA failureJob pytorch_xla_linux_bionic_py3_6_clang9_test is failing. Please create an issue with title prefixed by This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 116 times. |
|
there are some failing tests (like https://app.circleci.com/pipelines/github/pytorch/pytorch/174752/workflows/fa9a3d4b-602d-45b3-955f-8c32409c2eb5/jobs/5611015/steps), we should figure out what's going on with them before landing. The failure looks odd to me, do we have a local repro? |
torch/nn/quantized/functional.py
Outdated
| return output | ||
| elif inplace: | ||
| return torch._C._nn.elu_(input, alpha) | ||
| return torch._C._nn.elu_(input, alpha, 1., 1.) |
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.
these have a default of 1 in native_functions.yaml, would it work to revert this and next line?
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.
Sure, I can do that -- I didn't realize the C-style functions could have default arguments.
| } | ||
|
|
||
| Tensor& quantized_celu_(Tensor& self, Scalar alpha) { | ||
| double inv_alpha = 1. / alpha.to<double>(); |
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 verify that division by zero if alpha == 0 gives a good error message?
vkuzo
left a comment
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.
thanks for working on this! in general looks great, we should figure out why the derivative tests are failing before landing
torch/nn/quantized/functional.py
Outdated
| # type: (Tensor, Optional[float], Optional[bool]) -> Tensor | ||
| r"""celu(input, inplace=False) -> Tensor | ||
| Applies the quantized continuously differentiable ELU function element-wise. |
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.
ELU -> CELU
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.
CELU stands for continuously differentiable ELU -- maybe I should capitalize the C to make it clearer this is what I mean?
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 right, missed that! Maybe we should say Continuously Differentiable Exponential Linear Units (CELU)
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 37c1a45 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 37c1a45 Pull Request resolved: #39200 Added tests ghstack-source-id: 37c1a45 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 37c1a45 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 389d2df Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 389d2df Pull Request resolved: #39200 Added tests ghstack-source-id: 389d2df Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 389d2df Pull Request resolved: #39202
|
Changes look good! @vkuzo could you take a look as well? |
|
looks good, can we verify that |
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 9d1f973 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 9d1f973 Pull Request resolved: #39200 Added tests ghstack-source-id: 9d1f973 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 9d1f973 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: c20f914 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: c20f914 Pull Request resolved: #39200 Added tests ghstack-source-id: c20f914 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: c20f914 Pull Request resolved: #39202
|
@vkuzo I added a new error message that's more verbose - "ZeroDivisionError: alpha cannot be 0 in CELU". |
vkuzo
left a comment
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.
looks great! thank you for working on this!
| Scalar scale, | ||
| Scalar input_scale, |
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 you try giving default values to these arguments.
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: f2649e0 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: f2649e0 Pull Request resolved: #39200 Added tests ghstack-source-id: f2649e0 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: f2649e0 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: d75cf20 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: d75cf20 Pull Request resolved: #39200 Added tests ghstack-source-id: d75cf20 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: d75cf20 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: ca5c035 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: ca5c035 Pull Request resolved: #39200 Added tests ghstack-source-id: ca5c035 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: ca5c035 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 447308a Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 447308a Pull Request resolved: #39200 Added tests ghstack-source-id: 447308a Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 447308a Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 2b58934 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 2b58934 Pull Request resolved: #39200 Added tests ghstack-source-id: 2b58934 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 2b58934 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 3a7f60d Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 3a7f60d Pull Request resolved: #39200 Added tests ghstack-source-id: 3a7f60d Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 3a7f60d Pull Request resolved: #39202
| dtype=torch_type) | ||
|
|
||
| # test regular | ||
| qY = torch.nn.quantized.functional.celu(qX, output_scale, output_zero_point, alpha=alpha) |
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.
I believe you can call torch.ops.quantized.celu here instead of functional
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: f70040e Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: f70040e Pull Request resolved: #39200 Added tests ghstack-source-id: f70040e Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: f70040e Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: dc6071a Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: dc6071a Pull Request resolved: #39200 Added tests ghstack-source-id: dc6071a Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: dc6071a Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: 86c2437 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: 86c2437 Pull Request resolved: #39200 Added tests ghstack-source-id: 86c2437 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: 86c2437 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: b92cff1 Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: b92cff1 Pull Request resolved: #39200 Added tests ghstack-source-id: b92cff1 Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: b92cff1 Pull Request resolved: #39202
…s to quantized ELU" Differential Revision: [D21771202](https://our.internmc.facebook.com/intern/diff/D21771202) [ghstack-poisoned]
…zed ELU ghstack-source-id: c5e88ba Pull Request resolved: #39199 Updated ELU to accept additional parameters ghstack-source-id: c5e88ba Pull Request resolved: #39200 Added tests ghstack-source-id: c5e88ba Pull Request resolved: #39201 Improved tests to fail when formula is wrong ghstack-source-id: c5e88ba Pull Request resolved: #39202
Stack from ghstack:
Differential Revision: D21771202