junrushao commented on code in PR #593:
URL: https://github.com/apache/tvm-ffi/pull/593#discussion_r3575570840


##########
include/tvm/ffi/c_api.h:
##########
@@ -582,6 +582,66 @@ TVM_FFI_DLL int TVMFFIObjectDecRef(TVMFFIObjectHandle obj);
 TVM_FFI_DLL int TVMFFIObjectCreateOpaque(void* handle, int32_t type_index,
                                          void (*deleter)(void* handle), 
TVMFFIObjectHandle* out);
 
+//-----------------------------------------------------------------------
+// Section: ObjectAllocHeader and CustomAllocator
+//-----------------------------------------------------------------------
+/*!
+ * \brief Mandatory header placed immediately before each TVMFFIObject body.
+ *
+ * This header may be used by TVMFFIObject::deleter to reclaim space when a
+ * custom allocator is present. It can also be set to NULL if
+ * TVMFFIObject::deleter directly calls system free. This section must be
+ * available for each Object so a frontend can rely on this field to confirm
+ * if the object came from a certain allocator.

Review Comment:
   I got confused the first few times reading this paragraph. Does it mean:
   
   > `TVMFFIObject::deleter` may decide to use this header as a callback 
mechanism to notify the underlying custom allocator when it lifetime ends. The 
custom allocator is usually responsible for creating frontend language objects 
(e.g. `PyObject`) whose lifetime is tied with the TVM FFI object.



##########
include/tvm/ffi/c_api.h:
##########
@@ -582,6 +582,66 @@ TVM_FFI_DLL int TVMFFIObjectDecRef(TVMFFIObjectHandle obj);
 TVM_FFI_DLL int TVMFFIObjectCreateOpaque(void* handle, int32_t type_index,
                                          void (*deleter)(void* handle), 
TVMFFIObjectHandle* out);
 
+//-----------------------------------------------------------------------
+// Section: ObjectAllocHeader and CustomAllocator
+//-----------------------------------------------------------------------
+/*!
+ * \brief Mandatory header placed immediately before each TVMFFIObject body.
+ *
+ * This header may be used by TVMFFIObject::deleter to reclaim space when a
+ * custom allocator is present. It can also be set to NULL if
+ * TVMFFIObject::deleter directly calls system free. This section must be
+ * available for each Object so a frontend can rely on this field to confirm
+ * if the object came from a certain allocator.

Review Comment:
   I got confused the first few times reading this paragraph. Does it mean:
   
   > `TVMFFIObject::deleter` may decide to use this header as a callback 
mechanism to notify the underlying custom allocator when it lifetime ends. The 
custom allocator is usually responsible for creating frontend language objects 
(e.g. `PyObject`) whose lifetime is tied with the TVM FFI object.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to