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/04/06 21:54:36 UTC

[GitHub] [tvm] CircleSpin opened a new pull request, #10924: [FQ2I] Add log op to FQ2I

CircleSpin opened a new pull request, #10924:
URL: https://github.com/apache/tvm/pull/10924

   Registered the log unary elementwise op
   
   @mbrookhart @AndrewZhaoLuo @anwang2009 
   


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


[GitHub] [tvm] AndrewZhaoLuo merged pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo merged PR #10924:
URL: https://github.com/apache/tvm/pull/10924


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


[GitHub] [tvm] sfvaroglu commented on a diff in pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
sfvaroglu commented on code in PR #10924:
URL: https://github.com/apache/tvm/pull/10924#discussion_r845348241


##########
python/tvm/relay/qnn/op/qnn.py:
##########
@@ -998,6 +998,41 @@ def sigmoid(x, scale, zero_point, output_scale, output_zero_point):
     )
 
 
+def log(x, scale, zero_point, output_scale, output_zero_point):
+    """Quantized sigmoid.

Review Comment:
   sigmoid -> log



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


[GitHub] [tvm] AndrewZhaoLuo commented on a diff in pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
AndrewZhaoLuo commented on code in PR #10924:
URL: https://github.com/apache/tvm/pull/10924#discussion_r855398918


##########
python/tvm/relay/qnn/op/legalizations.py:
##########
@@ -72,6 +72,7 @@ def legalize_qnn_unary_op(attrs, inputs, types):
 register_qnn_unary_op_legalize("qnn.erf", special.erf)
 register_qnn_unary_op_legalize("qnn.sigmoid", lambda arr: 1 / (1 + np.exp(-arr)))
 register_qnn_unary_op_legalize("qnn.tanh", np.tanh)
+register_qnn_unary_op_legalize("qnn.log", np.log)

Review Comment:
   oh yeah im dumb



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


[GitHub] [tvm] anwang2009 commented on a diff in pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
anwang2009 commented on code in PR #10924:
URL: https://github.com/apache/tvm/pull/10924#discussion_r844454872


##########
tests/python/relay/test_pass_fake_quantization_to_integer.py:
##########
@@ -374,6 +377,19 @@ def test_fake_quantize_image_resize_bilinear():
     compare_fq_to_int(op, [x_np], allow_rounding_error=True)
 
 
+def test_fake_quantize_image_resize_bilinear():
+    x = relay.var("x", shape=[1, 3, 224, 224], dtype="int8")
+
+    zero = relay.const(0)
+    x = relay.qnn.op.dequantize(x, relay.const(2.0), zero)
+    op = relay.image.resize2d(x, size=[4, 4], method="linear")
+    op = relay.qnn.op.quantize(op, relay.const(2.0), zero)
+
+    x_np = np.random.randint(-128, 127, size=[1, 3, 224, 224], dtype="int8")
+
+    compare_fq_to_int(op, [x_np], allow_rounding_error=True)

Review Comment:
   looks like this block shouldn't have been committed, remove?



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


[GitHub] [tvm] CircleSpin commented on a diff in pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
CircleSpin commented on code in PR #10924:
URL: https://github.com/apache/tvm/pull/10924#discussion_r846492716


##########
tests/python/relay/test_pass_fake_quantization_to_integer.py:
##########
@@ -374,6 +377,19 @@ def test_fake_quantize_image_resize_bilinear():
     compare_fq_to_int(op, [x_np], allow_rounding_error=True)
 
 
+def test_fake_quantize_image_resize_bilinear():
+    x = relay.var("x", shape=[1, 3, 224, 224], dtype="int8")
+
+    zero = relay.const(0)
+    x = relay.qnn.op.dequantize(x, relay.const(2.0), zero)
+    op = relay.image.resize2d(x, size=[4, 4], method="linear")
+    op = relay.qnn.op.quantize(op, relay.const(2.0), zero)
+
+    x_np = np.random.randint(-128, 127, size=[1, 3, 224, 224], dtype="int8")
+
+    compare_fq_to_int(op, [x_np], allow_rounding_error=True)

Review Comment:
   Thank you! :)



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


[GitHub] [tvm] CircleSpin commented on a diff in pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
CircleSpin commented on code in PR #10924:
URL: https://github.com/apache/tvm/pull/10924#discussion_r846492605


##########
python/tvm/relay/qnn/op/qnn.py:
##########
@@ -998,6 +998,41 @@ def sigmoid(x, scale, zero_point, output_scale, output_zero_point):
     )
 
 
+def log(x, scale, zero_point, output_scale, output_zero_point):
+    """Quantized sigmoid.

Review Comment:
   Thank you for catching that! :smiley: 
   



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


[GitHub] [tvm] mbrookhart commented on a diff in pull request #10924: [FQ2I] Add log op to FQ2I

Posted by GitBox <gi...@apache.org>.
mbrookhart commented on code in PR #10924:
URL: https://github.com/apache/tvm/pull/10924#discussion_r855370291


##########
python/tvm/relay/qnn/op/legalizations.py:
##########
@@ -72,6 +72,7 @@ def legalize_qnn_unary_op(attrs, inputs, types):
 register_qnn_unary_op_legalize("qnn.erf", special.erf)
 register_qnn_unary_op_legalize("qnn.sigmoid", lambda arr: 1 / (1 + np.exp(-arr)))
 register_qnn_unary_op_legalize("qnn.tanh", np.tanh)
+register_qnn_unary_op_legalize("qnn.log", np.log)

Review Comment:
   @AndrewZhaoLuo Doesn't this already do the lookup table? 



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