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 2022/12/15 18:13:17 UTC

[GitHub] [tvm] vinx13 commented on a diff in pull request #13623: [Relay][Runtime] Add `set_input/output_zero_copy` in python

vinx13 commented on code in PR #13623:
URL: https://github.com/apache/tvm/pull/13623#discussion_r1049990723


##########
src/runtime/graph_executor/graph_executor.cc:
##########
@@ -160,6 +160,16 @@ void GraphExecutor::SetInput(int index, DLTensor* data_in) {
   uint32_t eid = this->entry_id(input_nodes_[index], 0);
   data_entry_[eid].CopyFrom(data_in);
 }
+/*!
+ * \brief set index-th output to the graph.
+ * \param index The output index.
+ * \param data_in The output data.
+ */
+void GraphExecutor::SetOutput(int index, DLTensor* data_in) {

Review Comment:
   not needed



##########
python/tvm/contrib/graph_executor.py:
##########
@@ -195,6 +198,49 @@ def set_input(self, key=None, value=None, **params):
                 if val:
                     self._get_input(k).copyfrom(params[k])
 
+    def set_output(self, key, value):
+        """Set outputs to the module
+
+        Parameters
+        ----------
+        key : int or str
+           The output key
+
+        value : the output value
+           The output value
+        """
+        self._set_output(key, value)

Review Comment:
   this is not needed, it doesn't make sense to copy external data to the output tensor



##########
python/tvm/contrib/graph_executor.py:
##########
@@ -195,6 +198,49 @@ def set_input(self, key=None, value=None, **params):
                 if val:
                     self._get_input(k).copyfrom(params[k])
 
+    def set_output(self, key, value):
+        """Set outputs to the module
+
+        Parameters
+        ----------
+        key : int or str
+           The output key
+
+        value : the output value
+           The output value
+        """
+        self._set_output(key, value)
+
+    def set_input_zero_copy(self, key, value, **params):
+        """Set inputs to the module via kwargs with zero memory copy
+
+        Parameters
+        ----------
+        key : int or str
+           The input key
+
+        value : the input value in DLPack
+           The input key
+
+        params : dict of str to NDArray
+           Additional arguments
+        """
+        self._set_input_zero_copy(key, value)
+        self.set_input(None, None, **params)

Review Comment:
   not needed



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org