apeskov commented on code in PR #13332:
URL: https://github.com/apache/tvm/pull/13332#discussion_r1019315558


##########
python/tvm/relay/transform/fake_quantization_to_integer.py:
##########
@@ -158,7 +159,10 @@ def avgpool2d(expr, type_map):
     else:
         arg = relay.op.cast(arg, "int32")
     out = relay.op.nn.avg_pool2d(arg, **expr.attrs)
-    return [out, TensorAffineType(out_t.scale, out_t.zero_point, "int32", 
out_t.axis)]
+    # Cast back to input dtype to preserve input dtype == output dtype.
+    out = relay.op.clip(out, a_min=np.iinfo(t.dtype).min, 
a_max=np.iinfo(t.dtype).max)
+    out = relay.op.cast(out, t.dtype)

Review Comment:
   Why do you need to preserve `input dtype == output dtype`? As I understood 
it should match `out_t.dtype`.
   
   I guess it should be conditional injection of cast op to `out_t.dtype` if it 
is not a `int32`.



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

Reply via email to