-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add TORCH_CHECK to disable sub for bool tensors #23335
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
gchanan
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.
we should have a real error message that indicates we don't plan to support bool; as it is currently it can seem like a mistake.
3162916 to
7daa610
Compare
izdeby
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.
Can you, please, add tests?
colesbury
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.
This seems unnecessarily complicated to me:
The check for subtraction on bool data dtypes should just be in BinaryOps.cpp (not in the kernels). A
TORCH_CHECK(iter.dtype() != kBool, "sub is not supported on bool tensors");
should suffice.
Please do not template these kernels on "bool add".
7013b6a to
32f9ae4
Compare
d0570da to
6b5e9c4
Compare
|
@pytorchbot retest this please |
facebook-github-bot
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.
@izdeby has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
aten/src/ATen/native/BinaryOps.cpp
Outdated
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 correct. ~ is not the correct suggestion for boolTensor - boolTensor (there are two boolean operands!), but it is temporarily for "1 - boolTensor", which is intended to invert the values.
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.
How about this:
if both operands are bool:
your error message, but with `^` instead as the suggestion.
if one operand is bool:
"Subtraction, the `-` operator, with a bool tensor is not supported. If you are trying to invert a mask, use the `~` or `bitwise_not()` operator instead."
|
@xuhdev are you going to adjust the error message for |
|
@colesbury I think I messed git on my side. Will reopen a PR. |
This resolves two issues in one shot:
shows "add_cpu/add_cuda is not implemented for [type]". They should be
"sub_cpu/sub_cuda" instead.