You can try the following
sums = x.cumsum(0)
sums = sums[y,:]
sums0=torch.zeros(sums.size())
nrows = y.size
index = torch.LongTensor(range(1,nrows))
sums0.index_copy_(0,index, sums[range(nrows-1),:])
cum_pos_lik = sums-sums0