mindspore.ops.rot90
- mindspore.ops.rot90(input, k, dims)[source]
Rotate a n-D tensor by 90 degrees in the plane specified by dims axis. Rotation direction is from the first towards the second axis if k > 0, and from the second towards the first for k < 0.
- Parameters
- Returns
Tensor.
- Raises
TypeError – If input is not a Tensor.
TypeError – If k is not integer.
TypeError – If dims is not tuple of integers or list of ints.
ValueError – If the length of dims is not 2.
ValueError – If any dims is out of Tensor's range [-input.ndim, input.ndim).
RuntimeError – If rotation dims are not different.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import numpy as np >>> from mindspore import Tensor, ops >>> x = Tensor(np.array([[0, 1], [2, 3]])).astype(np.float32) >>> k = 1 >>> dims = [0, 1] >>> output = ops.rot90(x, k, dims) >>> print(output) [[1. 3.] [0. 2.]]