diff --git a/src/common/depCore.h b/src/common/depCore.h index 3d7948cc835e9c4f1ac4670c6bd600028f2f48c1..ae8d411028065132a5cc0f544a0362a01bb52f9f 100644 --- a/src/common/depCore.h +++ b/src/common/depCore.h @@ -28,32 +28,29 @@ class depCore { const std::vector>>& ops) { std::unordered_map vars; size_t nop = ops.size(); - for (size_t i = 0; i < nop; i++) { - const auto& op = ops[i]; - for (const auto& kv : op->Outputs()) { - for (const auto& v : kv.second) { - vars[v] = i; - } - } - } deps.resize(nop); next.resize(nop); for (size_t i = 0; i < nop; i++) { const auto& op = ops[i]; for (const auto& kv : op->Inputs()) { - for (const auto& v : kv.second) { - if (vars.find(v) == vars.end()) { - continue; - } - int di = vars[v]; - if (di == i) { - continue; + for (const auto& v : kv.second) { + if (vars.find(v) == vars.end()) { + continue; + } + int di = vars[v]; + if (di == i) { + continue; + } + if (std::find(deps[i].begin(), deps[i].end(), di) != deps[i].end()) { + continue; + } + deps[i].push_back(di); + next[di].push_back(i); } - if (std::find(deps[i].begin(), deps[i].end(), di) != deps[i].end()) { - continue; - } - deps[i].push_back(di); - next[di].push_back(i); + } + for (const auto& kv : op->Outputs()) { + for (const auto& v : kv.second) { + vars[v] = i; } } }