!23551 catch exception while setting abstract

Merge pull request !23551 from zhoufeng/xiu-ba-ge-2
This commit is contained in:
i-robot 2021-09-16 06:29:21 +00:00 committed by Gitee
commit 44ece0ff82
1 changed files with 17 additions and 8 deletions

View File

@ -202,7 +202,11 @@ void MindIREngine::EvalReturnPrimitive(const PrimitivePtr &prim, const CNodePtr
auto funcName = node->func_graph()->ToString(); auto funcName = node->func_graph()->ToString();
auto it = func_graph_result_.find(funcName); auto it = func_graph_result_.find(funcName);
if (it != func_graph_result_.end()) { if (it != func_graph_result_.end()) {
result = result->Join(it->second); try {
result = result->Join(it->second);
} catch (const std::exception &e) {
MS_LOG(WARNING) << "Join abstract for return node " << node->DebugString() << " failed, exception: " << e.what();
}
} }
this->func_graph_result_[funcName] = result; this->func_graph_result_[funcName] = result;
SaveNodeInferResult(node, result); SaveNodeInferResult(node, result);
@ -275,15 +279,20 @@ void MindIREngine::EvalPartialAbastract(const abstract::PartialAbstractClosurePt
void MindIREngine::SaveNodeInferResult(const AnfNodePtr &node, const AbstractBasePtr &result) { void MindIREngine::SaveNodeInferResult(const AnfNodePtr &node, const AbstractBasePtr &result) {
auto answer = result; auto answer = result;
auto it = infer_resut_.find(node); try {
if (it != infer_resut_.end()) { auto it = infer_resut_.find(node);
MS_LOG(DEBUG) << node->ToString() << " result: " << it->second->ToString(); if (it != infer_resut_.end()) {
answer = result->Join(it->second); MS_LOG(DEBUG) << node->ToString() << " result: " << it->second->ToString();
if (*answer == *(it->second)) { answer = result->Join(it->second);
MS_LOG(DEBUG) << node->ToString() << " The value is not changed."; if (*answer == *(it->second)) {
return; MS_LOG(DEBUG) << node->ToString() << " The value is not changed.";
return;
}
} }
} catch (const std::exception &e) {
MS_LOG(WARNING) << "Join abstract for node " << node->DebugString() << " failed, exception: " << e.what();
} }
MS_LOG(DEBUG) << node->ToString() << " result: " << answer->ToString(); MS_LOG(DEBUG) << node->ToString() << " result: " << answer->ToString();
infer_resut_[node] = answer; infer_resut_[node] = answer;
UpdateReady(node); UpdateReady(node);