diff --git a/apps/extension/src/tvm_ext.cc b/apps/extension/src/tvm_ext.cc index 788c28da18d34..367d99c462bd6 100644 --- a/apps/extension/src/tvm_ext.cc +++ b/apps/extension/src/tvm_ext.cc @@ -63,38 +63,40 @@ namespace tvm_ext { */ class NDSubClass : public tvm::runtime::NDArray { public: - class SubContainer : public NDArray::Container { + class SubContainer : public NDArray::ContainerObj { public: SubContainer(int addtional_info) : addtional_info_(addtional_info) { array_type_code_ = array_type_info::code; } - static bool Is(NDArray::Container *container) { + static bool Is(NDArray::ContainerObj* container) { SubContainer *c = static_cast(container); return c->array_type_code_ == array_type_info::code; } int addtional_info_{0}; }; - NDSubClass(NDArray::Container *container) { + NDSubClass() { + } + + NDSubClass(ObjectPtr n) + : NDArray(n) { + } + + NDSubClass(NDArray::ContainerObj *container) { if (container == nullptr) { - data_ = nullptr; return; } CHECK(SubContainer::Is(container)); - container->IncRef(); - data_ = container; - } - ~NDSubClass() { - this->reset(); + data_ = GetObjectPtr(container); } NDSubClass AddWith(const NDSubClass &other) const { - SubContainer *a = static_cast(data_); - SubContainer *b = static_cast(other.data_); + SubContainer *a = static_cast(get_mutable()); + SubContainer *b = static_cast(other.get_mutable()); CHECK(a != nullptr && b != nullptr); return NDSubClass(new SubContainer(a->addtional_info_ + b->addtional_info_)); } int get_additional_info() const { - SubContainer *self = static_cast(data_); + SubContainer *self = static_cast(get_mutable()); CHECK(self != nullptr); return self->addtional_info_; } diff --git a/include/tvm/runtime/ndarray.h b/include/tvm/runtime/ndarray.h index e2f281626a0b0..80f6c465e11f7 100644 --- a/include/tvm/runtime/ndarray.h +++ b/include/tvm/runtime/ndarray.h @@ -206,14 +206,6 @@ class NDArray::Content { * (e.g. reference to original memory when creating views). */ void* manager_ctx{nullptr}; - /*! - * \brief deprecated. - * - * \note The customized deleter is helpful to enable - * different ways of memory allocator that are not - * currently defined by the system. - */ - void (*__deleter__)(ContainerObj* self) = nullptr; protected: friend class NDArray; diff --git a/include/tvm/runtime/packed_func.h b/include/tvm/runtime/packed_func.h index 31ef88a61dea2..bdafe4c81fb16 100644 --- a/include/tvm/runtime/packed_func.h +++ b/include/tvm/runtime/packed_func.h @@ -732,8 +732,7 @@ class TVMRetValue : public TVMPODValue_ { this->Clear(); type_code_ = kNDArrayContainer; value_.v_handle = static_cast(other.get_mutable()); - other.data_.data_ = nullptr; - CHECK(other.get() == nullptr); + ObjectRef::ClearAfterMove(&other); return *this; } TVMRetValue& operator=(ObjectRef other) { diff --git a/python/tvm/_ffi/_cython/base.pxi b/python/tvm/_ffi/_cython/base.pxi index 4b7b2c88ffa50..45d1053d414c4 100644 --- a/python/tvm/_ffi/_cython/base.pxi +++ b/python/tvm/_ffi/_cython/base.pxi @@ -82,7 +82,6 @@ ctypedef void* ObjectHandle ctypedef struct TVMNDArrayContainer: DLTensor dl_tensor void* manager_ctx - void (*deleter)(DLManagedTensor* self) int32_t array_type_info ctypedef TVMNDArrayContainer* TVMNDArrayContainerHandle diff --git a/python/tvm/_ffi/runtime_ctypes.py b/python/tvm/_ffi/runtime_ctypes.py index 2dbb67dfbf739..ec4bb53250c0f 100644 --- a/python/tvm/_ffi/runtime_ctypes.py +++ b/python/tvm/_ffi/runtime_ctypes.py @@ -276,7 +276,6 @@ class TVMNDArrayContainer(ctypes.Structure): """TVM NDArray::Container""" _fields_ = [("dl_tensor", TVMArray), ("manager_ctx", ctypes.c_void_p), - ("deleter", ctypes.c_void_p), ("array_type_info", ctypes.c_int32)] TVMNDArrayContainerHandle = ctypes.POINTER(TVMNDArrayContainer)