Aharrypotter commented on code in PR #19813:
URL: https://github.com/apache/tvm/pull/19813#discussion_r3427175295


##########
python/tvm/relax/frontend/tflite/tflite_frontend.py:
##########
@@ -1521,6 +1534,18 @@ def get_scalar_value(tensor):
 
         return out
 
+    def convert_rank(self, op):
+        """Convert TFLite RANK."""
+        input_tensors = self.get_input_tensors(op)
+        assert len(input_tensors) == 1, "input tensors length should be 1"
+
+        output_tensors = self.get_output_tensors(op)
+        assert len(output_tensors) == 1, "output tensors length should be 1"
+        output_dtype = 
self.get_tensor_type_str(output_tensors[0].tensor.Type())
+
+        rank = len(self.get_tensor_shape(input_tensors[0]))
+        return relax.const(np.array(rank, dtype=output_dtype), 
dtype=output_dtype)

Review Comment:
   Addressed in 864935f1 by returning `relax.const(rank, dtype=output_dtype)`.



##########
python/tvm/relax/frontend/tflite/tflite_frontend.py:
##########
@@ -1564,6 +1612,26 @@ def convert_relu(self, op):
 
         return out
 
+    def convert_relu_0_to_1(self, op):
+        """Convert TFLite RELU_0_TO_1."""
+        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_f32 = self.dequantize(in_expr, input_tensor)
+            out = relax.op.clip(in_f32, min=0, max=1)
+            out = self.quantize(out, output_tensor)
+        else:
+            out = relax.op.clip(in_expr, min=0, max=1)

Review Comment:
   Addressed in 864935f1 by switching the new `relax.op.clip` calls to 
positional arguments.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to