tqchen commented on a change in pull request #8114:
URL: https://github.com/apache/tvm/pull/8114#discussion_r637928440
##########
File path: src/arith/int_set.cc
##########
@@ -635,6 +636,83 @@ IntSet Union(const Array<IntSet>& sets) {
return IntervalSet(ana.Simplify(x->min_value), ana.Simplify(x->max_value));
}
+Array<IntSet> UnionRegion(const Array<Array<IntSet>>& nd_int_sets) {
+ if (nd_int_sets.empty()) {
+ return {};
+ }
+ int n = nd_int_sets.size();
+ int ndim = nd_int_sets[0].size();
+ Array<IntSet> result;
+ result.reserve(ndim);
+ for (int i = 0; i < ndim; ++i) {
+ Array<IntSet> candidates;
+ candidates.reserve(n);
+ for (int j = 0; j < n; ++j) {
+ candidates.push_back(nd_int_sets[j][i]);
+ }
+ result.push_back(Union(candidates));
+ }
+ return result;
+}
+
+IntSet UnionLowerBound(const Array<IntSet>& sets) {
+ if (sets.size() == 0) return IntSet::Nothing();
+ if (sets.size() == 1) return sets[0];
+ Analyzer analyzer;
+ bool is_first_interval = true;
+ PrimExpr min_inclusive{nullptr};
+ PrimExpr max_exclusive(nullptr);
+ for (const IntSet& int_set : sets) {
+ if (const auto* interval_set = int_set.as<IntervalSetNode>()) {
+ PrimExpr new_min_inclusive = interval_set->min_value;
+ PrimExpr new_max_exclusive = interval_set->max_value;
+ if (!is_pos_inf(new_max_exclusive) && !is_neg_inf(new_max_exclusive)) {
+ new_max_exclusive = new_max_exclusive + 1;
+ }
+ if (is_first_interval) {
+ is_first_interval = false;
+ min_inclusive = std::move(new_min_inclusive);
+ max_exclusive = std::move(new_max_exclusive);
+ continue;
+ }
+ bool bound_1 = is_neg_inf(new_min_inclusive) ||
is_pos_inf(max_exclusive) ||
+ analyzer.CanProve(new_min_inclusive <= max_exclusive);
+ bool bound_2 = is_neg_inf(min_inclusive) ||
is_pos_inf(new_max_exclusive) ||
+ analyzer.CanProve(min_inclusive <= new_max_exclusive);
+ if (bound_1 && bound_2) {
+ min_inclusive = min(min_inclusive, new_min_inclusive);
Review comment:
Consider handle the inf case separately, because min/max may not deal
with a case where one of them is inf
--
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]