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/08/24 19:47:06 UTC

[GitHub] [tvm] mbrookhart opened a new pull request, #12580: [SimplifyExpr] Add simplify for dq->arg funcs

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

   cc @csullivan @AndrewZhaoLuo 


-- 
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 #12580: [SimplifyExpr] Add simplify for dq->arg funcs

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


-- 
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 #12580: [SimplifyExpr] Add simplify for dq->arg funcs

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


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -708,6 +708,50 @@ class SimplifyRSqrt : public DFPatternRewrite {
   DFPattern numerator_;
 };
 
+class SimplifyDQArgFunc : public DFPatternRewrite {
+  /*! Base class for simplifying dequantize followed by arg ops */
+ public:
+  explicit SimplifyDQArgFunc(std::string op) : op_(op) {
+    x_ = IsWildcard();
+    dq_ = IsOp("qnn.dequantize")({x_, IsWildcard(), IsWildcard()});
+    pattern_ = IsOp(op_)({dq_});
+  }
+
+  Expr Callback(const Expr& pre, const Expr& post,
+                const Map<DFPattern, Array<Expr>>& node_map) const override {
+    const CallNode* call = pre.as<CallNode>();
+    ICHECK(call);
+    auto x = node_map[x_][0];
+    return Call(Op::Get(op_), {x}, call->attrs);
+  }
+
+ protected:
+  /*! \brief Pattern input */
+  DFPattern x_;
+  /*! \brief dequantize op */
+  DFPattern dq_;
+  /*! \brief Name of op to simplify */
+  String op_;
+};
+
+class SimplifyDQArgMax : public SimplifyDQArgFunc {
+  /*! Simplify dequantize follwed by argmax */

Review Comment:
   doh!



-- 
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 #12580: [SimplifyExpr] Add simplify for dq->arg funcs

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


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -708,6 +708,50 @@ class SimplifyRSqrt : public DFPatternRewrite {
   DFPattern numerator_;
 };
 
+class SimplifyDQArgFunc : public DFPatternRewrite {
+  /*! Base class for simplifying dequantize followed by arg ops */
+ public:
+  explicit SimplifyDQArgFunc(std::string op) : op_(op) {
+    x_ = IsWildcard();
+    dq_ = IsOp("qnn.dequantize")({x_, IsWildcard(), IsWildcard()});
+    pattern_ = IsOp(op_)({dq_});
+  }
+
+  Expr Callback(const Expr& pre, const Expr& post,
+                const Map<DFPattern, Array<Expr>>& node_map) const override {
+    const CallNode* call = pre.as<CallNode>();
+    ICHECK(call);
+    auto x = node_map[x_][0];
+    return Call(Op::Get(op_), {x}, call->attrs);
+  }
+
+ protected:
+  /*! \brief Pattern input */
+  DFPattern x_;
+  /*! \brief dequantize op */
+  DFPattern dq_;
+  /*! \brief Name of op to simplify */
+  String op_;
+};
+
+class SimplifyDQArgMax : public SimplifyDQArgFunc {
+  /*! Simplify dequantize follwed by argmax */

Review Comment:
   Probably want to follow format used in rest of file:
   
   ```
   
   /*! \brief Make two consecutive add able to be constant_folded.
    * This pattern matching supports commutative property for addition.
    */
   class SimplifyConsecutiveAdd : public DFPatternRewrite {
   ```



-- 
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 #12580: [SimplifyExpr] Add simplify for dq->arg funcs

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


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -708,6 +708,44 @@ class SimplifyRSqrt : public DFPatternRewrite {
   DFPattern numerator_;
 };
 
+class SimplifyDQArgFunc : public DFPatternRewrite {

Review Comment:
   Nit, add a comment



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