You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2019/12/29 18:26:49 UTC

[GitHub] [incubator-tvm] tqchen commented on a change in pull request #4581: [REFACTOR][RUNTIME] Update NDArray use the Unified Object System

tqchen commented on a change in pull request #4581: [REFACTOR][RUNTIME] Update NDArray use the Unified Object System
URL: https://github.com/apache/incubator-tvm/pull/4581#discussion_r361865346
 
 

 ##########
 File path: include/tvm/runtime/ndarray.h
 ##########
 @@ -315,49 +254,38 @@ class NDArray::Container {
     dl_tensor.byte_offset = 0;
     dl_tensor.ctx = ctx;
   }
-
-  /*! \brief developer function, increases reference counter */
-  void IncRef() {
-    ref_counter_.fetch_add(1, std::memory_order_relaxed);
-  }
-  /*! \brief developer function, decrease reference counter */
-  void DecRef() {
-    if (ref_counter_.fetch_sub(1, std::memory_order_release) == 1) {
-      std::atomic_thread_fence(std::memory_order_acquire);
-      if (this->deleter != nullptr) {
-        (*this->deleter)(this);
-      }
-    }
+  /*!
+   * \brief Set the deleter field.
+   * \param deleter The deleter.
+   */
+  void SetDeleter(FDeleter deleter) {
+    deleter_ = deleter;
   }
-};
 
-// implementations of inline functions
-// the usages of functions are documented in place.
-inline NDArray::NDArray(Container* data)
-  : data_(data) {
-  if (data != nullptr) {
-    data_->IncRef();
-  }
-}
+  // Expose DecRef and IncRef as public function
+  // NOTE: they are only for developer purposes only.
+  using Object::DecRef;
+  using Object::IncRef;
 
-inline NDArray::NDArray(const NDArray& other)
-  : data_(other.data_) {
-  if (data_ != nullptr) {
-    data_->IncRef();
-  }
-}
+  // Information for object protocol.
+  static constexpr const uint32_t _type_index = TypeIndex::kDynamic;
+  static constexpr const uint32_t _type_child_slots = 0;
+  static constexpr const uint32_t _type_child_slots_can_overflow = true;
+  static constexpr const char* _type_key = "NDArray";
 
 Review comment:
   We should refer to the final reference type name, so NDArray is correct here

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services