You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/04/29 11:54:28 UTC

[GitHub] [incubator-tvm] maheshambule opened a new pull request #5474: [Frontend][TFLite] ADD_N operator

maheshambule opened a new pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474


   - added support for ADD_N operator 
   - refactored some of the ADD code


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



[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
maheshambule commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r418572669



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -2280,6 +2276,20 @@ def get_expr(self, input_tensor_idx):
     def has_expr(self, input_tensor_idx):
         return self.exp_tab.has_expr(get_tensor_name(self.subgraph, input_tensor_idx))
 
+    def get_tensor_expr(self, tensor):

Review comment:
       @FrozenGene, @siju-samuel, Corrected the func name here also based on the comment on https://github.com/apache/incubator-tvm/pull/5486




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



[GitHub] [incubator-tvm] mbaret commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
mbaret commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r417873031



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -863,6 +845,21 @@ def convert_add(self, op):
             return self._convert_elemwise(_qnn.op.add, op)
         return self._convert_elemwise(_op.add, op)
 
+    def convert_add_n(self, op):
+        """Convert TFLite ADD_N"""
+        output_tensors = self.get_output_tensors(op)
+        assert len(output_tensors) == 1, "output tensors length should be 1"
+
+        input_tensors = self.get_input_tensors(op)
+        assert not input_tensors[0].qnn_params, "TFLite does not support quantized ADD_N."
+        lhs_expr = self.get_tensor_or_const_expr(input_tensors[0])
+        for rhs_tensor in input_tensors[1:]:

Review comment:
       I believe doing x[1:] with len(x) < 2 will just return an empty list rather than throw an error.




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



[GitHub] [incubator-tvm] mbaret commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
mbaret commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r417383328



##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -1896,6 +1896,41 @@ def test_forward_mediapipe_hand_landmark():
         tvm.testing.assert_allclose(np.squeeze(tvm_output[i]), np.squeeze(tflite_output[i]),
                                     rtol=1e-5, atol=1e-5)
 
+#######################################################################

Review comment:
       I think this should be moved so it's with the other element-wise tests and we keep the order the tests are run in the same as the order they appear in the file.




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



[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
maheshambule commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r418116057



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -774,6 +775,21 @@ def convert_square(self, op):
 
         return out
 
+    def get_tensor_or_const_expr(self, tensor):
+        if self.has_expr(tensor.tensor_idx):

Review comment:
       This is already addressed in previous commits.




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



[GitHub] [incubator-tvm] maheshambule commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
maheshambule commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r417808625



##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -1896,6 +1896,41 @@ def test_forward_mediapipe_hand_landmark():
         tvm.testing.assert_allclose(np.squeeze(tvm_output[i]), np.squeeze(tflite_output[i]),
                                     rtol=1e-5, atol=1e-5)
 
+#######################################################################

Review comment:
       Moved.




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



[GitHub] [incubator-tvm] maheshambule commented on pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
maheshambule commented on pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#issuecomment-624749216


   @tqchen Could you please help in merging this PR?


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



[GitHub] [incubator-tvm] siju-samuel commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
siju-samuel commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r417851626



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -863,6 +845,21 @@ def convert_add(self, op):
             return self._convert_elemwise(_qnn.op.add, op)
         return self._convert_elemwise(_op.add, op)
 
+    def convert_add_n(self, op):
+        """Convert TFLite ADD_N"""
+        output_tensors = self.get_output_tensors(op)
+        assert len(output_tensors) == 1, "output tensors length should be 1"
+
+        input_tensors = self.get_input_tensors(op)
+        assert not input_tensors[0].qnn_params, "TFLite does not support quantized ADD_N."
+        lhs_expr = self.get_tensor_or_const_expr(input_tensors[0])
+        for rhs_tensor in input_tensors[1:]:

Review comment:
       assert if len(input_tensors) <2 ? Othersiwe input_tensors[1: ] will throw error.

##########
File path: tests/python/frontend/tflite/test_forward.py
##########
@@ -1142,6 +1142,43 @@ def test_all_elemwise():
         _test_forward_elemwise(_test_floor_divide)
         _test_forward_elemwise(_test_floor_mod)
 
+
+#######################################################################
+# AddN
+# ----------------------

Review comment:
       remove unnecessary dashes




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



[GitHub] [incubator-tvm] u99127 commented on a change in pull request #5474: [Frontend][TFLite] ADD_N operator

Posted by GitBox <gi...@apache.org>.
u99127 commented on a change in pull request #5474:
URL: https://github.com/apache/incubator-tvm/pull/5474#discussion_r418110316



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -774,6 +775,21 @@ def convert_square(self, op):
 
         return out
 
+    def get_tensor_or_const_expr(self, tensor):
+        if self.has_expr(tensor.tensor_idx):

Review comment:
       This could do with a pydoc documentation for the interface.




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