Add multiple tensors inplace in PyTorch
I can add two tensors x and y inplace like this

x = x.add(y)


Is there a way of doing the same with three or more tensors given all tensors have same dimensions?

result = torch.sum(torch.stack([x, y, ...]), dim=0)

Without stack:
from functools import reduce

result = reduce(torch.add, [x, y, ...])

EDIT
As @LudvigH pointed out, the second method is not as memory-efficient, as inplace addition. So it's better like this:
from functools import reduce

result = reduce(
    torch.Tensor.add_,
    [x, y, ...],
    torch.zeros_like(x)  # optionally set initial element to avoid changing `x`
)

