-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Delegate Python ~ (invert operator) to Tensor.bitwise_not(). #22326
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
|
This commit changes the Previously, as discussed in #4082, |
| auto& self_ = reinterpret_cast<THPVariable*>(self)->cdata; | ||
| if (self_.scalar_type() != at::kByte) { | ||
| throw TypeError("~ (operator.invert) is only implemented on byte tensors"); | ||
| if (!isIntegralType(self_.scalar_type()) && self_.scalar_type() != at::kBool) { |
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.
Why isn't bool an integral type? It's not different than uint1
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.
It's defined here. It's probably worth another independent PR for discussing it...
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.
It looks like current usage and definition of isIntegralType are more of semantic sense (bool is technically integral, but semantically it is not used as an integer). I would lean toward keep it as it is now.
Examples:
if (isIntegralType(iter.dtype())) { if (var.dim() == 0 && at::isIntegralType(scalar_type)) {
|
@pytorchbot retest this please |
1 similar comment
|
@pytorchbot retest this please |
|
@xuhdev is this stack of PRs ready? |
|
@colesbury Yes. |
|
@pytorchbot merge this please |
|
@colesbury merged this pull request in 9c4c9c3. |
|
I'm reverting this for now. The problem is that comparison operators still return torch.uint8 and now |
Stack from ghstack:
Close #20024, Close #22246, Close #22262
Related #22324
Differential Revision: D16183577