jwfromm commented on a change in pull request #8241:
URL: https://github.com/apache/tvm/pull/8241#discussion_r674992637



##########
File path: python/tvm/relay/transform/fake_quantization_to_integer.py
##########
@@ -163,4 +196,128 @@ def clip(expr, type_map):
         amin = relay.op.round(relay.op.const(amin) / scale + z_p)
         amax = relay.op.round(relay.op.const(amax) / scale + z_p)
         out = relay.op.minimum(relay.op.maximum(arg, amin), amax)
-    return [out, t.scale, t.zero_point, t.dtype]
+    return [out, t]
+
+
+@register_fake_quantization_to_integer("nn.pad")
+def pad(expr, type_map):
+    """Rewite an nn.pad op"""
+    arg = expr.args[0]
+    t = type_map[arg]
+    pad_value = expr.args[1]
+    if pad_value in type_map:
+        pad_t = type_map[pad_value]
+        if not tvm.ir.structural_equal(t, pad_t):

Review comment:
       a comment explaining the logic here would be helpful.

##########
File path: src/relay/transforms/fake_quantization_to_integer.cc
##########
@@ -148,7 +93,8 @@ class SubgraphExtractor : public ExprVisitor {
   const AffineTypeMap GetAffineTypes() { return affine_types_; }
   void VisitExpr(const Expr& expr) override {
     if (expr.as<CallNode>() == nullptr && expr.as<OpNode>() == nullptr &&

Review comment:
       can you add a comment explaining this check and why it implies 
`fake_quantization = false`? It's a little confusing to me.

##########
File path: src/relay/transforms/fake_quantization_to_integer.cc
##########
@@ -226,18 +173,37 @@ class SubgraphMutator : public ExprMutator {
       // Call the rewrite
       Array<ObjectRef> vals = fqfq[op](expr, affine_types_);
       // Save teh outputs of the rewrite

Review comment:
       might as well fix this typo while adding comments.




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