taichi
taichi copied to clipboard
Ndarray lifetime management
Current ndarray implementation doesn't respect python. For example if you do del ndarray1
only the ndarray object is deleted but the underlying memory is not freed. (managed by Program)
Ideally we'd want ndarray memory to be freed either when python GCs it or C++ Program gets destructed, whichever comes first.
- Ndarray cannot be managed solely by Python (like holding a shared pointer to the Device). Otherwise
ti.reset()
won't be able to destructDevice
object as it does before. - Ndarray cannot be solely managed by C++
Program
class. Otherwise the underlying memory of ndarray won't be freed even after user callsdel ndarray
.
We gave this a try but had to revert it in https://github.com/taichi-dev/taichi/pull/5019. Need to understand the root cause of the bug first.