Skip to content

Commit

Permalink
Set dref.handle to None instead of using __del__ functions
Browse files Browse the repository at this point in the history
  • Loading branch information
echuraev committed Jul 24, 2024
1 parent f47ea06 commit d311b3d
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 14 deletions.
3 changes: 0 additions & 3 deletions python/tvm/_ffi/_cython/ndarray.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ cdef class NDArrayBase:
def __set__(self, value):
self._set_handle(value)

def __del__(self):
self.chandle = NULL

property is_view:
def __get__(self):
return self.c_is_view != 0
Expand Down
3 changes: 0 additions & 3 deletions python/tvm/_ffi/_cython/object.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ cdef class ObjectBase:
def __set__(self, value):
self._set_handle(value)

def __del__(self):
self.chandle = NULL

def __dealloc__(self):
CHECK_CALL(TVMObjectFree(self.chandle))

Expand Down
7 changes: 0 additions & 7 deletions python/tvm/_ffi/_cython/packed_func.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -308,22 +308,15 @@ cdef class PackedFuncBase:
def __set__(self, value):
self.c_is_global = value

def __del__(self):
self.c_is_global = 0

property handle:
def __get__(self):
if self.chandle == NULL:
return None
else:
return ctypes.cast(<unsigned long long>self.chandle, ctypes.c_void_p)

def __set__(self, value):
self._set_handle(value)

def __del__(self):
self.chandle = NULL

def __init__(self, handle, is_global):
self._set_handle(handle)
self.c_is_global = is_global
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/runtime/disco/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DModule(DRef):

def __init__(self, dref: DRef, session: "Session") -> None:
self.handle = dref.handle
del dref.handle
dref.handle = None
self.session = session

def __getitem__(self, name: str) -> DPackedFunc:
Expand Down

0 comments on commit d311b3d

Please sign in to comment.