tqchen commented on issue #264: URL: https://github.com/apache/tvm-ffi/issues/264#issuecomment-3543510468
First, all to clarify the state: `ffi::Tensor::FromEnvAlloc(TVMFFIEnvTensorAlloc, ...);` will allocate tensor whose deleter is not related to loaded dll. So we should point users to use write code in this way. This does mean that we should perhaps have a default EnvAllocator for CPU if it is not set. For general case, the main issue is that FromNDAlloc relies on a custom deleter that specializes in the module, this is because we do not know where the object gets allocated(e.g. they can get allocated in rust) so we need customized deleter. The deleter function was in the loaded dll. Note that this happens when we have loaded modules that are short lived(rather than like ctypes which persists). The same problem exists for template objects allocated and returned from the dll. For cases where we want tensor to keep module alive, we could in theory do tensor._keep_alive = module manually, but doing so automatically likely also come with its own issue and does not solve problem of the other objects. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
