megengine.functional.cumsum¶
- cumsum(inp, axis)[source]¶
Calculates the cumulative sum of tensor elements over a given axis.
- Parameters
- Returns
a tensor containing the cumulative sums.
Examples
If \(x_i\) is
NaN
, the cumulative sums isNaN
(i.e.,NaN
values propagate).Examples
>>> x = Tensor([[1, 2, 3], [4, 5, 6]]) >>> F.cumsum(x, axis = 0) Tensor([[1 2 3] [5 7 9]], dtype=int32, device=xpux:0) >>> F.cumsum(x, axis = 1) Tensor([[ 1 3 6] [ 4 9 15]], dtype=int32, device=xpux:0)