wkcn commented on a change in pull request #12047: [MXNET-779]Add DLPack Transformation API URL: https://github.com/apache/incubator-mxnet/pull/12047#discussion_r209134860
########## File path: python/mxnet/_ctypes/ndarray.py ########## @@ -31,21 +31,24 @@ class NDArrayBase(object): """Base data structure for ndarray""" - __slots__ = ["handle", "writable"] + __slots__ = ["handle", "writable", "dlpack"] # pylint: disable= no-member - def __init__(self, handle, writable=True): + def __init__(self, handle, writable=True, dlpack=None): Review comment: I use NDArrayDLManager whose member is a copy of NDArray, which increases refcount. The deleter of DLPack is to delete NDArrayDLManager, which decreases NDArray refcount. If a new NDArray() created by DLPack, the deleter of DLPack will be called by the new NDArray. Similarly, If a PyTorch Tensor createed by DLPack (MXNet), the deleter will be called by the new PyTorch Tensor. NDArray (CPP and Python class) doesn't have deleter API, so I set the DLPack as the member of NDArray (Python). When NDArray generated by DLPack releases, the DLPack object in the NDArray will release, then the deleter function in DLPack will be called. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services