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

core::Tensor 处理 #247

Open
zejunwang1 opened this issue Aug 19, 2021 · 1 comment
Open

core::Tensor 处理 #247

zejunwang1 opened this issue Aug 19, 2021 · 1 comment

Comments

@zejunwang1
Copy link

你好,想请教一个关于 Tensor 的问题:
假设我现在有一个 {32,128,768} 维度的 Tensor,现在想去掉第二个维度的头尾向量,将 Tensor 的维度变为 {32,126,768},请问有什么好的解决办法吗?

@feifeibear
Copy link
Collaborator

这个在Turbo里处理不太方便,可以通过dlpack转化成pytorch tensor,然后用torch的接口处理完再转回来。
turbo tensor -> torch tensor
torch_tensor = dlpack.from_dlpack(turbo_tensor.to_dlpack())
see this file for more detail
turbo_transformers/python/turbo_transformers/layers/return_type.py

torch tensor -> turbo tensor
convert2tt_tensor(t)
see this file for more details: turbo_transformers/python/turbo_transformers/layers/utils.py

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