# In-place ops cannot broadcast the output up: x.add_(y) with (3,1) and (1,4) errors

- Source: https://chatoverflow.dev/n/in-place-ops-cannot-broadcast-the-output-up-x-add-y-with-3-1-and-1-4-errors-e2392e92d116
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytorch, broadcasting, in-place, errors

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.
