From commits-return-15478-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Tue Jun 16 09:31:55 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id D0C53180621 for ; Tue, 16 Jun 2020 11:31:54 +0200 (CEST) Received: (qmail 16500 invoked by uid 500); 16 Jun 2020 09:31:54 -0000 Mailing-List: contact commits-help@tvm.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tvm.apache.org Delivered-To: mailing list commits@tvm.apache.org Received: (qmail 16490 invoked by uid 99); 16 Jun 2020 09:31:54 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jun 2020 09:31:54 +0000 From: =?utf-8?q?GitBox?= To: commits@tvm.apache.org Subject: =?utf-8?q?=5BGitHub=5D_=5Bincubator-tvm=5D_t-vi_commented_on_a_change_in_pul?= =?utf-8?q?l_request_=235822=3A_fix_relay=2Ebuild_to_not_change_the_module_a?= =?utf-8?q?rgument_in_place?= Message-ID: <159229991414.8807.10183452694476863367.asfpy@gitbox.apache.org> Date: Tue, 16 Jun 2020 09:31:54 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit In-Reply-To: References: 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(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: users@infra.apache.org