Skip to content

Commit

Permalink
Fix segfault by nonconstant bound in Adams2019 (#7321)
Browse files Browse the repository at this point in the history
Fix segmentation fault in Adams2019 in case the estimate or
bound of Func is set to nonconstant Expr.
  • Loading branch information
stevesuzuki-arm authored Feb 6, 2023
1 parent 01f9e2d commit 91f3ac0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/autoschedulers/adams2019/FunctionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,11 @@ FunctionDAG::FunctionDAG(const vector<Function> &outputs, const Target &target)
// Get the bounds estimate
map<string, Span> estimates;
for (const auto &b : consumer.schedule().estimates()) {
int64_t i_min = *as_const_int(b.min);
int64_t i_extent = *as_const_int(b.extent);
const int64_t *i_min = as_const_int(b.min);
const int64_t *i_extent = as_const_int(b.extent);
user_assert(i_min && i_extent)
<< "Min/extent of estimate or bound is not constant in \"" << consumer.name()
<< "\", var:" << b.var << ", min:" << b.min << ", extent:" << b.extent;

if ((false)) { // Intentional dead code. Extra parens to pacify clang-tidy.
// Some methods we compare to compile for
Expand All @@ -891,9 +894,9 @@ FunctionDAG::FunctionDAG(const vector<Function> &outputs, const Target &target)
// like unroll across color channels, so
// it affects the scheduling space.
Func(node.func).bound(b.var, b.min, b.extent);
estimates[b.var] = Span(i_min, i_min + i_extent - 1, true);
estimates[b.var] = Span(*i_min, *i_min + *i_extent - 1, true);
} else {
estimates[b.var] = Span(i_min, i_min + i_extent - 1, false);
estimates[b.var] = Span(*i_min, *i_min + *i_extent - 1, false);
}
}
for (const auto &b : consumer.schedule().bounds()) {
Expand Down

0 comments on commit 91f3ac0

Please sign in to comment.