Bitwise operations in Pytorch
Could someone help me how to perform bitwise  AND operations on two tensors in Pytorch 1.4?

Apparently I could only find NOT and XOR operations in official document  



I don't see them in the docs, but it looks like &amp;, |, __and__, __or__, __xor__, etc are bit-wise:

&gt;&gt;&gt; torch.tensor([1, 2, 3, 4]).__xor__(torch.tensor([1, 1, 1, 1]))
tensor([0, 3, 2, 5])
&gt;&gt;&gt; torch.tensor([1, 2, 3, 4]) | torch.tensor([1, 1, 1, 1])
tensor([1, 3, 3, 5])
&gt;&gt;&gt; torch.tensor([1, 2, 3, 4]) &amp; torch.tensor([1, 1, 1, 1])
tensor([1, 0, 1, 0])
&gt;&gt;&gt; torch.tensor([1, 2, 3, 4]).__and__(torch.tensor([1, 1, 1, 1]))
tensor([1, 0, 1, 0])


See https://github.com/pytorch/pytorch/pull/1556
