t-vi commented on a change in pull request #5822:
URL: https://github.com/apache/incubator-tvm/pull/5822#discussion_r440716367



##########
File path: src/relay/backend/build_module.cc
##########
@@ -244,6 +244,9 @@ class RelayBuildModule : public runtime::ModuleNode {
       GlobalVar main_glb_var = relay_module->GetGlobalVar("main");
       Function main_func = 
Downcast<Function>(relay_module->Lookup(main_glb_var));
       auto new_main = BindParamsByName(main_func, params);
+      // copy module to avoid changing our input
+      relay_module = IRModule(relay_module->functions, 
relay_module->type_definitions,

Review comment:
       OK, so I changed it to call `CopyOnWrite` and it appears to work.
   
   To understand this better, I got the re-instatiation from 
`FunctionPassNode::operator()` here:
   
https://github.com/apache/incubator-tvm/blob/99745a44407f2d1bd06b8c6a47e6c6c5239ec665/src/relay/ir/transform.cc#L123
   is there a reason that isn't done via `CopyOnWrite`?
   Superficially, it seems that the update is then 
   
https://github.com/apache/incubator-tvm/blob/99745a44407f2d1bd06b8c6a47e6c6c5239ec665/src/relay/ir/transform.cc#L135
   which would seem very similar to the `Update` done in the `Optimize`
   
https://github.com/apache/incubator-tvm/blob/99745a44407f2d1bd06b8c6a47e6c6c5239ec665/src/relay/backend/build_module.cc#L247
   which itself just calls add
   
https://github.com/apache/incubator-tvm/blob/99745a44407f2d1bd06b8c6a47e6c6c5239ec665/src/ir/module.cc#L271-L273
   
   Is  something that could also use `CopyOnWrite` or is it not applicable 
there.
   




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