[DLPack][TVM FFI] Return PyCapsule in __c_dlpack_exchange_api__ in tvm ffi 0.1.4+#76673
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Pull request overview
This PR adds compatibility for TVM FFI 0.1.4+ by conditionally returning either a raw pointer or a PyCapsule from the __c_dlpack_exchange_api__ interface. The change ensures backward compatibility with TVM FFI versions 0.1.0-0.1.3 while supporting the new protocol in 0.1.4+.
Key Changes:
- Introduced version detection logic to determine which DLPack exchange API format to return
- Added new C++ binding
dlpack_exchange_api_pycapsule()that returns a PyCapsule - Modified tensor patch method to call version-aware
_get_c_dlpack_exchange_api()function instead of directly using the raw pointer
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| python/paddle/base/dygraph/tensor_patch_methods.py | Implements version detection logic and conditional return of pointer vs PyCapsule for DLPack exchange API |
| paddle/fluid/pybind/pybind.cc | Adds new Python binding function to return DLPack exchange API as a PyCapsule |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (66.66%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #76673 +/- ##
==========================================
Coverage ? 66.66%
==========================================
Files ? 1
Lines ? 9
Branches ? 0
==========================================
Hits ? 6
Misses ? 3
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
|
/skip-ci coverage |


PR Category
Execute Infrastructure
PR Types
Improvements
Description
在 TVM FFI 0.1.4+ 或者说只要用户没有装 TVM FFI
0.1.0/0.1.1/0.1.2/0.1.3,__c_dlpack_exchange_api__就返回按照新的协议的指针包装后的PyCapsule,以匹配最新协议(这里更多是实现而非原本协议中的内容,见 pytorch/pytorch#162845、pytorch/pytorch#165483)虽然 TVM FFI 0.1.4 已经做了兼容性处理(apache/tvm-ffi#288),但我们不敢保证这一兼容性处理具体会持续多久,我们希望即将发布的 3.3.0 能够与下游生态有更松的耦合(FlashInfer、TileLang 等),确保这一版本尽可能长期可用,因此在 3.3.0 会添加这一兼容性逻辑
此外 CI 只监控 tvm-ffi 0.1.4 行为,0.1.3- 行为已经在 548666a 验证过