|
19 | 19 | #define DLPACK_MAJOR_VERSION 1 |
20 | 20 |
|
21 | 21 | /*! \brief The current minor version of dlpack */ |
22 | | -#define DLPACK_MINOR_VERSION 2 |
| 22 | +#define DLPACK_MINOR_VERSION 3 |
23 | 23 |
|
24 | 24 | /*! \brief DLPACK_DLL prefix for windows */ |
25 | 25 | #ifdef _WIN32 |
@@ -397,7 +397,7 @@ typedef enum |
397 | 397 | } DLManagedTensorVersioned; |
398 | 398 |
|
399 | 399 | //---------------------------------------------------------------------- |
400 | | - // DLPack `__c_dlpack_exchange_api__` fast exchange protocol definitions |
| 400 | + // DLPack `__dlpack_c_exchange_api__` fast exchange protocol definitions |
401 | 401 | //---------------------------------------------------------------------- |
402 | 402 | /*! |
403 | 403 | * \brief Request a producer library to create a new tensor. |
@@ -442,6 +442,7 @@ typedef enum |
442 | 442 | * |
443 | 443 | * \param py_object The Python object to convert. Must have the same type |
444 | 444 | * as the one the `DLPackExchangeAPI` was discovered from. |
| 445 | + * \param out The output DLManagedTensorVersioned. |
445 | 446 | * \return The owning DLManagedTensorVersioned* or NULL on failure with a |
446 | 447 | * Python exception set. If the data cannot be described using |
447 | 448 | * DLPack this should be a BufferError if possible. \note - As a C function, |
@@ -561,17 +562,24 @@ typedef enum |
561 | 562 | * \brief Framework-specific function pointers table for DLPack exchange. |
562 | 563 | * |
563 | 564 | * Additionally to `__dlpack__()` we define a C function table sharable by |
564 | | - * Python implementations via `__c_dlpack_exchange_api__`. |
565 | | - * This attribute must be set on the type as a Python integer compatible |
566 | | - * with `PyLong_FromVoidPtr`/`PyLong_AsVoidPtr`. |
| 565 | + * |
| 566 | + * Python implementations via `__dlpack_c_exchange_api__`. |
| 567 | + * This attribute must be set on the type as a Python PyCapsule |
| 568 | + * with name "dlpack_exchange_api". |
567 | 569 | * |
568 | 570 | * A consumer library may use a pattern such as: |
569 | 571 | * |
570 | 572 | * \code |
571 | 573 | * |
572 | | - * PyObject *api_obj = type(tensor_obj).__c_dlpack_exchange_api__; // as |
573 | | - * C-code MyDLPackExchangeAPI *api = PyLong_AsVoidPtr(api_obj); if (api == |
574 | | - * NULL && PyErr_Occurred()) { goto handle_error; } |
| 574 | + * PyObject *api_capsule = PyObject_GetAttrString( |
| 575 | + * (PyObject *)Py_TYPE(tensor_obj), "__dlpack_c_exchange_api__") |
| 576 | + * ); |
| 577 | + * if (api_capsule == NULL) { goto handle_error; } |
| 578 | + * MyDLPackExchangeAPI *api = (MyDLPackExchangeAPI *)PyCapsule_GetPointer( |
| 579 | + * api_capsule, "dlpack_exchange_api" |
| 580 | + * ); |
| 581 | + * Py_DECREF(api_capsule); |
| 582 | + * if (api == NULL) { goto handle_error; } |
575 | 583 | * |
576 | 584 | * \endcode |
577 | 585 | * |
@@ -652,7 +660,7 @@ typedef enum |
652 | 660 | /*! |
653 | 661 | * \brief Producer function pointer for DLPackManagedTensorToPyObject |
654 | 662 | * This function must be not NULL. |
655 | | - * \sa DLPackManagedTensorToPyObject |
| 663 | + * \sa DLPackManagedTensorToPyObjectNoSync |
656 | 664 | */ |
657 | 665 | DLPackManagedTensorToPyObjectNoSync managed_tensor_to_py_object_no_sync; |
658 | 666 | /*! |
|
0 commit comments