PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.3k stars 5.62k forks source link

conforming array_api_standards via `__dlpack__` and `__dlpack_device__` methods #56891

Open abdulasiraj opened 1 year ago

abdulasiraj commented 1 year ago

需求描述 Feature Description

Right now, paddle only produce and consume PyCapsules. However, dealing with raw capsules is outdated. Also, numpy doesn't supports PyCapsules. It's better if paddle tensors also support __dlpack__ and __dlpack_devce__ dunders.

替代实现 Alternatives

No response

zhangting2020 commented 1 year ago

Thank you for your suggestion. May I know if paddle.utils.dlpack.from_dlpack(dlpack) and paddle.utils.dlpack.from_dlpack(dlpack) can meet this requirement?

abdulasiraj commented 1 year ago

Hi @zhangting2020, Thanks for your response. from_dlpack and to_dlpack are legacy functions now. All frameworks are now implementing __dlpack__ and __dlpack_device__ dunders for their Tensors. It can be seen here: https://dmlc.github.io/dlpack/latest/python_spec.html https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack__.html

Also numpy doesn't support PyCapsules https://github.com/numpy/numpy/issues/24575