From b84df55a4de50507cc737cc02740f91dae1ac2ed Mon Sep 17 00:00:00 2001 From: Yanzhan Yang Date: Wed, 17 Jul 2019 13:22:36 +0800 Subject: [PATCH] fix fetch var memory optimization bug (#1746) --- src/pass/memory_optimize.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pass/memory_optimize.cpp b/src/pass/memory_optimize.cpp index dc14bac15b..d9cfa13899 100644 --- a/src/pass/memory_optimize.cpp +++ b/src/pass/memory_optimize.cpp @@ -118,10 +118,6 @@ void MemoryOptPass::operator()( } } - for (const auto &node : fetch_var_nodes) { - analysis_nodes_.push(node); - } - // apply optimize while (!analysis_nodes_.empty()) { auto *node = analysis_nodes_.top(); @@ -132,7 +128,9 @@ void MemoryOptPass::operator()( bool reused = false; // find out a possable reuse list for (auto &list : reused_nodes_) { - if (list.back()->count == 0) { + if (list.back()->count == 0 && + std::find(fetch_var_nodes.begin(), fetch_var_nodes.end(), + list.back()) == fetch_var_nodes.end()) { list.push_back(node); reused = true; break; -- GitLab