From 967768dadfcaebd9982416be1c608dbbb03dc370 Mon Sep 17 00:00:00 2001 From: Junru Shao Date: Fri, 8 Oct 2021 00:14:45 -0700 Subject: [PATCH] [BugFix] Fix to allow zero-copy between numpy and TVM NDArrays --- python/tvm/_ffi/_ctypes/ndarray.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/tvm/_ffi/_ctypes/ndarray.py b/python/tvm/_ffi/_ctypes/ndarray.py index 1aa6964d952f..fc8768448dde 100644 --- a/python/tvm/_ffi/_ctypes/ndarray.py +++ b/python/tvm/_ffi/_ctypes/ndarray.py @@ -53,9 +53,9 @@ def _dlpack_deleter(pycapsule): if ctypes.pythonapi.PyCapsule_IsValid(pycapsule, _c_str_dltensor): ptr = ctypes.pythonapi.PyCapsule_GetPointer(pycapsule, _c_str_dltensor) # enforce type to make sure it works for all ctypes - ptr = ctypes.cast(ctypes.c_void_p, ptr) + ptr = ctypes.cast(ptr, ctypes.c_void_p) _LIB.TVMDLManagedTensorCallDeleter(ptr) - ctypes.pythonapi.PyCapsule_SetDestructor(dltensor, TVMPyCapsuleDestructor(0)) + ctypes.pythonapi.PyCapsule_SetDestructor(pycapsule, None) _c_dlpack_deleter = TVMPyCapsuleDestructor(_dlpack_deleter)