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 2022/12/29 13:01:11 UTC

[GitHub] [tvm] ekalda commented on a diff in pull request #13645: [microNPU] Add relu6 relu_n1_to_1 test cases for Ethos-U

ekalda commented on code in PR #13645:
URL: https://github.com/apache/tvm/pull/13645#discussion_r1058940323


##########
tests/python/contrib/test_ethosu/test_codegen.py:
##########
@@ -1109,6 +1109,45 @@ def leaky_relu_func(x):
     )
 
 
+def test_tflite_relu6():
+    np.random.seed(0)
+    accel_type = "ethos-u55-128"
+    ifm_shape = (1, 12, 16, 8)
+
+    @tf.function
+    def relu6(x):
+        return tf.nn.relu6(x)
+
+    infra.compare_tvm_with_tflite(
+        relu6,
+        [ifm_shape],
+        accel_type,
+        enable_cascader=is_u55_accel_type(accel_type),
+        ranges=[(-1, 1)],
+    )
+
+
+def test_tflite_relu_n1_to_1():
+    np.random.seed(0)
+    accel_type = "ethos-u55-128"
+    ifm_shape = (1, 12, 16, 8)
+
+    @tf.function
+    def relu_n1_to_1(x):
+        """
+        The specific pattern will be replaced into RELU_N1_TO_1 by tflite.
+        """
+        return tf.math.maximum(-1.0, tf.math.minimum(x, 1.0))

Review Comment:
   Out of interest, what Relay does this get lowered to? I always thought all the different kinds of RELUs were lowered to the same Relay clip with just different min and max and then this clip was pattern matched as a part of all the different op pattern matchers and added to the primitive op's `clip_min` and `clip_max`, but as we don't pattern match for standalone clip and this test here passes, I suppose it gets lowered to something different? 



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org