mindspore.ops.Cummax

View Source On Gitee
class mindspore.ops.Cummax(axis)[source]

Returns the cumulative maximum of elements and the index.

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

Parameters

axis (int) – The axis to accumulate the tensor’s value. Must be in the range [-rank(input), rank(input)).

Inputs:
  • input (Tensor) - The input tensor.

Outputs:

A tuple of 2 Tensors(values, indices), containing the cumulative maximum of elements and the index, The shape of each output tensor is the same as input input.

Supported Platforms:

GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor
>>> import mindspore.ops as ops
>>> cummax = ops.Cummax(axis=0)
>>> x = Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32))
>>> output = cummax(x)
>>> print(output[0])
[[ 3.  4.  6. 10.]
 [ 3.  6.  7. 10.]
 [ 4.  6.  8. 10.]
 [ 4.  6.  8. 10.]]
>>> print(output[1])
[[0 0 0 0]
 [0 1 1 0]
 [2 1 2 0]
 [2 1 2 0]]