|
Open3D (C++ API)
0.19.0
|
Framework-specific function pointers table for DLPack exchange. More...
#include <DLPack.h>
Data Fields | |
| DLPackExchangeAPIHeader | header |
| The header that remains stable across versions. More... | |
| DLPackManagedTensorAllocator | managed_tensor_allocator |
| Producer function pointer for DLPackManagedTensorAllocator This function must not be NULL. More... | |
| DLPackManagedTensorFromPyObjectNoSync | managed_tensor_from_py_object_no_sync |
| Producer function pointer for DLPackManagedTensorFromPyObject This function must be not NULL. More... | |
| DLPackManagedTensorToPyObjectNoSync | managed_tensor_to_py_object_no_sync |
| Producer function pointer for DLPackManagedTensorToPyObject This function must be not NULL. More... | |
| DLPackDLTensorFromPyObjectNoSync | dltensor_from_py_object_no_sync |
| Producer function pointer for DLPackDLTensorFromPyObject This function can be NULL when the producer does not support this function. More... | |
| DLPackCurrentWorkStream | current_work_stream |
| Producer function pointer for DLPackCurrentWorkStream This function must be not NULL. More... | |
Framework-specific function pointers table for DLPack exchange.
Additionally to __dlpack__() we define a C function table sharable by Python implementations via __c_dlpack_exchange_api__. This attribute must be set on the type as a Python integer compatible with PyLong_FromVoidPtr/PyLong_AsVoidPtr.
A consumer library may use a pattern such as:
Note that this must be defined on the type. The consumer should look up the attribute on the type and may cache the result for each unique type.
The precise API table is given by:
Guidelines for leveraging DLPackExchangeAPI:
There are generally two kinds of consumer needs for DLPack exchange:
Note that obj.__dlpack__() API should provide useful ways for N1. The primary focus of the current DLPackExchangeAPI is to enable faster exchange N0 with the support of the function pointer current_work_stream.
Array/Tensor libraries should statically create and initialize this structure then return a pointer to DLPackExchangeAPI as an int value in Tensor/Array. The DLPackExchangeAPI* must stay alive throughout the lifetime of the process.
One simple way to do so is to create a static instance of DLPackExchangeAPI within the framework and return a pointer to it. The following code shows an example to do so in C++. It should also be reasonably easy to do so in other languages.
| DLPackCurrentWorkStream DLPackExchangeAPI::current_work_stream |
Producer function pointer for DLPackCurrentWorkStream This function must be not NULL.
| DLPackDLTensorFromPyObjectNoSync DLPackExchangeAPI::dltensor_from_py_object_no_sync |
Producer function pointer for DLPackDLTensorFromPyObject This function can be NULL when the producer does not support this function.
| DLPackExchangeAPIHeader DLPackExchangeAPI::header |
The header that remains stable across versions.
| DLPackManagedTensorAllocator DLPackExchangeAPI::managed_tensor_allocator |
Producer function pointer for DLPackManagedTensorAllocator This function must not be NULL.
| DLPackManagedTensorFromPyObjectNoSync DLPackExchangeAPI::managed_tensor_from_py_object_no_sync |
Producer function pointer for DLPackManagedTensorFromPyObject This function must be not NULL.
| DLPackManagedTensorToPyObjectNoSync DLPackExchangeAPI::managed_tensor_to_py_object_no_sync |
Producer function pointer for DLPackManagedTensorToPyObject This function must be not NULL.