anijain2305 commented on a change in pull request #4805:
URL: https://github.com/apache/incubator-tvm/pull/4805#discussion_r420254831



##########
File path: python/tvm/relay/frontend/tflite.py
##########
@@ -463,6 +484,114 @@ def convert_relu(self, op):
 
         return out
 
+    def convert_relu6(self, op):
+        """Convert TFLite ReLU6"""
+        try:
+            from tflite.Operator import Operator
+        except ImportError:
+            raise ImportError("The tflite package must be installed")
+
+        assert isinstance(op, Operator)
+        input_tensors = self.get_input_tensors(op)
+        assert len(input_tensors) == 1, "input tensors length should be 1"
+        input_tensor = input_tensors[0]
+        in_expr = self.get_expr(input_tensor.tensor_idx)
+
+        output_tensors = self.get_output_tensors(op)
+        assert len(output_tensors) == 1, "output tensors length should be 1"
+        output_tensor = output_tensors[0]
+
+        if input_tensor.qnn_params:
+            in_expr = self.dequantize(in_expr, input_tensor)
+        out = _op.clip(in_expr, a_min=0, a_max=6)
+        if output_tensor.qnn_params:
+            out = self.quantize(out, output_tensor)

Review comment:
       This is expensive. Lets try this 
https://github.com/apache/incubator-tvm/pull/5479/files




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to