docs: document expand/broadcast semantics of einops.repeat - #436
Open
madhavcodez wants to merge 1 commit into
Open
docs: document expand/broadcast semantics of einops.repeat#436madhavcodez wants to merge 1 commit into
madhavcodez wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per #351, the expand-like behavior of
einops.repeathas come up several times in issues and was not stated in the docs. This documents thatrepeatcan introduce axes that are not present in the input and fill them by repetition, covering thenumpy.broadcast_to/torch.expanduse cases in addition to repeat and tile.repeatdocstring: 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).broadcastto the operations list in the README, alongside the existingrepeatandtile.Docs only, no behavior change. Happy to drop the README line if you would prefer the docstring change only.
Closes #351