mindspore.mint.cummax

View Source On AtomGit
mindspore.mint.cummax(input, dim)[source]

Return the cumulative maximum values and their indices along the given dimension of the tensor.

\[\begin{split}\begin{array}{ll} \\ y_{i} = \max(x_{1}, x_{2}, ... , x_{i}) \end{array}\end{split}\]

Note

GE backend is not supported in Ascend.

Parameters
  • input (Tensor) – The input tensor.

  • dim (int) – The dimension to compute the cumulative maximum along.

Returns

Tuple(max, max_indices) of 2 tensors.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> x = mindspore.tensor([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]])
>>> mindspore.mint.cummax(x, dim=0)
(Tensor(shape=[4, 4], dtype=Int64, value=
[[ 3,  4,  6, 10]
 [ 3,  6,  7, 10]
 [ 4,  6,  8, 10]
 [ 4,  6,  8, 10]]),
Tensor(shape=[4, 4], dtype=Int64, value=
[[0, 0, 0, 0]
 [0, 1, 1, 0]
 [2, 1, 2, 0]
 [2, 1, 2, 0]]))
>>> mindspore.mint.cummax(x, dim=1)
(Tensor(shape=[4, 4], dtype=Int64, value=
[[ 3,  4,  6, 10]
 [ 1,  6,  7,  9]
 [ 4,  4,  8,  8]
 [ 1,  3,  7,  9]]),
Tensor(shape=[4, 4], dtype=Int64, value=
[[0, 1, 2, 3]
 [0, 1, 2, 3]
 [0, 0, 2, 2]
 [0, 1, 2, 3]]))