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/02/29 05:27:19 UTC

[GitHub] [incubator-tvm] siju-samuel opened a new pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

siju-samuel opened a new pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971
 
 
   @wyc-ruiker @FrozenGene @u99127 Please help to review and merge this two frontend ops for tflite.
   
   Thanks for contributing to TVM!   Please refer to guideline https://docs.tvm.ai/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386037670
 
 

 ##########
 File path: tests/python/frontend/tflite/test_forward.py
 ##########
 @@ -942,6 +942,22 @@ def _test_squared_difference(data):
     """ One iteration of squared difference """
     return _test_elemwise(math_ops.squared_difference, data)
 
+#######################################################################
+# floor_divide
+# ------------
+
+def _test_floor_divide(data):
+    """ One iteration of floor_div"""
+    return _test_elemwise(math_ops.floordiv, data)
+
+#######################################################################
+# floor_mod
 
 Review comment:
   It would be better to use capitalized `F` at the beginning.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386006490
 
 

 ##########
 File path: python/tvm/relay/frontend/tflite.py
 ##########
 @@ -1532,6 +1534,58 @@ def convert_pad(self, op):
         out = _op.nn.pad(in_expr, pad_width=paddings, pad_value=pad_value)
         return out
 
+    def convert_floor_div(self, op):
+        """Convert TFLite FLOOR_DIV"""
+        if self.is_quantized(op):
+            raise tvm.error.OpNotImplemented(
+                'TFlite quantized FLOOR DIV operator is not supported yet.')
+
+        input_tensors = self.get_input_tensors(op)
+        assert len(input_tensors) == 2, "input tensors length should be 2"
+
+        lhs_tensor = input_tensors[0]
+        if self.has_expr(lhs_tensor.tensor_idx):
+            lhs_expr = self.get_expr(lhs_tensor.tensor_idx)
+        else:
+            lhs_type_str = self.get_tensor_type_str(lhs_tensor.tensor.Type())
+            lhs_expr = self.exp_tab.new_const(self.get_tensor_value(lhs_tensor),
+                                              dtype=lhs_type_str)
+        rhs_tensor = input_tensors[1]
+        if self.has_expr(rhs_tensor.tensor_idx):
+            rhs_expr = self.get_expr(rhs_tensor.tensor_idx)
+        else:
+            rhs_type_str = self.get_tensor_type_str(rhs_tensor.tensor.Type())
+            rhs_expr = self.exp_tab.new_const(self.get_tensor_value(rhs_tensor),
+                                              dtype=rhs_type_str)
+        out = _op.floor_divide(lhs_expr, rhs_expr)
+        return out
+
+    def convert_floor_mod(self, op):
+        """Convert TFLite FLOOR_MOD"""
+        if self.is_quantized(op):
+            raise tvm.error.OpNotImplemented(
+                'TFlite quantized FLOOR MOD operator is not supported yet.')
+
+        input_tensors = self.get_input_tensors(op)
+        assert len(input_tensors) == 2, "input tensors length should be 2"
+
+        lhs_tensor = input_tensors[0]
+        if self.has_expr(lhs_tensor.tensor_idx):
+            lhs_expr = self.get_expr(lhs_tensor.tensor_idx)
+        else:
+            lhs_type_str = self.get_tensor_type_str(lhs_tensor.tensor.Type())
+            lhs_expr = self.exp_tab.new_const(self.get_tensor_value(lhs_tensor),
+                                              dtype=lhs_type_str)
+        rhs_tensor = input_tensors[1]
+        if self.has_expr(rhs_tensor.tensor_idx):
+            rhs_expr = self.get_expr(rhs_tensor.tensor_idx)
+        else:
+            rhs_type_str = self.get_tensor_type_str(rhs_tensor.tensor.Type())
+            rhs_expr = self.exp_tab.new_const(self.get_tensor_value(rhs_tensor),
+                                              dtype=rhs_type_str)
 
 Review comment:
   Same as above.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386007660
 
 

 ##########
 File path: tests/python/frontend/tflite/test_forward.py
 ##########
 @@ -942,6 +942,22 @@ def _test_squared_difference(data):
     """ One iteration of squared difference """
     return _test_elemwise(math_ops.squared_difference, data)
 
+#######################################################################
+# floor_divide
+# ------------------
 
 Review comment:
   `floor_divide` -> `Floor_divide` and align `-` the same length of `Floor_divide` 

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386006487
 
 

 ##########
 File path: python/tvm/relay/frontend/tflite.py
 ##########
 @@ -1532,6 +1534,58 @@ def convert_pad(self, op):
         out = _op.nn.pad(in_expr, pad_width=paddings, pad_value=pad_value)
         return out
 
