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

[Extend feature] Reduce and repeat not supporting tensor concatenation. #177

Open
Schinkikami opened this issue Mar 17, 2022 · 1 comment

Comments

@Schinkikami
Copy link

Einops allows the use of rearrange to concatenate a list of tensors, like shown in the einops for deep learning notebook.

import torch
import einops

x = [torch.rand([3,20,20]) for _ in range(10)]
stacked_and_reshaped = einops.rearrange(x, "b c h w -> b c (h w)")

However, this functionality does not work for reduce and repeat:

stacked_and_averaged = einops.reduce(x, "b c h w -> c h w", reduction="mean")
stacked_and_repeated = einops.repeat(x, "b c h w -> why_not b c h w", why_not=2)

both operations produce these error messages (this is obviously for repeat)

  File "/home/myName/miniconda3/envs/myEnv/lib/python3.9/site-packages/einops/einops.py", line 536, in repeat
    return reduce(tensor, pattern, reduction='repeat', **axes_lengths)
  File "/home/myName/miniconda3/envs/myEnv/lib/python3.9/site-packages/einops/einops.py", line 409, in reduce
    return _apply_recipe(recipe, tensor, reduction_type=reduction)
  File "/home/myName/miniconda3/envs/myEnv/lib/python3.9/site-packages/einops/einops.py", line 230, in _apply_recipe
    backend = get_backend(tensor)
  File "/home/myName/miniconda3/envs/myEnv/lib/python3.9/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'>

The expected behavior is of course, that it would work like with rearrange.

Your platform
Python: 3.9
einops: 0.4.0
DL_package: pyTorch

@Schinkikami Schinkikami added the bug Something isn't working label Mar 17, 2022
@arogozhnikov
Copy link
Owner

see #172 , that's a plan for the next release

@arogozhnikov arogozhnikov changed the title [BUG] Reduce and repeat not supporting tensor concatenation. [Extend feature] Reduce and repeat not supporting tensor concatenation. Mar 17, 2022
@arogozhnikov arogozhnikov added feature suggestion and removed bug Something isn't working labels Mar 17, 2022
@arogozhnikov arogozhnikov added this to the 0.5 milestone May 7, 2022
@arogozhnikov arogozhnikov modified the milestones: 0.5, 0.6 Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants