mindspore.ops.bitwise_left_shift

mindspore.ops.bitwise_left_shift(input, other)[源代码]

逐元素对输入 input 进行左移位运算, 移动的位数由 other 指定。

\[\begin{aligned} &out_{i} =input_{i} << other_{i} \end{aligned}\]
参数:
  • input (Union[Tensor, int, bool]) - 被左移的输入。

  • other (Union[Tensor, int, bool]) - 左移的位数。

返回:

Tensor,左移位运算后的结果。

异常:
  • TypeError - inputother 都不是Tensor。

  • TypeError - inputother 不是bool、int、int类型的Tensor或uint类型的Tensor。

  • TypeError - inputother 的数据类型不相同。

  • ValueError - input 的shape 与 other 的shape不能进行广播。

支持平台:

Ascend GPU CPU

样例:

>>> 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]