mindspore.ops.bitwise_left_shift

View Source On Gitee
mindspore.ops.bitwise_left_shift(input, other)[source]

Perform a left bitwise shift operation on the input element-wise, where the number of bits to shift is specified by other.

\[\begin{aligned} &out_{i} =input_{i} << other_{i} \end{aligned}\]
Parameters
  • input (Union[Tensor, int, bool]) – The input to be left shifted.

  • other (Union[Tensor, int, bool]) – The number of bit to be applied on left arithmetic shift.

Returns

Tensor, the result after bitwise left shift.

Raises
  • TypeError – If neither input nor other is a tensor.

  • TypeError – If either input or other is not a bool, int or a tensor of dtype: int or uint.

  • TypeError – If input and other do not have the same dtype.

  • ValueError – If input and other could not be broadcast.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([1024, 2]), mindspore.int16)
>>> other = Tensor(np.array([2]), mindspore.int16)
>>> output = ops.bitwise_left_shift(input, other)
>>> print(output)
[4096    8]