fn
bitwise_left_shift
→Tensorbitwise_left_shift(input: Tensor, other: Tensor | Scalar)Element-wise bitwise left shift.
Shifts the bits of input to the left by other positions, filling
vacated low-order bits with zero. Equivalent to integer multiplication by
modulo the dtype width.
Parameters
inputTensorLeft operand. Must have integer dtype.
otherTensor or scalarNumber of positions to shift. Must be a non-negative integer; shifting by
more than the bit-width of
input is undefined and clamped or wrapped
depending on the underlying integer dtype.Returns
TensorShifted tensor with shape broadcast(input.shape, other.shape).
Notes
Mathematical definition (modulo the dtype's bit width ):
High-order bits are lost on overflow. Not differentiable.
Examples
>>> import lucid
>>> a = lucid.tensor([1, 2, 4], dtype=lucid.int32)
>>> lucid.bitwise_left_shift(a, 2)
Tensor([4, 8, 16])