Libtorch no boolean not operator

Would be useful to be able to do !tensor for a boolean tensor. Also, there’s no unary not for integers, but this is less important (for my use).

We don’t have ‘!’ or ‘not’ operator support on tensors in c++ apis. (you can do this in python version when tensor has only 1 item)
You can file a feature issue here ‘’ and put a label operator on the issue. We will triage it.

if b - boolean var, than not_b = 1 - b or not_b = 1 ^ b; But ‘-’ operator is prohibited for boolean tensors, so:

(if B - boolean tensor) at::Tensor not_B = torch::ones_like(B) ^ B;

Hope this helps.