yongfeng-nv commented on a change in pull request #5367:
URL: https://github.com/apache/incubator-tvm/pull/5367#discussion_r411785613



##########
File path: src/arith/int_set.cc
##########
@@ -372,7 +387,27 @@ class IntervalSetEvaluator :
   }
 
   IntervalSet Eval(const PrimExpr& val) {
-    return this->VisitExpr(val);
+    IntervalSet result = this->VisitExpr(val);
+    // Use the IterVar range info bound to analyzer to further simplify
+    // and reduce the interval
+    auto min_value_expr = analyzer_->Simplify(result->min_value);
+    auto max_value_expr = analyzer_->Simplify(result->max_value);
+    auto min_bd = analyzer_->const_int_bound(min_value_expr);
+    auto max_bd = analyzer_->const_int_bound(max_value_expr);
+    if (min_bd->max_value == min_bd->min_value && max_bd->max_value == 
max_bd->min_value) {
+      const auto* min_ptr = result->min_value.as<IntImmNode>();
+      const auto* max_ptr = result->max_value.as<IntImmNode>();
+      // The following if statement is necessary.  When result is a single 
point of IntImm, such as
+      // [0, 0], both 0s refer the same ObjectRef.  We really don't want to 
create a new [0, 0]
+      // IntervalSet and have 0s refer two different ObjectRef.  They will 
confuse APIs, such as
+      // IntervalSetEvaluator::MatchPoint() and 
IntervalSetNode::IsSinglePoint().
+      if (min_ptr && max_ptr && min_bd->min_value == min_ptr->value &&

Review comment:
       I tried to fix MatchPoint first, then I found out 
IntervalSetNode::IsSinglePoint() requiring update too and worried about more 
APIs to touch.  Now I am moving the IntImm single point handling to IntervalSet 
constructor.  At certain point, I think immediate values are better to refactor 
to singleton.
   




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