einops icon indicating copy to clipboard operation
einops copied to clipboard

Ellipsis not mentioned in docs

Open LukasDrude opened this issue 6 years ago • 10 comments

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.

LukasDrude avatar Dec 01 '18 10:12 LukasDrude

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.

arogozhnikov avatar Dec 05 '18 19:12 arogozhnikov

+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.

shoyer avatar Aug 20 '20 22:08 shoyer

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.

zplizzi avatar Feb 08 '22 17:02 zplizzi

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!

JeppeKlitgaard avatar Apr 21 '22 17:04 JeppeKlitgaard

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!

lucasb-eyer avatar Jun 13 '22 22:06 lucasb-eyer

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].

NightMachinery avatar Jul 04 '22 15:07 NightMachinery

I agree with everyone. If there is a concern for misuse, we could have a paragraph informing the user about best practices.

magehrig avatar Jul 27 '22 08:07 magehrig

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.

zjost avatar Aug 30 '22 13:08 zjost

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.

Etienne-Meunier avatar Jan 10 '23 11:01 Etienne-Meunier

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.

perkfly avatar Nov 30 '23 13:11 perkfly