Skip to content

docs: document expand/broadcast semantics of einops.repeat - #436

Open
madhavcodez wants to merge 1 commit into
arogozhnikov:mainfrom
madhavcodez:docs/repeat-expand-semantics-351
Open

docs: document expand/broadcast semantics of einops.repeat#436
madhavcodez wants to merge 1 commit into
arogozhnikov:mainfrom
madhavcodez:docs/repeat-expand-semantics-351

Conversation

@madhavcodez

Copy link
Copy Markdown

Per #351, the expand-like behavior of einops.repeat has come up several times in issues and was not stated in the docs. This documents that repeat can introduce axes that are not present in the input and fill them by repetition, covering the numpy.broadcast_to / torch.expand use cases in addition to repeat and tile.

  • Adds one paragraph to the repeat docstring: it can create new output axes by repeating the data, and whether the repeated elements are a materialized copy or a memory-sharing view depends on the backend (numpy returns a copy, some frameworks return an expanded view).
  • Adds broadcast to the operations list in the README, alongside the existing repeat and tile.

Docs only, no behavior change. Happy to drop the README line if you would prefer the docstring change only.

Closes #351

Repeating along a new axis is implemented by broadcasting, which has come up
several times in issues (see arogozhnikov#351). Document in the repeat docstring that a new
output-only axis is added and filled by broadcasting (covering the
numpy.broadcast_to / torch.expand use cases), and that whether the result
shares memory with the input or is a fresh copy depends on the backend and
pattern.

Closes arogozhnikov#351
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicitly document expand-like semantics of einops.repeat

1 participant