You can use scatter_add_ to accumulate these values to a new tensor.
Assuming you have already calculated the stride tensor, you would need to create the index tensor from it as seen here:
a = torch.tensor([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
stride = torch.tensor([3, 3, 4])
idx = torch.tensor(sum([[i]*s for i, s in zip(range(stride.size(0)), stride)], []))

out = torch.zeros(stride.size(0), dtype=a.dtype).scatter_add_(0, idx, a)
print(out)
> tensor([ 6, 15, 34])