-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[API] Add __cuda_array_interface__ for eager Tensor
#68192
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
[API] Add __cuda_array_interface__ for eager Tensor
#68192
Conversation
[pull] develop from PaddlePaddle:develop
[pull] develop from PaddlePaddle:develop
|
你的PR提交成功,感谢你对开源项目的贡献! |
…d add unitest for cuda_array_interface
27029c6 to
88eddaa
Compare
SigureMo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| CPU, | ||
| ALL_LAYOUT, | ||
| phi::NumelKernel, | ||
| int8_t, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
numel 中英文 API 文档是不是也应该体现这一点修改?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉可以跟下个PR一起改掉
__cuda_array_interface__ `for eager Tensor
__cuda_array_interface__ `for eager Tensor__cuda_array_interface__ for eager Tensor
We support `paddle.Tensor.__cuda_array_interface__`(PaddlePaddle/Paddle#68192) and `paddle.to_tensor(tenosr_with_CAI_impl)`(PaddlePaddle/Paddle#69913), so we can convert paddle Tensor from/to other DL frameworks via CAI(based on CAI version 2).
PR Category
User Experience
PR Types
New features
Description
Pcard-75624
为eager Tensor添加
__cuda_array_interface__属性,从而允许paddle.Tensor被不同的GPU计算框架在同相同设备上以零拷贝的方式使用。添加对应单测。属性定义规范参考:https://numba.readthedocs.io/en/0.52.0/cuda/cuda_array_interface.html(与其他框架对齐,采用version 2而非version 3)
代码参考:
Support the __cuda_array_interface__ protocol tensorflow/tensorflow#29039
Add paddle backend NVIDIA/warp#313
https://github.com/pytorch/pytorch/blob/e54b559e8860e343692bb5534777b2384a57a613/torch/_tensor.py#L1185-L1252
paddle.numel支持uint8和int8类型,添加对应单测。