Skip to content

data-interchange description of DLPack  #337

Closed
@oleksandr-pavlyk

Description

@oleksandr-pavlyk

The implementation section of the data_interchange document contains some incorrect statements:

  1. The __dlpack__ method will produce a PyCapsule containing a DLPackManagedTensor, ....

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 a PyCapsule object containing a reference to DLPackManagedTensor struct, ....

  1. The consumer must set the PyCapsule name to "used_dltensor" , and call the deleter of the DLPackManagedTensor 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions