pytorch
dda59162 - Native `rearrange` in `functorch` (#101957)

Commit
1 year ago
Native `rearrange` in `functorch` (#101957) Fixes #92675 Here we implement a native version of [`einops.rearrange`](https://einops.rocks/api/rearrange/) using first class dims to perform the operations. The string parsing + validation, documentation, and relevant tests are adapted from `einops`. The API is exactly the same as the `einops` API. The main idea is to take the string and convert it to a left and right `ParsedExpression`, and then find a mapping from the axes to first class dims. Once the mapping exists we convert the left expression `composition` list into a `Tensor.__getitem__` index and the right expression `composition` into the `Tensor.order` arguments, and then use this to dynamically create a callable that performs the `rearrange` operation as specified by the pattern. Pull Request resolved: https://github.com/pytorch/pytorch/pull/101957 Approved by: https://github.com/zdevito
Author
Committer
Parents
Loading