Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions python/taichi/lang/_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ def __getitem__(self, key):
"""
raise NotImplementedError()

def __del__(self):
if impl is None or self.arr is None:
return

rt = impl.get_runtime()
if rt is not None and rt.prog is not None:
rt.prog.delete_ndarray(self.arr)

@python_scope
def fill(self, val):
"""Fills ndarray with a specific scalar value.
Expand Down Expand Up @@ -243,10 +251,6 @@ def __init__(self, dtype, arr_shape):
self.shape = tuple(self.arr.shape)
self.element_type = dtype

def __del__(self):
if impl is not None and impl.get_runtime() is not None and impl.get_runtime().prog is not None:
impl.get_runtime().prog.delete_ndarray(self.arr)

@property
def element_shape(self):
return ()
Expand Down
Loading