hypercubestart commented on a change in pull request #5881:
URL: https://github.com/apache/incubator-tvm/pull/5881#discussion_r475802507



##########
File path: src/relay/transforms/type_infer.cc
##########
@@ -109,6 +134,44 @@ class TypeInferencer : private ExprFunctor<Type(const 
Expr&)>,
   // inference the type of expr.
   Expr Infer(Expr expr);
 
+  void SetCurrentFunc(GlobalVar current_func) {
+    this->current_func_ = current_func;
+    this->solver_.SetCurrentFunc(current_func);
+  }
+
+  void Solve();
+  Expr ResolveType(Expr expr);
+
+  // Lazily get type for expr
+  // expression, we will populate it now, and return the result.
+  Type GetType(const Expr& expr) {
+    auto it = type_map_.find(expr);
+    if (it != type_map_.end() && it->second.checked_type.defined()) {
+      if (expr.as<GlobalVarNode>() != nullptr) {
+        // if we don't dedup GlobalVarNode, two functions that use the same 
GlobalVar
+        // may resolve to the same type incorrectly
+        return DeDupType().VisitType(it->second.checked_type);

Review comment:
       if we DeDup a TypeVar, this will always be incorrect because there is no 
subst taking place.
   
   i.e.
   ```
   In `id`: 
     fn [A](%x: A) -> A {
     %x
   } unable to unify: `A` and `A`;
   ```
   %x is DeDup into a different typevar which is incorrect




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to