vvchernov commented on code in PR #11358:
URL: https://github.com/apache/tvm/pull/11358#discussion_r967164258


##########
src/runtime/vm/vm.cc:
##########
@@ -143,8 +143,15 @@ PackedFunc VirtualMachine::GetFunction(const std::string& 
name,
       } else {
         auto it = inputs_.find(func_name);
         ICHECK(it != inputs_.end()) << "Input has not been set for function " 
<< func_name;
-        const std::vector<ObjectRef>& func_args = it->second;
-        *rv = Invoke(func, func_args);
+        const std::vector<ObjectRef>& input_args = it->second;
+        if (set_outputs_enabled_.count(func_name) && 
set_outputs_enabled_[func_name]) {
+          ICHECK(outputs_.count(func_name))
+              << "Outputs have not been set for function " << func_name;
+          *rv = Invoke(func, input_args, outputs_[func_name]);
+          set_outputs_enabled_[func_name] = false;

Review Comment:
   It depends on scenario of using output tensors allocated outside. I see two 
options: 1. In-place scenario: memory for output tensors is allocated once. 
Each new inference (invoke) writes result in this memory. 2. We should insert 
new inputs/outputs for each new infer. Just now the second scenario is 
implemented and in that case `outputs_` can be cleared. But in the first 
scenario we should store `outputs_`. What do you think should I support the 
first scenario instead of second one or both ones or keep the current one?



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

Reply via email to