tvm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-tvm] lixiaoquan commented on a change in pull request #5699: [Frontend][TensorFlow] Improve Control Flow and TensorArray
Date Fri, 05 Jun 2020 03:17:55 GMT

lixiaoquan commented on a change in pull request #5699:
URL: https://github.com/apache/incubator-tvm/pull/5699#discussion_r435668087



##########
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:
       This check of cloop_name doesn't work sometimes becuase of op's name. Patch to reproduce
   ```
   diff --git a/tests/python/frontend/tensorflow/test_control_flow.py b/tests/python/frontend/tensorflow/test_control_flow.py
   index 90035279b..e2f8ec115 100644
   --- a/tests/python/frontend/tensorflow/test_control_flow.py
   +++ b/tests/python/frontend/tensorflow/test_control_flow.py
   @@ -46,7 +46,7 @@ def check_equal(graph, tf_out, input_map=None):
    def test_vanilla_loop():
        graph = tf.Graph()
        with graph.as_default():
   -        i = tf.constant(0)
   +        i = tf.constant(0, name="while/counter")
    
            def c(i): return tf.less(i, 10)
    ```
   




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



Mime
View raw message