From commits-return-14684-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Fri Jun 5 07:52:17 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 C6DE0180665 for ; Fri, 5 Jun 2020 09:52:16 +0200 (CEST) Received: (qmail 99634 invoked by uid 500); 5 Jun 2020 07:52:16 -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 99595 invoked by uid 99); 5 Jun 2020 07:52:16 -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; Fri, 05 Jun 2020 07:52:16 +0000 From: =?utf-8?q?GitBox?= To: commits@tvm.apache.org Subject: =?utf-8?q?=5BGitHub=5D_=5Bincubator-tvm=5D_kevinthesun_commented_on_a_change?= =?utf-8?q?_in_pull_request_=235699=3A_=5BFrontend=5D=5BTensorFlow=5D_Improv?= =?utf-8?q?e_Control_Flow_and_TensorArray?= Message-ID: <159134353607.17834.4681485557810816104.asfpy@gitbox.apache.org> Date: Fri, 05 Jun 2020 07:52:16 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit References: In-Reply-To: kevinthesun commented on a change in pull request #5699: URL: https://github.com/apache/incubator-tvm/pull/5699#discussion_r435748804 ########## File path: python/tvm/relay/frontend/tensorflow.py ########## @@ -3194,6 +3191,55 @@ def _convert_operator(self, op_name, inputs, attrs, raise NotImplementedError("Operator {} not implemented.".format(op_name)) return sym + def _licm_construct(self, loop_name, node_name): + """Construct a node by considering whether it is + loop invariant with the given while loop. If yes, we + generate a loop Variable. Otherwise, return regular + converted relay expression. + + Parameters + ---------- + loop_name : str + TensorFlow while loop name to be checked. + + node_name : str + TensorFlow node name. + + Returns + ------- + out : relay.Expr or relay.Var + Converted relay expression or loop var. + """ + actual_expr = self._backtrack_construct(node_name) + tn = node_name.split(':').split("^")[-1] + node_name = tn[0] + cloop_name = find_parent_loop_name(node_name, self._while_loop_name_set) + + if loop_name in self._while_loop_name_set and not cloop_name.startswith(loop_name): Review comment: Indeed when user sets tf op name in the way that the graph def node name is in the format of ```loop_name/xxx```, we will recognize it to be part of a while loop. The problem here is tf op name is a part of node name in graph def and there is no ```name``` attribute in node attr. For now I haven't found a better way to do licm node construction. In practice, this case should be rare since while loop name is a complicated hierarchical combination of op and sub-graph names. ---------------------------------------------------------------- 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