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

【PaddlePaddle Hackathon 2】88、实现 Taichi 和 PaddlePaddle 之间的无拷贝交互 #3

Open
TCChenlong opened this issue Mar 8, 2022 · 8 comments

Comments

@TCChenlong
Copy link

TCChenlong commented Mar 8, 2022

(此 ISSUE 为 PaddlePaddle Hackathon 第二期活动的任务 ISSUE,更多详见 【PaddlePaddle Hackathon 第二期】任务总览

【任务说明】

  • 任务标题:实现 Taichi 和 PaddlePaddle 之间的无拷贝交互。

  • 技术标签:深度学习框架,高性能计算。

  • 任务难度:中等。

  • 详细描述:

  • 深度学习框架如 PaddlePaddle 与 Taichi 的结合使用,可以使开发新的 op 更加高效快速。得益于 Paddle Tensor 的内部由一块连续内存实现,Taichi 和 Paddle 之间可以实现同硬件上的无拷贝交互,即 Taichi kernel 直接操作 PaddlePaddle 。Tensor 所在的内存地址,既实现了在同一个 Python 程序中 Taichi 和 PaddlePaddle 的数据交互,又避免了两个框架间的数据拷贝。

  • 相关实现:

    Taichi 与 torch tensor 交互的实现细节

【提交内容】

  • 设计文档,并提 PR 至 PaddlePaddle/community 的 rfcs/Taichi 目录

  • 任务 PR 到 Taichi;

  • 添加交互 API 如 from_paddle/to_paddle 的文档;

  • 添加对交互 API 的测试。

【技术要求】

  • 熟悉 Taichi ;

  • 了解 Paddle API 相关用法;

  • 熟练掌握 C++ 、Python。

【答疑交流】

  • 如果在开发中对于上述任务有任何问题,欢迎在本 ISSUE 下留言交流。
  • 对于开发中的共性问题,在活动过程中,会定期组织答疑,请大家关注官网&QQ群的通知,及时参与。
@0xzhang
Copy link

0xzhang commented Mar 30, 2022

I have a question, does Paddle now support Tensor._ptr()?

This unittest failed.

image

image

@yuanming-hu
Copy link
Member

@0xzhang
Copy link

0xzhang commented Mar 30, 2022

Thanks.

Now the unittest passed. I will continue to develop.

image

@yuanming-hu
Copy link
Member

Awesome, many thanks!!

@0xzhang
Copy link

0xzhang commented Mar 31, 2022

I'm not very familiar with "Paddle", but it seems like paddles.Tensor is not the same as paddle.fluid.core.Tensor. Only the paddle.fluid.core.Tensor supports _ptr().

I'm not sure about this. So should I use paddle.fluid.core.Tensor as "Tensor in Paddle" to interact with "Taichi" during development.

@ailzhang
Copy link

Hey @0xzhang sorry for the late reply! We've confirmed that paddle.fluid.core.Tensor is the underlying data storage and it's fine to use it to interact with Taichi. You can get it from a paddle.Tensor using .value().get_tensor(). Hopefully this answers your question. Please feel free to ask here if you have follow up any question!

@0xzhang
Copy link

0xzhang commented Apr 20, 2022

Thanks for reply! I hope I can submit the PR as soon as possible.

@0xzhang
Copy link

0xzhang commented Apr 29, 2022

A simple test has passed. I'll describe that more in PR.

I use commands below to run test.

$Env:TI_ENABLE_PADDLE=1
python .\setup.py install
python .\tests\run_tests.py -v -k test_paddle_io -a cpu -t 1

image

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

5 participants