dmlc/dlpack

[RFC] Introduce a OpaqueHandle type

tqchen opened this issue · 3 comments

So far DLPack has introduced a few primitive data types, int, float, uint and bfloat. However, we still want to be able to provide a type code for quick extension in a compatible way.

One potential proposal is to bring a OpaqueHandle, type code, which means the target data is actually opaque, while the bitwidth and lanes are still specified. This type code could be used as code for testing data types that are not yet supported and allow frameworks to exchange the data as long as they agree on the dtype.

szha commented

+1 this will be helpful for extensibility. Do you intend to use 3 as its type code, as is done in TVM?

Thanks Tianqi for brining this up!

In numpy, there is a dtype called "object":

>>> import numpy as np
>>> a = np.array([[1, 2], [1, 2, 3]])
>>> a
array([list([1, 2]), list([1, 2, 3])], dtype=object)
>>> a.dtype
dtype('O')
>>> a.shape
(2,)
>>> a.strides
(8,)

Shall we also consider this "object" dtype's type code as OpaqueHandle, or consider this as irrelevant?

Trying to move on this topic. I think having 3 as the type code for OpaqueHandle would be great. Opening this thread for another week to see if there are more thoughts. I do believe that object could use OpaqueHandle if both frameworks agree on them