einops
einops copied to clipboard
Ellipsis not mentioned in docs
Great work!
I discovered in https://github.com/arogozhnikov/einops/blob/master/einops/einops.py#L199 that you also support ellipsis. Its an important feature so you may want to add it to the documentation.
Thanks!
I am not mentioning this in the docs for purpose as I expect this feature to be misused. So, for now I'd better keep it as is.
+1 I think support for ellipsis is noteworthy. In fact, I recently saw someone note support for ellipsis as a missing feature in einops!
It's true that it's probably a better idea to omit ellipsis when writing code specialized for particular shapes of arrays, but occasionally it's nice to write rank polymorphic code and there's no good alternative to it.
I also agree that this should be documented! Sometimes you have to reshape an array with an undefined number of axes, and I don't think there's any other way to do it with einops? Eg rearrange(x, "a b ... -> (a b) ...")
seems to work as I would expect, and I'll be using this in my code right now to replace a messy .reshape()
, so it's definitely not unusual.
I was initially a little disappointed after not finding ellipsis support in the docs, as it was crucial for my application and I was really enjoying einops
in other places. Very glad I found this issue – I hope the feature gets added to einops' excellent documention!
rearrange(x, "b ... -> b (...)")
is so much better than np.reshape(x, (x.shape[0], np.prod(x.shape[1:])))
and it is a super widespread operation to do. Ellipsis is beautiful, consider mentioning it very late in the docs!
I was just going to open a feature request for ...
. :D
I think the ellipsis notation can be turned even more powerful by adding the ability to name the axes group and add an explicit count. E.g.,
reduce(x, "b size[2] channel -> b size", "mean")
An undetermined count (what ...
currently does) can be shown using []
or [-1]
.
I agree with everyone. If there is a concern for misuse, we could have a paragraph informing the user about best practices.
I'm here because ellipsis are used in StableDiffusion code, and I had a hard time understanding since I couldn't find in the docs.
In the mean time you can find some usage of ellipsis in the einops paper : Rogozhnikov, Alex. "Einops: Clear and reliable tensor manipulations with einstein-like notation." International Conference on Learning Representations. 2021.
I'm here because ellipsis are used in FlashAttention. It's hard for non-native English speakers to know the word "ellipsis", let alone find the correct page to explain what it means in einops
. I really hope this can be mentioned in the docs or tutorial.