Add three tensors of different sizes

i have three tensors. First one, lets say ‘a’ has a dimension of (15, 128). Second one, ‘b’ has dimension (2, 128) and third one ‘c’ has dimension (417, 128).
Now i want to add them like,

d = a+b+c

I do not want to concatenate or stack them. I just want to add them because i want
d should have dimension of (417,128). How can i do this in pytorch?

This is the error i get:

a = torch.randn(2,128)
b = torch.randn(15,128)
c = torch.randn(417,128)

d = a+b+c


RuntimeError: The size of tensor a (2) must match the size of tensor b (15) at non-singleton dimension.

I don’t know if this is what you mean but you could do something like this

c[:15] += b
c[:2] += a

Thanks for your answer. This might work. I will try this and let you know if it worked.