How to use the BitShift operator in Pytorch?
Does anyone has an example of how to use the BitShift operator in Pytorch?


Bitwise shift operator performs element-wise operation.

It works the same way it works in python, and numpy i.e. shift the bits of an integer to the left or right. The &lt;&lt; and &gt;&gt; denotes the left and right shift respectively.
x = torch.tensor([16, 4, 1])
y = torch.tensor([1, 2, 3])
z = x &lt;&lt; y
print(z)
tensor([32, 16,  8])

It's equivalent to 16 &lt;&lt; 1 (np.left_shift(16, 1)), 4 &lt;&lt; 2, and 1 &lt;&lt; 3.

For each input element, if the attribute &quot;direction&quot; is &quot;RIGHT&quot;, this operator moves its binary representation toward the right side so that the input value is effectively decreased. If the attribute &quot;direction&quot; is &quot;LEFT&quot;, bits of binary representation moves toward the left side, which results the increase of its actual value.
This operator supports multidirectional (i.e., Numpy-style) broadcasting.

