This may have already been addressed, but I did some googling and couldn’t find a solution. I’d like to compute various sums from unequal sized subsets of a given tensor (or more precisely from a column vector) where the summing index boundaries are defined by a list (or tensor) and then to have the operation return a tensor of these sums  (without using a for loop)
torch.split does almost exactly what I want but it returns a list, for example
a=torch.tensor([[1,2,3,4,5,6,7,8]])
print(torch.split(a,[2,2,4],dim=1))
returns the following lists
(tensor([[1, 2]]), tensor([[3, 4]]), tensor([[5, 6, 7, 8]]))
what I want is a tensor whose elements are the sums of those individual lists
i.e tensor([[3,7,26]]) .
Is it possible to do this in a vectorized way using torch operations? also I’d like to do the same thing but with a product over the subsets and return a tensor of the products.
Much thanks in advance!