wkcn edited a comment on issue #13658: Converting MX array to DLPack crashes when MX array goes out-of-scope URL: https://github.com/apache/incubator-mxnet/issues/13658#issuecomment-448429133 Reproduce the error on Ubuntu16.04 I print the datas of DLTensor in `include/tvm/runtime/ndarray.h ` ```c++ inline size_t GetDataSize(const DLTensor& arr) { size_t size = 1; cout << "DLTensor Ptr: " << &arr << endl; cout << "Shape Ptr: " << arr.shape << endl; cout << "ndim: " << arr.ndim << endl; for (tvm_index_t i = 0; i < arr.ndim; ++i) { cout << "shape[" << i << "] = " << arr.shape[i] << endl; size *= static_cast<size_t>(arr.shape[i]); } cout << "Bits: " << int(arr.dtype.bits) << endl; cout << "lanes: " << int(arr.dtype.lanes) << endl; size *= (arr.dtype.bits * arr.dtype.lanes + 7) / 8; return size; } ``` Error Message: ``` DLTensor Ptr: 0x3496040 Shape Ptr: 0x34839f0 ndim: 1 shape[0] = -2992783055023189668 Bits: 64 lanes: 1 ``` In MXNet, `include/mxnet/tensor_blob.h` ```c++ inline void SetDLTensor(int dev_mask, int dev_id) { dltensor_.data = dptr_; dltensor_.ctx = DLContext{static_cast<DLDeviceType>(dev_mask), dev_id}; dltensor_.ndim = shape_.ndim(); dltensor_.dtype = DTypeTransform(type_flag_); dltensor_.shape = shape_.data(); dltensor_.strides = nullptr; dltensor_.byte_offset = 0; } ``` It seems that `TShape` object `shape)_` has been reallocated in MXNet.
---------------------------------------------------------------- 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
