cummin

paddle. cummin ( x, axis=None, dtype='int64', name=None ) [source]

The cumulative min of the elements along a given axis.

Note

The first element of the result is the same as the first element of the input.

Parameters
  • x (Tensor) – The input tensor needed to be cummined.

  • axis (int, optional) – The dimension to accumulate along. -1 means the last dimension. The default (None) is to compute the cummin over the flattened array.

  • dtype (str, optional) – The data type of the indices tensor, can be int32, int64. The default value is int64.

  • name (str, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

out (Tensor), The result of cummin operation. The dtype of cummin result is same with input x.

indices (Tensor), The corresponding index results of cummin operation.

Examples

>>> import paddle
>>> data = paddle.to_tensor([-1, 5, 0, -2, -3, 2])
>>> data = paddle.reshape(data, (2, 3))

>>> value, indices = paddle.cummin(data)
>>> value
Tensor(shape=[6], dtype=int64, place=Place(cpu), stop_gradient=True,
[-1, -1, -1, -2, -3, -3])
>>> indices
Tensor(shape=[6], dtype=int64, place=Place(cpu), stop_gradient=True,
[0, 0, 0, 3, 4, 4])

>>> value, indices = paddle.cummin(data, axis=0)
>>> value
Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
[[-1,  5,  0],
 [-2, -3,  0]])
>>> indices
Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
[[0, 0, 0],
 [1, 1, 0]])

>>> value, indices = paddle.cummin(data, axis=-1)
>>> value
Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
[[-1, -1, -1],
 [-2, -3, -3]])
>>> indices
Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True,
[[0, 0, 0],
 [0, 1, 1]])

>>> value, indices = paddle.cummin(data, dtype='int64')
>>> assert indices.dtype == paddle.int64