1
1
// Taken from:
2
- // https://github.com/dmlc/dlpack/blob/ca4d00ad3e2e0f410eeab3264d21b8a39397f362/include/dlpack/dlpack.h
2
+ // https://github.com/dmlc/dlpack/blob/bbd2f4d32427e548797929af08cfe2a9cbb3cf12/include/dlpack/dlpack.h
3
+ // but added typedef to DLManagedTensorVersioned
3
4
/* !
4
5
* Copyright (c) 2017 by Contributors
5
6
* \file dlpack.h
@@ -118,6 +119,8 @@ typedef enum {
118
119
kDLWebGPU = 15 ,
119
120
/* ! \brief Qualcomm Hexagon DSP */
120
121
kDLHexagon = 16 ,
122
+ /* ! \brief Microsoft MAIA devices */
123
+ kDLMAIA = 17 ,
121
124
} DLDeviceType;
122
125
123
126
/* !
@@ -197,7 +200,7 @@ typedef struct {
197
200
* `byte_offset` field should be used to point to the beginning of the data.
198
201
*
199
202
* Note that as of Nov 2021, multiply libraries (CuPy, PyTorch, TensorFlow,
200
- * TVM, perhaps others) do not adhere to this 256 byte alignment requirement
203
+ * TVM, perhaps others) do not adhere to this 256 byte aligment requirement
201
204
* on CPU/CUDA/ROCm, and always use `byte_offset=0`. This must be fixed
202
205
* (after which this note will be updated); at the moment it is recommended
203
206
* to not rely on the data pointer being correctly aligned.
@@ -215,6 +218,9 @@ typedef struct {
215
218
* return size;
216
219
* }
217
220
* \endcode
221
+ *
222
+ * Note that if the tensor is of size zero, then the data pointer should be
223
+ * set to `NULL`.
218
224
*/
219
225
void * data;
220
226
/* ! \brief The device of the tensor */
@@ -259,7 +265,7 @@ typedef struct DLManagedTensor {
259
2
10000
65
* \brief Destructor - this should be called
260
266
* to destruct the manager_ctx which backs the DLManagedTensor. It can be
261
267
* NULL if there is no way for the caller to provide a reasonable destructor.
262
- * The destructors deletes the argument self as well.
268
+ * The destructor deletes the argument self as well.
263
269
*/
264
270
void (*deleter)(struct DLManagedTensor * self);
265
271
} DLManagedTensor;
@@ -269,6 +275,14 @@ typedef struct DLManagedTensor {
269
275
/* ! \brief bit mask to indicate that the tensor is read only. */
270
276
#define DLPACK_FLAG_BITMASK_READ_ONLY (1UL << 0UL )
271
277
278
+ /* !
279
+ * \brief bit mask to indicate that the tensor is a copy made by the producer.
280
+ *
281
+ * If set, the tensor is considered solely owned throughout its lifetime by the
282
+ * consumer, until the producer-provided deleter is invoked.
283
+ */
284
+ #define DLPACK_FLAG_BITMASK_IS_COPIED (1UL << 1UL )
285
+
272
286
/* !
273
287
* \brief A versioned and managed C Tensor object, manage memory of DLTensor.
274
288
*
@@ -279,7 +293,7 @@ typedef struct DLManagedTensor {
279
293
*
280
294
* \note This is the current standard DLPack exchange data structure.
281
295
*/
282
- struct DLManagedTensorVersioned {
296
+ typedef struct DLManagedTensorVersioned {
283
297
/* !
284
298
* \brief The API and ABI version of the current managed Tensor
285
299
*/
@@ -296,7 +310,7 @@ struct DLManagedTensorVersioned {
296
310
*
297
311
* This should be called to destruct manager_ctx which holds the DLManagedTensorVersioned.
298
312
* It can be NULL if there is no way for the caller to provide a reasonable
299
- * destructor. The destructors deletes the argument self as well.
313
+ * destructor. The destructor deletes the argument self as well.
300
314
*/
301
315
void (*deleter)(struct DLManagedTensorVersioned *self);
302
316
/* !
@@ -308,11 +322,12 @@ struct DLManagedTensorVersioned {
308
322
* stable, to ensure that deleter can be correctly called.
309
323
*
310
324
* \sa DLPACK_FLAG_BITMASK_READ_ONLY
325
+ * \sa DLPACK_FLAG_BITMASK_IS_COPIED
311
326
*/
312
327
uint64_t flags;
313
328
/* ! \brief DLTensor which is being memory managed */
314
329
DLTensor dl_tensor;
315
- };
330
+ } DLManagedTensorVersioned ;
316
331
317
332
#ifdef __cplusplus
318
333
} // DLPACK_EXTERN_C
0 commit comments