From 755edefea9551f0bd6ff887c75ca0695579fddbd Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Tue, 21 Feb 2017 03:53:07 +0000 Subject: [PATCH 1/3] [FIX] add CombineInterval
--- src/arithmetic/int_set.cc | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/arithmetic/int_set.cc b/src/arithmetic/int_set.cc index 8fdba6650f25..a9e5ef2d8d18 100644 --- a/src/arithmetic/int_set.cc +++ b/src/arithmetic/int_set.cc @@ -251,6 +251,32 @@ inline IntSet CombineInterval(Interval a, Interval b) { return IntSet::everything(); } +template<> +inline IntSet CombineInterval
(Interval a, Interval b) { + if (a.is_single_point() && b.is_single_point()) { + return IntSet::single_point(ComputeExpr
(a.min, b.min)); + } + if (b.is_single_point()) { + if (is_zero(b.min)) { + LOG(WARNING) << "Return Everything in CombineInterval Div"; + return IntSet::everything(); + } + if (is_one(b.min)) return IntervalSet::make(a); + Expr e1 = a.has_lower_bound() ? ComputeExpr
(a.min, b.min) : a.min; + Expr e2 = a.has_upper_bound() ? ComputeExpr
(a.max, b.min) : a.min; + if (is_positive_const(b.min)) { + return IntervalSet::make(e1, e2); + } else if (is_negative_const(b.min)) { + return IntervalSet::make(e2, e1); + } else if (a.is_bounded()) { + Expr cmp = b.min >= make_zero(b.min.type().element_of()); + return IntervalSet::make(select(cmp, e1, e2), select(cmp, e2, e1)); + } + } + LOG(WARNING) << "Return Everything in CombineInterval Div"; + return IntSet::everything(); +} + template<> inline IntSet CombineInterval(Interval a, Interval b) { if (a.is_single_point() && b.is_single_point()) { From 566c6f97a126cee1246570ec149f2dde33912134 Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Tue, 21 Feb 2017 18:10:31 +0000 Subject: [PATCH 2/3] fix error message and add comment about rounding --- src/arithmetic/int_set.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arithmetic/int_set.cc b/src/arithmetic/int_set.cc index a9e5ef2d8d18..fb96d3ec09f6 100644 --- a/src/arithmetic/int_set.cc +++ b/src/arithmetic/int_set.cc @@ -258,12 +258,12 @@ inline IntSet CombineInterval
(Interval a, Interval b) { } if (b.is_single_point()) { if (is_zero(b.min)) { - LOG(WARNING) << "Return Everything in CombineInterval Div"; - return IntSet::everything(); + LOG(FATAL) << "Divide by zero in CombineInterval Div"; } if (is_one(b.min)) return IntervalSet::make(a); Expr e1 = a.has_lower_bound() ? ComputeExpr
(a.min, b.min) : a.min; - Expr e2 = a.has_upper_bound() ? ComputeExpr
(a.max, b.min) : a.min; + Expr e2 = a.has_upper_bound() ? ComputeExpr
(a.max, b.min) : a.max; + // This is relaxiation due to set is inclusive if (is_positive_const(b.min)) { return IntervalSet::make(e1, e2); } else if (is_negative_const(b.min)) { From c17c0ab2660a9b8c41592fb10421a52d633b0da1 Mon Sep 17 00:00:00 2001 From: ZihengJiang Date: Tue, 21 Feb 2017 18:37:00 +0000 Subject: [PATCH 3/3] fix comment --- src/arithmetic/int_set.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/arithmetic/int_set.cc b/src/arithmetic/int_set.cc index fb96d3ec09f6..db6c75642f3b 100644 --- a/src/arithmetic/int_set.cc +++ b/src/arithmetic/int_set.cc @@ -236,7 +236,7 @@ inline IntSet CombineInterval(Interval a, Interval b) { if (is_one(b.min)) return IntervalSet::make(a); Expr e1 = a.has_lower_bound() ? ComputeExpr(a.min, b.min) : a.min; Expr e2 = a.has_upper_bound() ? ComputeExpr(a.max, b.min) : a.max; - // This is relaxiation + // no relaxation is needed in here due to set is inclusive // TODO(tqchen): consider convert to StrideSet. if (is_positive_const(b.min)) { return IntervalSet::make(e1, e2); @@ -263,7 +263,7 @@ inline IntSet CombineInterval
(Interval a, Interval b) { if (is_one(b.min)) return IntervalSet::make(a); Expr e1 = a.has_lower_bound() ? ComputeExpr
(a.min, b.min) : a.min; Expr e2 = a.has_upper_bound() ? ComputeExpr
(a.max, b.min) : a.max; - // This is relaxiation due to set is inclusive + // no relaxation is needed in here due to set is inclusive if (is_positive_const(b.min)) { return IntervalSet::make(e1, e2); } else if (is_negative_const(b.min)) {