-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
[primTorch] special: ndtr, ndtri, log_ndtr, erfcx #86077
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/86077
Note: Links to docs will display an error until the docs builds have been completed. ✅ No Failures, 1 PendingAs of commit 78a25b9: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
/easycla As part of the transition to the PyTorch Foundation, this project now requires contributions be covered under the new CLA. See #85559 for additional details. This comment will trigger a new check of this PR. If you are already covered, you will simply see a new "EasyCLA" check that passes. If you are not covered, a bot will leave a new comment with a link to sign. |
torch/_refs/special/__init__.py
Outdated
type_promotion_kind=utils.ELEMENTWISE_TYPE_PROMOTION_KIND.INT_TO_FLOAT, | ||
) | ||
def ndtr(a: TensorLikeType) -> TensorLikeType: | ||
a_sqrt_2 = a / 1.414213562373095048801688724209698 |
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.
This doesn't look right -- shouldn't this expression be a * M_SQRT1_2
?
pytorch/aten/src/ATen/native/UnaryOps.cpp
Line 570 in 2a88f1b
auto x_sqrt_2 = self * M_SQRT1_2; |
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.
Hi, @mruberry! Thanks for the question. I believe the formula is right:
Here, it's a * M_SQRT1_2
, where M_SQRT1_2 is 1/√2
= 0.70710678118654752440
.
And in my impl, I had implemented it as a / √2
; √2
= 1.414213562373095048801688724209698
.
Anyways, I've updated as per the previous implementation by assigning objects to the constant :)
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.
That makes sense but maybe the multiplication is preferable? Multiplication is typically faster than division
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 appreciate your input! I've updated using multiplication :p Thank you :)
Hi, @mruberry! Gentle ping, please take another look. Thanks |
9e03ff2
to
4cc77e0
Compare
Hi, Gentle ping, @mruberry! |
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.
LGTM!
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Hey @khushi-411. |
erfcx
andndtri
.ndtr
, andlog_ndtr
.cc @kshitij12345 @lezcano @mruberry