wyc-ruiker commented on a change in pull request #4805: [Frontend][TFlite] Add parser support for relu6, leaky_relu, relu_n1_to_1, log_softmax URL: https://github.com/apache/incubator-tvm/pull/4805#discussion_r374723352
########## 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) + + return out + + def convert_leaky_relu(self, op): + """Convert TFLite LEAKY_RELU""" Review comment: Not important, I think it should be `"""Convert TFLite Leaky_ReLU"""` to align with `"""One iteration of Leaky_ReLU"""`. ---------------------------------------------------------------- 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 With regards, Apache Git Services