Hi Marek!



 Marek_Balaz:

how to compute this case without any for loop?


Use unfold() to generate the correct “slices” of t1:
>>> import torch
>>> torch.__version__
'1.9.0'
>>> t1 = torch.tensor([1, 2, 3, 4, 5])
>>> t2 = torch.tensor([1, 2, 1])
>>> t1.unfold (0, 3, 1) @ t2
tensor([ 8, 12, 16])

You could also use conv1d() if you unsqueeze() t1 and t2 to add
the required singleton dimensions.
Best.
K. Frank