mindspore.mint.flip

mindspore.mint.flip(input, dims)[source]

Reverses the order of elements in a tensor along the given axis.

The shape of the tensor is preserved, but the elements are reordered.

Parameters
  • input (Tensor) – Input tensor.

  • dims (Union[list[int], tuple[int]]) – Axis or axes along which to flip over. Flipping is performed on all of the axes specified in the tuple, If dims is a tuple of integers contains negative, it counts from the last to the first axis.

Returns

Tensor, with the entries of dims reversed.

Raises
Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> from mindspore import mint
>>> import numpy as np
>>> input = mindspore.Tensor(np.arange(1, 9).reshape((2, 2, 2)))
>>> output = mint.flip(input, (0, 2))
>>> print(output)
[[[6 5]
  [8 7]]
 [[2 1]
  [4 3]]]