Commit 770b904b by Salem Derisavi Committed by Tianqi Chen

Simplify expressions early on (#702)

* Simplify expressions early on

* fixed lint errors
parent 33910970
...@@ -27,7 +27,7 @@ inline IntSet IntSet::cover_interval() const { ...@@ -27,7 +27,7 @@ inline IntSet IntSet::cover_interval() const {
for (size_t i = 0; i < s->extents.size(); ++i) { for (size_t i = 0; i < s->extents.size(); ++i) {
max = max + s->extents[i] * s->strides[i] - s->strides[i]; max = max + s->extents[i] * s->strides[i] - s->strides[i];
} }
return IntervalSet::make(s->base.min, max); return IntervalSet::make(s->base.min, Simplify(max));
} }
LOG(FATAL) << "cannot convert set " << (*this)->type_key() << " to interval"; LOG(FATAL) << "cannot convert set " << (*this)->type_key() << " to interval";
return IntSet::everything(); return IntSet::everything();
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <tvm/ir_visitor.h> #include <tvm/ir_visitor.h>
#include <tvm/schedule_pass.h> #include <tvm/schedule_pass.h>
#include <tvm/operation.h> #include <tvm/operation.h>
#include <tvm/ir_pass.h>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include "./graph.h" #include "./graph.h"
...@@ -209,6 +210,10 @@ Map<IterVar, Range> InferBound(const Schedule& sch) { ...@@ -209,6 +210,10 @@ Map<IterVar, Range> InferBound(const Schedule& sch) {
ret[iv] = iv->dom; ret[iv] = iv->dom;
} }
} }
for (auto& p : ret) {
ret[p.first] = Range::make_by_min_extent(ir::Simplify(p.second->min),
ir::Simplify(p.second->extent));
}
return Map<IterVar, Range>(ret.begin(), ret.end()); return Map<IterVar, Range>(ret.begin(), ret.end());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment