First thing that comes to mind:
# length 10 vector
ten = torch.ones((10))
# 128x10x512 tensor
big = torch.ones((128,10,512))

result = (big*ten.view(1,-1,1)).sum(1).flatten()

We reshape the tensor to be 1x10x1 to align with the other one. Then we sum across that dimension and flatten.
Makes sense?