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/11/05 07:07:47 UTC

[GitHub] [tvm] leiwen83 commented on a diff in pull request #13294: Enhancement for simplify_expr

leiwen83 commented on code in PR #13294:
URL: https://github.com/apache/tvm/pull/13294#discussion_r1014595606


##########
src/relay/transforms/simplify_expr.cc:
##########
@@ -878,6 +932,33 @@ class SimplifyAdd : public DFPatternRewrite {
   DFPattern y_;
 };
 
+/*! \brief Simplifying x/c to x*(1/c) */
+class SimplifyDivide : public DFPatternRewrite {
+ public:
+  SimplifyDivide() {
+    x_ = IsWildcard();
+    c_ = IsConstant();
+    pattern_ = IsOp("divide")({x_, c_});
+  }
+
+  Expr Callback(const Expr& pre, const Expr& post,
+                const Map<DFPattern, Array<Expr>>& node_map) const override {
+    Type pre_type = pre->checked_type_;
+    auto dtype = pre_type.as<TensorTypeNode>()->dtype;
+    auto x = node_map[x_][0];
+    auto c = node_map[c_][0];
+
+    Expr one;
+    one = MakeConstantScalar(dtype, 1);

Review Comment:
   fixed



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