Skip to content

Commit ec5a117

Browse files
committed
Add more comments on the null rationale
1 parent 1546501 commit ec5a117

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

include/dlpack/dlpack.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,23 @@ typedef struct {
254254
int32_t ndim;
255255
/*! \brief The data type of the pointer*/
256256
DLDataType dtype;
257-
/*! \brief The shape of the tensor */
257+
/*!
258+
* \brief The shape of the tensor
259+
*
260+
* When ndim == 0, we suggest to set the shape to NULL.
261+
*/
258262
int64_t* shape;
259263
/*!
260264
* \brief strides of the tensor (in number of elements, not bytes),
261265
* can not be NULL if ndim != 0, must points to
262266
* an array of ndim elements that specifies the strides.
267+
*
268+
* When ndim == 0, we suggest to set the strides to NULL.
269+
*
270+
* \note Before DLPack v1.2, strides can be NULL to indicate contiguous data.
271+
* This is not allowed in DLPack v1.2 and later. The rationale
272+
* is to simplify the consumer hanlding, and most frameworks already
273+
* always returns the strides when ndim != 0.
263274
*/
264275
int64_t* strides;
265276
/*! \brief The offset in bytes to the beginning pointer to data */

0 commit comments

Comments
 (0)