fn
bitwise_right_shift
→Tensorbitwise_right_shift(input: Tensor, other: Tensor | Scalar)Element-wise bitwise right shift.
Shifts the bits of input to the right by other positions. For signed
integer dtypes the shift is arithmetic (sign-extending); for unsigned dtypes
it is logical (zero-filling).
Parameters
inputTensorLeft operand. Must have integer dtype.
otherTensor or scalarNumber of positions to shift. Must be a non-negative integer.
Returns
TensorShifted tensor with shape broadcast(input.shape, other.shape).
Notes
Mathematical definition (signed, with floor division):
Shifting by an amount greater than or equal to the dtype's bit width is undefined behaviour and should be avoided. Not differentiable.
Examples
>>> import lucid
>>> a = lucid.tensor([8, 16, 32], dtype=lucid.int32)
>>> lucid.bitwise_right_shift(a, 2)
Tensor([2, 4, 8])