> We may need to find a way to make our containers capable of holding NDArrays. > FFI containers are mainly adapted from TVM and can only hold ObjectRefs from > object system. Different from TVM's NDArray, which inherits from ObjectRef > and there is customized smart pointer called ObjectPtr to count references, > NDArray in MXNet uses shared pointer to hold internal data. Holding NDArray > in container requires NDArrayHandle can affect NDArray's reference counting.
It seems that the key difference between the TVM NDArray and MXNet NDArray wrt to FFI is that in TVM, the Ref will own a copy of the NDArray, whereas in the current implementation, MXNet NDArrayHandle in the FFI only owns a pointer to the underlying array. Changing the MXNet FFI to also own the underlying NDArray (copy constructor instead of pointer) should resolve the issue. Copy of the MXNet array would be cheap, as it only holds some metadata information and a shared pointer to the underlying storage chunk. WDYT? -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/apache/incubator-mxnet/issues/19672#issuecomment-745043940