wpan11nv commented on a change in pull request #5193: [TE] Support mixing
normal and cross-thread reduction
URL: https://github.com/apache/incubator-tvm/pull/5193#discussion_r401263693
##########
File path: src/te/operation/cross_thread_reduction.cc
##########
@@ -57,10 +57,63 @@ Stmt MakeCrossThreadReduction(
for (PrimExpr v : conds) {
cond = cond && v;
}
+
+ std::vector<std::vector<Stmt> > common, normal_red;
+ for (size_t i = 0, n = stage->leaf_iter_vars.size(); i < n; ++i) {
+ IterVar iv = stage->leaf_iter_vars[i];
+ IterVarAttr attr;
+ auto it = stage->iter_var_attrs.find(iv);
+ if (it != stage->iter_var_attrs.end()) {
+ attr = (*it).second;
+ }
+ if (iv->iter_type == kCommReduce) {
+ if (attr.defined() && attr->bind_thread.defined()) {
+ common.emplace_back(nest[i + 1]);
+ } else {
+ normal_red.emplace_back(nest[i + 1]);
+ }
+ } else {
+ common.emplace_back(nest[i + 1]);
+ }
+ }
+
+ // If we load from and then store into the same res_handles in the
thread_allreduce intrinsic,
+ // somethings goes wrong, so we use an extra variable here for normal
reduction.
Review comment:
%/res_handles/res_handle
%s/somethings/something/
----------------------------------------------------------------
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]
With regards,
Apache Git Services