areusch commented on a change in pull request #6917:
URL: https://github.com/apache/incubator-tvm/pull/6917#discussion_r528404351



##########
File path: src/runtime/rpc/rpc_module.cc
##########
@@ -36,6 +37,44 @@
 namespace tvm {
 namespace runtime {
 
+// deleter of RPC remote array
+static void RemoteNDArrayDeleter(Object* obj) {
+  auto* ptr = static_cast<NDArray::Container*>(obj);
+  RemoteSpace* space = static_cast<RemoteSpace*>(ptr->dl_tensor.data);
+  space->sess->FreeHandle(ptr->manager_ctx, kTVMNDArrayHandle);
+  delete space;
+  delete ptr;
+}
+
+/*!
+ * \brief Build a local NDArray with remote backing storage.
+ * \param sess the RPCSession which owns the given handle.
+ * \param handle A pointer valid on the remote end which should form the 
`data` field of the
+ *     underlying DLTensor.
+ * \param template_tensor An empty DLTensor whose shape and dtype fields are 
used to fill the newly
+ *     created array. Needed because it's difficult to pass a shape vector as 
a PackedFunc arg.
+ * \param ctx Remote context used with this tensor. Must have non-zero 
RPCSessMask.
+ * \param deleter A function invoked when the local NDArray object is no 
longer used. If `handle`
+ *      needs to be explicitly deleted after the NDArray is freed, this 
function should do that.
+ * \param deleter_ctx An opaque pointer passed to deleter to identify the 
tensor being deleted.
+ */
+NDArray NDArrayFromRemoteOpaqueHandle(std::shared_ptr<RPCSession> sess, void* 
handle,
+                                      DLTensor* template_tensor, TVMContext 
ctx,
+                                      ADTObj::FDeleter deleter, void* 
deleter_ctx) {

Review comment:
       i've changed this so if the handle is nullptr, it won't delete. I thiink 
that will probably work, let me know your thoughts.




----------------------------------------------------------------
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:
[email protected]


Reply via email to