You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Hzfengsy (via GitHub)" <gi...@apache.org> on 2023/03/24 13:36:49 UTC

[GitHub] [tvm] Hzfengsy commented on a diff in pull request #14396: [Unity] Support simple dynamic-shape-aware fusion

Hzfengsy commented on code in PR #14396:
URL: https://github.com/apache/tvm/pull/14396#discussion_r1147589997


##########
src/relax/transform/fuse_ops.cc:
##########
@@ -344,6 +345,42 @@ class GraphCreator : public ExprVisitor {
   std::unordered_set<IndexedForwardGraph::Node*> initialized_nodes_;
 };
 
+/*!
+ * \brief Renew the definition of symbolic vars in Relax.
+ * \details This mutator is used to prevent the same symbolic var from being used in different
+ *          functions, which is malformed.
+ */
+class SymbolicVarRenewMutator : public ExprMutator, tir::ExprMutator {
+ public:
+  static Function Renew(const Function& function) {
+    SymbolicVarRenewMutator mutator;
+    return Downcast<Function>(mutator.VisitExpr(function));
+  }
+
+ private:
+  SymbolicVarRenewMutator() = default;
+  using relax::ExprMutator::VisitExpr;
+  using relax::ExprMutator::VisitExpr_;
+  using tir::ExprMutator::VisitExpr_;
+
+  PrimExpr VisitPrimExpr(const PrimExpr& expr) final { return tir::ExprMutator::VisitExpr(expr); }
+
+  PrimExpr VisitExpr_(const tir::VarNode* op) final {

Review Comment:
   Thanks TQ, I agree that your approach is safer. However, in this particular case, I think both ways are the same. I would leave a TODO here for further updates.
   
   BTW, there is not an easy/formal way to visit symbolic var at def side, we may add a method to the base visitor/mutator later.



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