mindspore.ops.LeftShift

View Source On Gitee
class mindspore.ops.LeftShift[source]

Shift the value of each position of the tensor to the left several bits. The inputs are two tensors, dtypes of them must be consistent, and the shapes of them could be broadcast. The output does not support implicit type conversion.

\[\begin{aligned} &out_{i} =x_{i} << y_{i} \end{aligned}\]

Warning

This is an experimental API that is subject to change or deletion.

Inputs:
  • x1 (Tensor) - The target tensor whose dtype supports all int and uint type, will be shifted to the left by x2 in element-wise.

  • x2 (Tensor) - The tensor must have the same dtype as x1. And the tensor must have the same shape as x1 or could be broadcast with x1.

Outputs:
  • output (Tensor) - The output tensor, has the same dtype as x1. And the shape of the output tensor is the same shape as x1, or the same shape as x1 and x2 after broadcasting.

Raises
Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> left_shift = ops.LeftShift()
>>> x1 = Tensor(np.array([1, 2, 3]).astype(np.int8))
>>> x2 = Tensor(np.array([0, 1, -1]).astype(np.int8))
>>> output = left_shift(x1, x2)
>>> print(output)
[1 4 0]