Skip to content
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

einops.layers.torch.Rearrange does not accept a list[torch.Tensor] as an input #284

Open
zimka opened this issue Sep 18, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@zimka
Copy link

zimka commented Sep 18, 2023

Describe the bug
einops.layers.torch.Rearrange and einops.rearrange behave differently with list[torch.Tensor].
It is possible to use rearrange for concatenation, while Rearrange fails with error:

einops/_torch_specific.py:66, in TorchJitBackend.shape(x)
64 @staticmethod
65 def shape(x):
---> 66 return x.shape
AttributeError: 'list' object has no attribute 'shape'

Reproduction steps

import torch
from einops import rearrange
from einops.layers.torch import Rearrange

layer = Rearrange('num b c h w -> b (num c) h w', num=2)
func = lambda x: rearrange(x, 'num b c h w -> b (num c) h w', num=2)

t1 = torch.randn((1, 3, 16, 24))
t2 = torch.rand((1, 3, 16, 24))

y = func([w1, w2]) # OK
y = layer([w1, w2]) #  AttributeError: 'list' object has no attribute 'shape'

Expected behavior
Expect the same behavior in both cases (hopefully correct operation execution, not raise exception)

Your platform
python==3.10.12
torch==2.0.1
einops==0.6.1

@zimka zimka added the bug Something isn't working label Sep 18, 2023
@arogozhnikov arogozhnikov changed the title [BUG] einops.layers.torch.Rearrange and einops.rearrange behave differently with list[torch.Tensor] einops.layers.torch.Rearrange does not accept a list[torch.Tensor] as an input Sep 19, 2023
@arogozhnikov arogozhnikov added enhancement New feature or request and removed bug Something isn't working labels Sep 19, 2023
@arogozhnikov
Copy link
Owner

Yup, that's how it was supposed to work. Nobody asked for support of lists in layers ... yet :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants