Hi Elkop!



 elkop:

s = torch.split(a, k)
cumsum = torch.stack(s).cumsum(dim=1)
sum = torch.cat(torch.unbind(cumsum))



The following is, in essence, the same as your solution, but it might
be a bit more efficient to replace your cat / unbind / stack / split
processing with reshape() and flatten():
>>> import torch
>>> torch.__version__
'1.9.0'
>>> k = 3
>>> a = torch.tensor ([1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> sum = a.reshape (k, a.numel() // k).cumsum (dim = 1).flatten()
>>> sum
tensor([ 1,  3,  6,  4,  9, 15,  7, 15, 24])

Best.
K. Frank