提交 6f7678f6 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!4929 fix bug for PynativeExecutor clear

Merge pull request !4929 from zhangbuxue/fix_bug_for_PynativeExecutor_clear
...@@ -1252,9 +1252,14 @@ void PynativeExecutor::GradNetInner(const GradOperationPtr &grad, const py::obje ...@@ -1252,9 +1252,14 @@ void PynativeExecutor::GradNetInner(const GradOperationPtr &grad, const py::obje
void PynativeExecutor::Clear(const std::string &flag) { void PynativeExecutor::Clear(const std::string &flag) {
if (!flag.empty()) { if (!flag.empty()) {
MS_LOG(DEBUG) << "Clear res"; MS_LOG(DEBUG) << "Clear res";
(void)graph_map_.erase(flag); auto key_value = std::find_if(graph_map_.begin(), graph_map_.end(),
(void)cell_graph_map_.erase(flag); [&flag](const auto &item) { return item.first.find(flag) != std::string::npos; });
(void)cell_resource_map_.erase(flag); if (key_value != graph_map_.end()) {
std::string key = key_value->first;
(void)graph_map_.erase(key);
(void)cell_graph_map_.erase(key);
(void)cell_resource_map_.erase(key);
}
Clean(); Clean();
// Maybe exit in the pynative runing op, so need reset pynative flag. // Maybe exit in the pynative runing op, so need reset pynative flag.
auto ms_context = MsContext::GetInstance(); auto ms_context = MsContext::GetInstance();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册