cumsum¶
dragon.vm.torch.
cumsum
(
input,
dim,
out=None
)[source]¶Compute the cumulative sum of elements along the given dimension.
dim
could be negative:# A negative dimension is the last-k dimension x = torch.tensor([[1, 2, 3], [4, 5, 6]]) print(torch.cumsum(x, dim=1)) # [[1, 3, 6], [4, 9, 15]] print(torch.cumsum(x, dim=-1)) # Equivalent
- Parameters:
- input (dragon.vm.torch.Tensor) – The input tensor.
- dim (int) – The cumulative dimension.
- out (dragon.vm.torch.Tensor, optional) – The output tensor.
- Returns:
dragon.vm.torch.Tensor – The output tensor.