Description
Add support for importing objects that implement the __c_dlpack_exchange_api__ protocol as StridedMemoryView objects.
Motivation
The __c_dlpack_exchange_api__ protocol provides a C-level interface for efficient zero-copy data exchange. Currently, StridedMemoryView supports construction from Python-level protocols (__dlpack__, __cuda_array_interface__, buffer protocol), but does not support the C-level exchange API.
Supporting this protocol would enable:
- More efficient data sharing with libraries that expose the C-level API
- Reduced overhead by avoiding Python-level protocol dispatch
- Better integration with Cython-based libraries that use the C exchange API
Requested Features
- Add a class method or constructor path in
StridedMemoryView that can consume objects implementing __c_dlpack_exchange_api__
- Properly handle the DLManagedTensor lifecycle (deleter callback)
Additional Context
Description
Add support for importing objects that implement the
__c_dlpack_exchange_api__protocol asStridedMemoryViewobjects.Motivation
The
__c_dlpack_exchange_api__protocol provides a C-level interface for efficient zero-copy data exchange. Currently,StridedMemoryViewsupports construction from Python-level protocols (__dlpack__,__cuda_array_interface__, buffer protocol), but does not support the C-level exchange API.Supporting this protocol would enable:
Requested Features
StridedMemoryViewthat can consume objects implementing__c_dlpack_exchange_api__Additional Context
StridedMemoryViewobjects via DLPack #1438 (export support)