!5528 Fix unnecessary catch and core dump in graph kernel

Merge pull request !5528 from Kang/opt
This commit is contained in:
mindspore-ci-bot 2020-08-31 09:14:13 +08:00 committed by Gitee
commit 6169226dcf
2 changed files with 6 additions and 5 deletions

View File

@ -37,9 +37,11 @@ class MergeAddN : public AnfVisitor {
public:
AnfNodePtr operator()(const OptimizerPtr &optimizer, const AnfNodePtr &node) override {
Reset();
optimizer_ = optimizer;
mng_ = optimizer->resource()->manager();
is_outer_ = true;
AnfVisitor::Match(prim::kPrimAddN, {IsCNode})(node);
// do not hold this manager
mng_ = nullptr;
if (!is_match_ || node->func_graph() == nullptr) {
return nullptr;
}
@ -104,8 +106,7 @@ class MergeAddN : public AnfVisitor {
}
bool is_unique(const AnfNodePtr &node) {
auto mng = optimizer_->resource()->manager();
auto &node_users = mng->node_users();
auto &node_users = mng_->node_users();
if (node_users.find(node) == node_users.end()) {
return false;
}
@ -124,7 +125,7 @@ class MergeAddN : public AnfVisitor {
}
private:
OptimizerPtr optimizer_{nullptr};
FuncGraphManagerPtr mng_{nullptr};
std::vector<AnfNodePtr> Xs_{}, Ys_{}, args_{};
bool is_inner_{false}, is_outer_{false}, is_match_{false};
};

View File

@ -481,9 +481,9 @@ bool ExecutorPy::CompileInner(const py::object &obj, const py::tuple &args, cons
SaveCompiledGraph(phase_s);
opt::python_pass::PyPassManager::GetInstance()->ClearPipelineRes();
resource->Clean();
// Reclaim all resource used by optimizer;
ReclaimOptimizer();
resource->Clean();
MS_LOG(INFO) << "End ExecutorPy compile!";
return true;