Description
The implementation section of the data_interchange
document contains some incorrect statements:
-
The
__dlpack__
method will produce aPyCapsule
containing aDLPackManagedTensor
, ....
The DLPackManagedTensor
should be DLManagedTensor
consistent with dlpack.h and the DLPack diagram.
I also think it would be beneficial to make it more precise:
The
__dlpack__
method will produce aPyCapsule
object containing a reference toDLPackManagedTensor
struct, ....
-
The consumer must set the
PyCapsule
name to"used_dltensor"
, and call thedeleter
of theDLPackManagedTensor
when it no longer needs the data.
The DLPackManagedTensor
here also should be DLManagedTensor
, but more importantly, the consumer should not be calling the deleter
function. The DLManagedTensor.deleter
must be called by the PyCapsule_Destructor
function provided by the producer.
I also would like to call the mandatory nature of capsule renaming from "dltensor"
to "used_dltensor"
into question. With proper memory management the capsule can be consumed more than once, creating multiple views into the same allocation.
I would therefore like to propose to change that statement from a requirement to a recommendation.