Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit e15aaef

Browse files
author
Sven Verdoolaege
committed
halide2isl: findReductions: support multiple reductions on the same tensor
The tensor name was being used as a key in a map that was used to match init and update nodes and to store the results. Since 33a3bb6 (halide2isl: do not require init statement for reduction detection, Sun May 27 12:04:46 2018 +0200), these init statements are no longer considered, so the map is no longer needed. Collect the reductions directly in a vector instead. Closes #455
1 parent 9fb6a37 commit e15aaef

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

tc/core/halide2isl.cc

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,10 @@ std::vector<Reduction> findReductions(const Stmt& s) {
529529
}
530530
}
531531
if (dims.size() > 0) {
532-
auto& p = reductions[op->name];
533-
CHECK(!p.update.defined())
534-
<< "Multiple reduction updates not yet implemented";
532+
Reduction p;
535533
p.update = op;
536534
p.dims = dims;
535+
reductions.emplace_back(p);
537536
}
538537
}
539538
}
@@ -543,15 +542,11 @@ std::vector<Reduction> findReductions(const Stmt& s) {
543542
std::unordered_set<std::string> reductionVars;
544543
// The names of the outer For nodes, outermost to innermost.
545544
std::vector<std::string> vars;
546-
std::map<std::string, Reduction> reductions;
545+
std::vector<Reduction> reductions;
547546
} finder;
548547
s.accept(&finder);
549548

550-
std::vector<Reduction> result;
551-
for (auto p : finder.reductions) {
552-
result.push_back(p.second);
553-
}
554-
return result;
549+
return finder.reductions;
555550
}
556551

557552
} // namespace halide2isl

0 commit comments

Comments
 (0)