Skip to content

Commit fe3b2db

Browse files
Update dlpack.h to v1.3 and README.md
1 parent 76b1a0f commit fe3b2db

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# DLPack header
22

3-
The header `dlpack.h` downloaded from `https://github.com/dmlc/dlpack.git` remote at tag v1.0rc commit [`62100c1`](https://github.com/dmlc/dlpack/commit/62100c123144ae7a80061f4220be2dbd3cbaefc7).
3+
The header `dlpack.h` downloaded from `https://github.com/dmlc/dlpack.git` remote at tag v1.3 commit [`84d107b`](https://github.com/dmlc/dlpack/commit/84d107bf416c6bab9ae68ad285876600d230490d).
44

5-
The file can also be viewed using github web interface at https://github.com/dmlc/dlpack/blob/62100c123144ae7a80061f4220be2dbd3cbaefc7/include/dlpack/dlpack.h
5+
The file can also be viewed using github web interface at https://github.com/dmlc/dlpack/blob/v1.3/include/dlpack/dlpack.h
66

77
License file was retrieved from https://github.com/dmlc/dlpack/blob/main/LICENSE

dpctl_ext/tensor/include/dlpack/dlpack.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define DLPACK_MAJOR_VERSION 1
2020

2121
/*! \brief The current minor version of dlpack */
22-
#define DLPACK_MINOR_VERSION 2
22+
#define DLPACK_MINOR_VERSION 3
2323

2424
/*! \brief DLPACK_DLL prefix for windows */
2525
#ifdef _WIN32
@@ -397,7 +397,7 @@ typedef enum
397397
} DLManagedTensorVersioned;
398398

399399
//----------------------------------------------------------------------
400-
// DLPack `__c_dlpack_exchange_api__` fast exchange protocol definitions
400+
// DLPack `__dlpack_c_exchange_api__` fast exchange protocol definitions
401401
//----------------------------------------------------------------------
402402
/*!
403403
* \brief Request a producer library to create a new tensor.
@@ -442,6 +442,7 @@ typedef enum
442442
*
443443
* \param py_object The Python object to convert. Must have the same type
444444
* as the one the `DLPackExchangeAPI` was discovered from.
445+
* \param out The output DLManagedTensorVersioned.
445446
* \return The owning DLManagedTensorVersioned* or NULL on failure with a
446447
* Python exception set. If the data cannot be described using
447448
* DLPack this should be a BufferError if possible. \note - As a C function,
@@ -561,17 +562,24 @@ typedef enum
561562
* \brief Framework-specific function pointers table for DLPack exchange.
562563
*
563564
* 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".
567569
*
568570
* A consumer library may use a pattern such as:
569571
*
570572
* \code
571573
*
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; }
575583
*
576584
* \endcode
577585
*
@@ -652,7 +660,7 @@ typedef enum
652660
/*!
653661
* \brief Producer function pointer for DLPackManagedTensorToPyObject
654662
* This function must be not NULL.
655-
* \sa DLPackManagedTensorToPyObject
663+
* \sa DLPackManagedTensorToPyObjectNoSync
656664
*/
657665
DLPackManagedTensorToPyObjectNoSync managed_tensor_to_py_object_no_sync;
658666
/*!

0 commit comments

Comments
 (0)