Skip to content

Commit

Permalink
[RUNTIME][NDARRAY] Remove deprecated field, update extension example.
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Dec 26, 2019
1 parent 4d85668 commit 26d9cbc
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
26 changes: 14 additions & 12 deletions apps/extension/src/tvm_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<NDSubClass>::code;
}
static bool Is(NDArray::Container *container) {
static bool Is(NDArray::ContainerObj* container) {
SubContainer *c = static_cast<SubContainer*>(container);
return c->array_type_code_ == array_type_info<NDSubClass>::code;
}
int addtional_info_{0};
};
NDSubClass(NDArray::Container *container) {
NDSubClass() {
}

NDSubClass(ObjectPtr<Object> 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<Object>(container);
}
NDSubClass AddWith(const NDSubClass &other) const {
SubContainer *a = static_cast<SubContainer*>(data_);
SubContainer *b = static_cast<SubContainer*>(other.data_);
SubContainer *a = static_cast<SubContainer*>(get_mutable());
SubContainer *b = static_cast<SubContainer*>(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<SubContainer*>(data_);
SubContainer *self = static_cast<SubContainer*>(get_mutable());
CHECK(self != nullptr);
return self->addtional_info_;
}
Expand Down
8 changes: 0 additions & 8 deletions include/tvm/runtime/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions include/tvm/runtime/packed_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -732,8 +732,7 @@ class TVMRetValue : public TVMPODValue_ {
this->Clear();
type_code_ = kNDArrayContainer;
value_.v_handle = static_cast<NDArray::Content*>(other.get_mutable());
other.data_.data_ = nullptr;
CHECK(other.get() == nullptr);
ObjectRef::ClearAfterMove(&other);
return *this;
}
TVMRetValue& operator=(ObjectRef other) {
Expand Down
1 change: 0 additions & 1 deletion python/tvm/_ffi/_cython/base.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion python/tvm/_ffi/runtime_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 26d9cbc

Please sign in to comment.