-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Let logical_xor support non-bool tensors (again) #27248
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
|
There are some issues with tests |
|
@pytorchbot retest this please |
|
We do not support Byte output for logical operation any more. So some test are failing. |
Even if we do |
|
@ifedan I changed the test |
|
You have some failures in tests, because for inplace operation a.op_(b) we expect that a and b has same dtype, otherwise it's possible to get an overflow(Example: 'a' is uint8, 'b' is float32. 'a' will be promoted to float32 and the result will be also float32. Then it will be casted back to uint8 so potential for overflow). So we check that both dtypes of a and b are same |
|
@ifedan I've updated the overtest again. Thanks! |
|
logical_xor_cpu is not implemented for 'Half' |
|
Updated again |
ca49c76 to
5ea8a22
Compare
|
I skipped the test case where the dtype of either operand is |
893ab03 to
b9ae14f
Compare
|
@pytorchbot rebase this please |
f362a5a reverted 5ca612b due to build time conerns (also see pytorch#25254). Now we come back to this by reusing the underlying code in comparison operators: Logical operators on non-bool variables are essentially comparison operators that semantically output bool values. Compared with the previous implementation, we compromise by always applying XOR on the same input type, while output can be either the input type or the bool type.
|
@pytorchbot merge 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.
@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: f362a5a04b3708355b08e5c1285e46ca1b537ad6 reverted 5ca612b55ec1205f98e6bc5d5e64b1bf35f3b3cd due to build time conerns (also see pytorch/pytorch#25254). Now we come back to this by reusing the underlying code in comparison operators: Logical operators on non-bool variables are essentially comparison operators that semantically output bool values. Compared with the previous implementation, we compromise by always applying XOR on the same input type, while output can be either the input type or the bool type. Pull Request resolved: pytorch/pytorch#27248 Differential Revision: D17929356 Pulled By: ezyang fbshipit-source-id: dbac08c7614b36f05d24c69104fee9df9ca523d5
| Tensor& comparison_op_out(Tensor& result, const Tensor& self, const Tensor& other, Stub& stub) { | ||
| TORCH_CHECK(result.scalar_type() == kBool, | ||
| "The output tensor of lt must be a bool, but was ", result.scalar_type()); | ||
| "The output tensor of a comparison or logical op must be a bool, but was ", result.scalar_type()); |
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'm confused -- the documentation shows the output being uint8, but this error messages says it can be a bool. What's up?
| for other_dtype in torch.testing.get_all_dtypes(): | ||
| # Skip bfloat16 on CUDA | ||
| if device != 'cpu' and torch.bfloat16 in (dtype, other_dtype): | ||
| continue |
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 generally don't test like this -- it's not good because we will eventually enable this op but we won't realize we need to enable testing. It's much better to assert that the test throws, so when we add support we are forced to test it.
Following up pytorch#27248 per suggestion by @gchanan
Summary: f362a5a reverted 5ca612b due to build time conerns (also see pytorch#25254). Now we come back to this by reusing the underlying code in comparison operators: Logical operators on non-bool variables are essentially comparison operators that semantically output bool values. Compared with the previous implementation, we compromise by always applying XOR on the same input type, while output can be either the input type or the bool type. Pull Request resolved: pytorch#27248 Differential Revision: D17929356 Pulled By: ezyang fbshipit-source-id: dbac08c7614b36f05d24c69104fee9df9ca523d5
Summary: Following up pytorch#27248. per suggestion by gchanan Pull Request resolved: pytorch#28031 Differential Revision: D17962226 Pulled By: gchanan fbshipit-source-id: 788e4e1fc78b1cfc7915aedaa10c8656b19edc4d
f362a5a reverted
5ca612b due to build time conerns (also
see #25254). Now we come back to this by reusing the underlying code in
comparison operators: Logical operators on non-bool variables are
essentially comparison operators that semantically output bool
values. Compared with the previous implementation, we compromise by
always applying XOR on the same input type, while output can be either
the input type or the bool type.