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.reduce behavior for list input #172

Closed
ferrophile opened this issue Feb 18, 2022 · 2 comments
Closed

einops.reduce behavior for list input #172

ferrophile opened this issue Feb 18, 2022 · 2 comments

Comments

@ferrophile
Copy link

ferrophile commented Feb 18, 2022

reduce seems to not accept list of equal-shaped tensors as input - even though the API claims it should. (Just for comparison, rearrange appears to work as expected).

>>> import einops
>>> import numpy as np
>>> a = np.random.rand(3, 4)
>>> b = np.random.rand(3, 4)
>>> out1 = einops.rearrange([a, b], 'i j k -> j i k')
>>> out1.shape
(3, 2, 4)
>>> out2 = einops.reduce([a, b], 'i j k -> j k', 'sum')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hwpang/miniconda3/envs/nerf-pytorch/lib/python3.7/site-packages/einops/einops.py", line 409, in reduce
    return _apply_recipe(recipe, tensor, reduction_type=reduction)
  File "/home/hwpang/miniconda3/envs/nerf-pytorch/lib/python3.7/site-packages/einops/einops.py", line 230, in _apply_recipe
    backend = get_backend(tensor)
  File "/home/hwpang/miniconda3/envs/nerf-pytorch/lib/python3.7/site-packages/einops/_backends.py", line 52, in get_backend
    raise RuntimeError('Tensor type unknown to einops {}'.format(type(tensor)))
RuntimeError: Tensor type unknown to einops <class 'list'>

Is the above intended behavior?

@arogozhnikov
Copy link
Owner

Is the above intended behavior?

Yes, for now it is intended.

I think that lists worked well and it feels safe to expand their support to reduce/repeat functions in the next version

@ferrophile
Copy link
Author

ferrophile commented Feb 24, 2022

Thanks for the clarification. Hope it gets supported soon

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

No branches or pull requests

2 participants