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/07/28 22:17:17 UTC

[GitHub] [tvm] AndrewZhaoLuo commented on a diff in pull request #12224: [FQ2I] fix unary op output affine type in fq2i

AndrewZhaoLuo commented on code in PR #12224:
URL: https://github.com/apache/tvm/pull/12224#discussion_r932720536


##########
tests/python/relay/test_pass_fake_quantization_to_integer.py:
##########
@@ -318,17 +318,26 @@ def test_fake_quantize_global_avg_pool():
 
 
 class TestUnaryQNNOp:
-    def helper_test_fake_quantize_unary_op(self, fp32_op, scale=0.125):
-        x = relay.var("x", shape=[1, 3, 3, 3], dtype="int8")
-        mid_point = relay.const(-128)
+    def helper_test_fake_quantize_unary_op(self, fp32_op):
+        for dtype in ["int8", "uint8"]:
+            x = relay.var("x", shape=[1, 3, 3, 3], dtype=dtype)
 
-        x = relay.qnn.op.dequantize(x, relay.const(scale), mid_point)
-        op = fp32_op(x)
-        op = relay.qnn.op.quantize(op, relay.const(scale), mid_point)
+            zero = -128 if dtype == "int8" else 0
 
-        x_np = np.random.randint(-128, 127, size=[1, 3, 3, 3], dtype="int8")
+            mid_point = relay.const(np.random.randint(0, 255) + zero)

Review Comment:
   Can you rename these input_mid_point, input_scale, outptu_scale, etc. for readability?



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