inadob commented on a change in pull request #4978: [TFLITE]Activation functions support URL: https://github.com/apache/incubator-tvm/pull/4978#discussion_r387106930
########## File path: python/tvm/relay/frontend/tflite.py ########## @@ -454,6 +456,42 @@ def convert_l2_normalization(self, op): return out + def convert_lrn(self, op): + """Convert TFLite LOCAL_RESPONSE_NORMALIZATION """ + try: + from tflite.Operator import Operator + from tflite.BuiltinOptions import BuiltinOptions + from tflite.LocalResponseNormalizationOptions import LocalResponseNormalizationOptions + except ImportError: + raise ImportError("The tflite package must be installed") + + assert isinstance(op, Operator) + if self.is_quantized(op): + raise tvm.error.OpNotImplemented( + 'TFlite quantized LRN operator is not supported yet.') + + 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" + + assert op.BuiltinOptionsType() == BuiltinOptions.LocalResponseNormalizationOptions + op_options = op.BuiltinOptions() + lrn_options = LocalResponseNormalizationOptions() + lrn_options.Init(op_options.Bytes, op_options.Pos) + radius = lrn_options.Radius() + bias = lrn_options.Bias() + alpha = lrn_options.Alpha() + beta = lrn_options.Beta() + size = (radius * 2) + 1 + alpha = alpha * size + axis = 3 # NHWC format + out = _op.nn.lrn(in_expr, size=size, axis=axis, bias=bias, alpha=alpha, beta=beta) + return out Review comment: I think it would be better to add an empty line before the **return**. The same applies to the rest of the functions. ---------------------------------------------------------------- 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