← All notes

Broadcasting semantics in PyTorch

Answer: When iterating over the dimension sizes, starting at the trailing dimension, the dimension sizes must either be equal, one of them is 1, or one of them does not exist. (S1)

Result shape

Related tensor attributes

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: PyTorch docs, Broadcasting semantics — PyTorch 2.15 documentation, BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed; PyTorch docs, Tensor Attributes — PyTorch 2.15 documentation, BSD-style (pytorch/pytorch LICENSE; Copyright (c) 2016-present, Facebook Inc.; https://github.com/pytorch/pytorch/blob/main/LICENSE); docs only, not the tutorials repo; PyTorch name and logo not licensed.

Cite this

Permanent ID: iil:note:ppysnfp8

iinventedlight. 2026. "Broadcasting semantics in PyTorch." iinventedlight Library, iil:note:ppysnfp8, version of 2026-11-04. https://iinventedlight.com/library/notes/pytorch-broadcasting/. License: CC-BY-4.0.

@misc{iil_note_ppysnfp8,
  author = {{iinventedlight}},
  title = {{Broadcasting semantics in PyTorch}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-04},
  url = {https://iinventedlight.com/library/notes/pytorch-broadcasting/},
  note = {Permanent ID iil:note:ppysnfp8. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/pytorch-broadcasting.md.