mindspore.ops.CumSum
- class mindspore.ops.CumSum(*args, **kwargs)[source]
Computes the cumulative sum of input tensor along axis.
\[y_i = x_1 + x_2 + x_3 + ... + x_i\]- Parameters
- Inputs:
input (Tensor) - The input tensor to accumulate.
axis (int) - The axis to accumulate the tensor’s value. Only constant value is allowed. Must be in the range [-rank(input), rank(input)).
- Outputs:
Tensor, the shape of the output tensor is consistent with the input tensor’s.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> input = Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32)) >>> cumsum = ops.CumSum() >>> output = cumsum(input, 1) >>> print(output) [[ 3. 7. 13. 23.] [ 1. 7. 14. 23.] [ 4. 7. 15. 22.] [ 1. 4. 11. 20.]]