junrushao1994 commented on a change in pull request #5822:
URL: https://github.com/apache/incubator-tvm/pull/5822#discussion_r440679465
##########
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:
If I understand the issue correctly, I think we need to call CopyOnWrite
instead.
IRModule is actually defined with `CopyOnWrite` method
[here](https://github.com/apache/incubator-tvm/blob/master/include/tvm/ir/module.h#L332),
the macro expands to
[this](https://github.com/apache/incubator-tvm/blob/master/include/tvm/runtime/object.h#L755-L763).
What we need to do is just call its `CopyOnWrite` method to generate a unique
copy of IRModule.
----------------------------------------------------------------
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]