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


##########
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:
   Minor: var declare and initialize at the same time.



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