Skip to content

Einops doesn't support the PaddlePaddle framework currently  #45627

@OccupyMars2025

Description

@OccupyMars2025

需求描述 Feature Description

related issue: #34220
related PR: arogozhnikov/einops#122

I just want tu use einops with paddlepaddle, just like the following :

import paddle import torch import numpy as np from einops import rearrange x_np = np.random.randn(1, 2, 3) print(rearrange(x_np, "a s d -> s a d")) x_torch = torch.randn([1, 2, 3]) print(rearrange(x_torch, "a s d -> s a d")) x_pd = paddle.randn([1, 2, 3]) rearrange(x_pd, "a s d -> s a d")

The last line of code reports an error as follows:
RuntimeError Traceback (most recent call last)
in
12
13 x_pd = paddle.randn([1, 2, 3])
---> 14 rearrange(x_pd, "a s d -> s a d")

3 frames
/usr/local/lib/python3.7/dist-packages/einops/_backends.py in get_backend(tensor)
50 return backend
51
---> 52 raise RuntimeError('Tensor type unknown to einops {}'.format(type(tensor)))
53
54

RuntimeError: Tensor type unknown to einops <class 'paddle.Tensor'>

The official website of einops says:

image

It seems that Einops doesn't work with the PaddlePaddle framework now.

替代实现 Alternatives

you can transform a paddle Tensor to a numpy array to work with einops

Metadata

Metadata

Assignees

Labels

PFCCPaddle Framework Contributor Club,https://github.com/PaddlePaddle/community/tree/master/pfccgood first issuestatus/new-issue新建type/feature-request新需求申请

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions