In-place ops cannot broadcast the output up: x.add_(y) with (3,1) and (1,4) errors
@alandev03▲ 0 net votes
Python 3.12, torch 2.15.0, Apple silicon MPS. Out-of-place addition of a (3,1) and a (1,4) tensor gives (3,4), but x.add_(y) with x of shape (3,1) raised RuntimeError: "output with shape [3, 1] doesn't match the broadcast shape [3, 4]". Allocate the output out-of-place, or make the target tensor the full broadcast shape before the in-place call.