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

[API] Add __cuda_array_interface__ for eager Tensor #68192

Conversation

HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Sep 12, 2024

PR Category

User Experience

PR Types

New features

Description

Pcard-75624

  1. 为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

  2. paddle.numel支持uint8和int8类型,添加对应单测。

[pull] develop from PaddlePaddle:develop
[pull] develop from PaddlePaddle:develop
Copy link

paddle-bot bot commented Sep 12, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@HydrogenSulfate HydrogenSulfate force-pushed the add___cuda_array_interface__ branch from 27029c6 to 88eddaa Compare September 13, 2024 05:47
@HydrogenSulfate HydrogenSulfate mentioned this pull request Sep 13, 2024
14 tasks
Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

相关问题可以单独 PR 看看~

@@ -22,6 +22,7 @@ PD_REGISTER_KERNEL(numel,
CPU,
ALL_LAYOUT,
phi::NumelKernel,
int8_t,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numel 中英文 API 文档是不是也应该体现这一点修改?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉可以跟下个PR一起改掉

test/legacy_test/test_eager_tensor.py Show resolved Hide resolved
@SigureMo SigureMo changed the title [API] Add __cuda_array_interface__ for eager Tensor [API] Add __cuda_array_interface__ `for eager Tensor Sep 14, 2024
@SigureMo SigureMo changed the title [API] Add __cuda_array_interface__ `for eager Tensor [API] Add __cuda_array_interface__ for eager Tensor Sep 14, 2024
@HydrogenSulfate HydrogenSulfate merged commit e7403a2 into PaddlePaddle:develop Sep 14, 2024
28 of 30 checks passed
@HydrogenSulfate HydrogenSulfate deleted the add___cuda_array_interface__ branch September 14, 2024 10:32
@HydrogenSulfate HydrogenSulfate mentioned this pull request Sep 28, 2024
14 tasks
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

Successfully merging this pull request may close these issues.

2 participants