mindspore.numpy.cumsum
- mindspore.numpy.cumsum(a, axis=None, dtype=None)[source]
Returns the cumulative sum of the elements along a given axis.
Note
If
a.dtype
is int8, int16 or bool, the result dtype will be elevated to int32.- Parameters
a (Tensor) – Input tensor.
axis (int, optional) – Axis along which the cumulative sum is computed. The default (
None
) is to compute the cumsum over the flattened array.dtype (
mindspore.dtype
, optional) – If not specified, stay the same as a, unless a has an integer dtype with a precision less than that of the default platform integer. In that case, the default platform integer is used. Default:None
.
- Returns
Tensor.
- Raises
TypeError – If input arguments have types not specified above.
ValueError – If axis is out of range.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> output = np.cumsum(np.ones((3,3)), axis=0) >>> print(output) [[1. 1. 1.] [2. 2. 2.] [3. 3. 3.]]