mindspore.ops.Roll

class mindspore.ops.Roll(shift, axis)[source]

Rolls the elements of a tensor along an axis.

Refer to mindspore.ops.roll() for more details.

Supported Platforms:

Ascend GPU

Examples

>>> input_x = Tensor(np.array([0, 1, 2, 3, 4]).astype(np.float32))
>>> op = ops.Roll(shift=2, axis=0)
>>> output = op(input_x)
>>> print(output)
[3. 4. 0. 1. 2.]
>>> input_x = Tensor(np.array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]).astype(np.float32))
>>> op = ops.Roll(shift=-1, axis=0)
>>> output = op(input_x)
>>> print(output)
[[5. 6. 7. 8. 9.]
 [0. 1. 2. 3. 4.]]