-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature suggestion] support for ellipsis in unpack
#253
Comments
Hi @alisterburt, happy to hear that einops is helpful. Thanks for making detailed analysis of your proposal. There are a couple of consideration why
Neither is a strong blocker, but still are important to consider. Regarding your particular case, I find the following snippet is more readable (and maybe it isn't, if you just handle data of arbitrary dimensionality). pattern = {
3: 't * c',
4: 'h w * c',
5: 'h w d * c',
}[grid.ndim]
[grid] = einops.unpack(grid, packed_shapes=ps_grid, pattern=pattern) In any case, this is implementable if more people will run into this (and if you do, please describe your usecase in this issue!). |
Thanks for considering and providing a more readable substitute, let's see if anyone else would like this |
Hi, I'd like to say this is convenient to us when we try to refactor projects that look like OpenFold, where we may have different number of batched dimensions. For example, paired representation on attention, where instead of attention on sequence of shape |
Hi @arogozhnikov - thank you so much for einops, it has been really transformative.
I am trying to write some rank-polymorphic library code for working with nD image data. I am finding that sometimes I don't know the dimensionality of the data upfront and this can make using einops unpack a little tricky.
below is an illustrated example - I would like to be able to shift grids of arbitrary dimensionality by nD arrays of 'center points'
I can dynamically generate labels for the new dimensions here easily but feel that the ellipsis would be more natural.
Integrity - does it interplay well with existing operations and notation in einops?
The ellipsis is supported in
einops.rearrange()
but I know it is not encouraged.Readability
I find the solution with dynamically generated labels below less readable than the proposed ellipsis.
The text was updated successfully, but these errors were encountered: