From 49ef0775a40103538076dab13ea4f594d2cee6aa Mon Sep 17 00:00:00 2001 From: dolphin8 Date: Thu, 21 Jun 2018 20:04:13 +0800 Subject: [PATCH] fix dep analysis --- src/common/depCore.h | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/common/depCore.h b/src/common/depCore.h index 3d7948cc83..ae8d411028 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; } } } -- GitLab