wkcn edited a comment on issue #12047: [MXNET-779]Add DLPack Transformation API URL: https://github.com/apache/incubator-mxnet/pull/12047#issuecomment-414905679 @tqchen Hi! What should I do next for this PR? For the release of DLPack, here are the implements of TVM, PyTorch and Cupy. [TVM src/runtime/ndarray.cc#L148](https://github.com/dmlc/tvm/blob/master/src/runtime/ndarray.cc#L148) ```c++ NDArray NDArray::FromDLPack(DLManagedTensor* tensor) { NDArray::Container* data = new NDArray::Container(); data->deleter = Internal::DLPackDeleter; data->manager_ctx = tensor; data->dl_tensor = tensor->dl_tensor; return NDArray(data); } ``` [PyTorch aten/src/ATen/DLConvertor.cpp#L170](https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/DLConvertor.cpp#L170) ```C++ Tensor fromDLPack(const DLManagedTensor* src) { Backend backend = getATenBackend(src->dl_tensor.ctx); ScalarType stype = toScalarType(src->dl_tensor.dtype); auto deleter = [src](void * self) { src->deleter(const_cast<DLManagedTensor*>(src)); }; return getType(backend, stype).tensorFromBlob( src->dl_tensor.data, IntList(src->dl_tensor.shape, src->dl_tensor.ndim), IntList(src->dl_tensor.strides, src->dl_tensor.ndim), deleter); } ``` [CuPy cupy/core/dlpack.pyx#L231](https://github.com/cupy/cupy/blob/master/cupy/core/dlpack.pyx#L231) ```python mem = DLPackMemory(dltensor) mem_ptr = memory.MemoryPointer(mem, mem.dlm_tensor.dl_tensor.byte_offset) cupy_array = ndarray(shape_vec, cp_dtype, mem_ptr) ``` The all NDArray save dltensor. So I add a new member `dlpack` for mx.nd.NDArray for store of dltensor.
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