+    def convert_floor_div(self, op):
+        """Convert TFLite FLOOR_DIV"""
+        if self.is_quantized(op):
+            raise tvm.error.OpNotImplemented(
+                'TFlite quantized FLOOR DIV operator is not supported yet.')
+
+        input_tensors = self.get_input_tensors(op)
+        assert len(input_tensors) == 2, "input tensors length should be 2"
+
+        lhs_tensor = input_tensors[0]
+        if self.has_expr(lhs_tensor.tensor_idx):
+            lhs_expr = self.get_expr(lhs_tensor.tensor_idx)
+        else:
+            lhs_type_str = self.get_tensor_type_str(lhs_tensor.tensor.Type())
+            lhs_expr = self.exp_tab.new_const(self.get_tensor_value(lhs_tensor),
+                                              dtype=lhs_type_str)
+        rhs_tensor = input_tensors[1]
+        if self.has_expr(rhs_tensor.tensor_idx):
+            rhs_expr = self.get_expr(rhs_tensor.tensor_idx)
+        else:
+            rhs_type_str = self.get_tensor_type_str(rhs_tensor.tensor.Type())
+            rhs_expr = self.exp_tab.new_const(self.get_tensor_value(rhs_tensor),
+                                              dtype=rhs_type_str)
 
 Review comment:
   We should use `_convert_elemwise` to catch constant input.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386007675
 
 

 ##########
 File path: tests/python/frontend/tflite/test_forward.py
 ##########
 @@ -942,6 +942,22 @@ def _test_squared_difference(data):
     """ One iteration of squared difference """
     return _test_elemwise(math_ops.squared_difference, data)
 
+#######################################################################
+# floor_divide
+# ------------------
+
+def _test_floor_divide(data):
+    """ One iteration of floor_div"""
+    return _test_elemwise(math_ops.floordiv, data)
+
+#######################################################################
+# floor_mod
+# ------------------
 
 Review comment:
   `floor_mod` -> `Floor_mod` and align `-` the same length of `Floor_mod`

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] siju-samuel commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
siju-samuel commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386007643
 
 

 ##########
 File path: python/tvm/relay/frontend/tflite.py
 ##########
 @@ -1532,6 +1534,58 @@ def convert_pad(self, op):
         out = _op.nn.pad(in_expr, pad_width=paddings, pad_value=pad_value)
         return out
 
+    def convert_floor_div(self, op):
+        """Convert TFLite FLOOR_DIV"""
+        if self.is_quantized(op):
+            raise tvm.error.OpNotImplemented(
+                'TFlite quantized FLOOR DIV operator is not supported yet.')
+
+        input_tensors = self.get_input_tensors(op)
+        assert len(input_tensors) == 2, "input tensors length should be 2"
+
+        lhs_tensor = input_tensors[0]
+        if self.has_expr(lhs_tensor.tensor_idx):
+            lhs_expr = self.get_expr(lhs_tensor.tensor_idx)
+        else:
+            lhs_type_str = self.get_tensor_type_str(lhs_tensor.tensor.Type())
+            lhs_expr = self.exp_tab.new_const(self.get_tensor_value(lhs_tensor),
+                                              dtype=lhs_type_str)
+        rhs_tensor = input_tensors[1]
+        if self.has_expr(rhs_tensor.tensor_idx):
+            rhs_expr = self.get_expr(rhs_tensor.tensor_idx)
+        else:
+            rhs_type_str = self.get_tensor_type_str(rhs_tensor.tensor.Type())
+            rhs_expr = self.exp_tab.new_const(self.get_tensor_value(rhs_tensor),
+                                              dtype=rhs_type_str)
 
 Review comment:
   Thanks @wyc-ruiker, done 

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] FrozenGene merged pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
FrozenGene merged pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971
 
 
   

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
wyc-ruiker commented on a change in pull request #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#discussion_r386037666
 
 

 ##########
 File path: tests/python/frontend/tflite/test_forward.py
 ##########
 @@ -942,6 +942,22 @@ def _test_squared_difference(data):
     """ One iteration of squared difference """
     return _test_elemwise(math_ops.squared_difference, data)
 
+#######################################################################
+# floor_divide
 
 Review comment:
   It would be better to use capitalized `F` at the beginning.

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


With regards,
Apache Git Services

[GitHub] [incubator-tvm] FrozenGene commented on issue #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support

Posted by GitBox <gi...@apache.org>.
FrozenGene commented on issue #4971: [TFLITE]FLOOR_MOD & FLOOR_DIV support
URL: https://github.com/apache/incubator-tvm/pull/4971#issuecomment-593199865
 
 
   Thanks @siju-samuel @wyc-ruiker @anijain2305 It is merged now.

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


With regards,
Apache Git Services