MarisaKirisame commented on a change in pull request #5618:
URL: https://github.com/apache/incubator-tvm/pull/5618#discussion_r440736456



##########
File path: include/tvm/arith/int_solver.h
##########
@@ -26,17 +26,99 @@
 
 #include <tvm/ir/expr.h>
 #include <tvm/tir/expr.h>
+#include <tvm/tir/op.h>
 
 #include <unordered_map>
+#include <utility>
 #include <vector>
 
+#include "analyzer.h"
+
 namespace tvm {
 namespace arith {
 
 using tir::IterVar;
 using tir::Var;
 using tir::VarNode;
 
+/*!
+ * \brief Represent integer grouped bounds which are classified into
+ *        lower bounds (include), upper bounds (include) and equalities.

Review comment:
       ```suggestion
    *        lower bounds (inclusive), upper bounds (inclusive) and equalities.
   ```

##########
File path: src/arith/int_constraints.cc
##########
@@ -21,18 +21,166 @@
  * \file int_constraints.cc
  * \brief The integer constraints data structures.
  */
+#include <tvm/arith/analyzer.h>
 #include <tvm/arith/int_solver.h>
 #include <tvm/runtime/registry.h>
 #include <tvm/tir/expr.h>
 #include <tvm/tir/expr_functor.h>
+#include <tvm/tir/op.h>
+#include <tvm/tir/stmt_functor.h>
 
 #include <algorithm>
 #include <unordered_map>
 #include <utility>
 
+#include "../tir/transforms/ir_util.h"
+
 namespace tvm {
 namespace arith {
 
+IntGrpBounds::IntGrpBounds(PrimExpr coef, Array<PrimExpr> lower, 
Array<PrimExpr> equal,
+                           Array<PrimExpr> upper) {
+  CHECK(coef.dtype().is_int() || coef.dtype().is_uint())
+      << "Coefficient in IntGrpBounds must be integers";
+  ObjectPtr<IntGrpBoundsNode> node = make_object<IntGrpBoundsNode>();
+  node->coef = std::move(coef);
+  node->lower = std::move(lower);
+  node->equal = std::move(equal);
+  node->upper = std::move(upper);
+  data_ = std::move(node);
+}
+
+IntGrpBounds IntGrpBounds::range(const Range& r) {
+  Analyzer analyzer;
+  PrimExpr coef = tir::make_const(r->min.dtype(), 1);
+  Array<PrimExpr> equal;
+  Array<PrimExpr> lower;
+  Array<PrimExpr> upper;
+  if (tir::is_one(r->extent)) {
+    equal.push_back(r->min);
+  } else {
+    lower.push_back(r->min);
+    upper.push_back(analyzer.Simplify(r->min + r->extent - 1));
+  }
+  return IntGrpBounds(coef, lower, equal, upper);
+}
+
+IntGrpBounds IntGrpBounds::operator+(const Range& r) {
+  Analyzer analyzer;
+  Array<PrimExpr> equal;
+  Array<PrimExpr> lower;
+  Array<PrimExpr> upper;
+  if (tir::is_one(r->extent)) {
+    equal.push_back(analyzer.Simplify(r->min * operator->()->coef));

Review comment:
       maybe getting a constref that result form operator->() is better code 
style. seeing operator->() flying around hurt my eyes imo.




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