Implementing NumPy-like function torch.signbit()#41589
Implementing NumPy-like function torch.signbit()#41589Kiyosora wants to merge 5 commits intopytorch:masterfrom
Conversation
💊 CI failures summary and remediationsAs of commit 9db39c6 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
🚧 3 fixed upstream failures:These were probably caused by upstream breakages that were already fixed.
Please rebase on the
|
eb278ce to
bd179e2
Compare
|
Hi, @mruberry ! I implemented the |
bd179e2 to
b65627a
Compare
Great! Thanks @Kiyosora! I'll take a look soon. |
ailzhang
left a comment
There was a problem hiding this comment.
stamping for xla fix :D Thanks!
mruberry
left a comment
There was a problem hiding this comment.
Thank you, @ailzhang, for helping with the XLA dispatch!
This is a well-written PR, @Kiyosora, thanks for submitting it!
I made a few comments about the test and docs, but also have a question about the design of this PR: does it need a new TensorIterator kernel, or can it be implemented using existing PyTorch functions? I'm curious to hear your thoughts.
7b76fb9 to
359d5d1
Compare
|
Hi, @mruberry ! Thank you so much for your advice & Sorry for my late reply. 😢 |
There was a problem hiding this comment.
It's true that clamp is not implemented for complex tensors, but this should probably say:
"signbit is not implemented for complex tensors."
No need for a "yet," either, since we have no plans to implement it in the future -- it's not even clear how to define a function like signbit on complex values. NumPy, for example, also throws an error when signbit is given a complex input.
There was a problem hiding this comment.
Also: better add a check that result is bool
There was a problem hiding this comment.
Addressed! Thanks for the correction.
There was a problem hiding this comment.
This doesn't need to promote inputs or cast to an output. There's only one input and for this first iteration signbit doesn't need to support non-bool outputs.
There was a problem hiding this comment.
Got it! thanks for your explanation.
There was a problem hiding this comment.
(Tensor self), no star needed here
There was a problem hiding this comment.
\operatorname{signbit} ?
There was a problem hiding this comment.
The formulas has been deleted, Sorry for my carelessness.
There was a problem hiding this comment.
This regexes will need to be updated to refer to signbit
mruberry
left a comment
There was a problem hiding this comment.
Overall looks very good!
I made a few comments with updates/corrections.
5e95f7f to
775f095
Compare
|
Hi, @mruberry. I'm sorry that my carelessness caused some avoidable mistakes. |
775f095 to
9db39c6
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: - Related with pytorch#38349 - Implementing the NumPy-like function `torch.signbit()` . Pull Request resolved: pytorch#41589 Reviewed By: albanD Differential Revision: D22835249 Pulled By: mruberry fbshipit-source-id: 7988f7fa8f591ce4b6a23ac884ee7b3aa718bcfd
torch.signbit().