a = torch.arange(3).unsqueeze(1)
b = torch.arange(4).unsqueeze(0)
c = a + b # works
d = torch.stack([a, b]) # fails because of dimensions
e = torch.stack([a.expand(3, 4), b.expand(3, 4)]) # works
Currently torch.stack requires arguments to be expanded manually, which is not the case for many other operations. It would be nice if it supported broadcasting, if it's easy enough to implement.