Is there a verctorized approach in PyTorch to get this result?
I would like to get this result with torch functions. Do you have suggestions?
import torch
test_tensor=torch.tensor([[1,  2,  3, 4,  5,  6],
                         [7,  8,  9, 10,  11,  12]]
                        )
print(test_tensor)
'''
I would like to get:
t_1 = torch.tensor([[6], #1+2+3
                  [24]])#7+8+9
t_2 = torch.tensor([[9], #1+3+5
                  [27]])#7+9+11
'''


Using standard Python stride notation
import torch
test_tensor=torch.tensor([[1,  2,  3, 4,  5,  6],
                         [7,  8,  9, 10,  11,  12]]
                        )

t1 = test_tensor[:, :3].sum(dim=1)
print(t1)
t2 = test_tensor[:, ::2].sum(dim=1)
print(t2)

