diff --git a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc index 64e5bb59a1..5f789c52ce 100644 --- a/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc +++ b/mindspore/ccsrc/pipeline/pynative/pynative_execute.cc @@ -1846,8 +1846,9 @@ void MapClear(T *map, const std::string &flag) { void PynativeExecutor::Clear(const std::string &flag) { if (!flag.empty()) { MS_LOG(DEBUG) << "Clear cell res"; - MapClear>>(&cell_graph_map_, flag); MapClear>(&cell_resource_map_, flag); + MapClear>>(&cell_graph_map_, flag); + MapClear>>(&cell_sw_map_, flag); MapClear>>(&df_builder_map_, flag); // Maybe exit in the pynative runing op, so need reset pynative flag. @@ -1886,11 +1887,13 @@ void PynativeExecutor::Clean() { void PynativeExecutor::ClearRes() { MS_LOG(DEBUG) << "PynativeExecutor destruct"; + Clean(); + cell_sw_map_.clear(); df_builder_map_.clear(); cell_graph_map_.clear(); cell_resource_map_.clear(); node_abs_map_.clear(); - Clean(); + top_graph_cells_.clear(); } void PynativeExecutor::NewGraph(const py::object &cell, const py::args &args) { diff --git a/mindspore/ccsrc/pipeline/pynative/pynative_execute.h b/mindspore/ccsrc/pipeline/pynative/pynative_execute.h index ac55fad774..54fa41cca4 100644 --- a/mindspore/ccsrc/pipeline/pynative/pynative_execute.h +++ b/mindspore/ccsrc/pipeline/pynative/pynative_execute.h @@ -56,13 +56,10 @@ py::object RunOpInVM(const OpExecInfoPtr &op_exec_info, PynativeStatusCode *stat py::tuple RunOp(const py::args &args); -void ConvertInputs(const PrimitivePyPtr &prim, const py::list &py_args, py::tuple *const out_args, - py::list *const out_args_list); - void ClearPyNativeSession(); struct GraphInfo { - std::unordered_set params; // hold inpout parameters and cell weigths + std::unordered_set params; // hold input parameters and cell weigths std::unordered_map>> node_map; AnfNodePtr output; std::vector objects; @@ -78,6 +75,8 @@ class PynativeExecutor : public std::enable_shared_from_this { return executor_; } ~PynativeExecutor(); + PynativeExecutor(const PynativeExecutor &) = delete; + PynativeExecutor &operator=(const PynativeExecutor &) = delete; bool grad_flag() { return grad_flag_; } void set_grad_flag(bool flag) { grad_flag_ = flag; } @@ -100,8 +99,6 @@ class PynativeExecutor : public std::enable_shared_from_this { private: PynativeExecutor() = default; - PynativeExecutor(const PynativeExecutor &) = delete; - PynativeExecutor &operator=(const PynativeExecutor &) = delete; // run op AnfNodePtr GetInput(const py::object &obj, bool op_mask); @@ -146,13 +143,13 @@ class PynativeExecutor : public std::enable_shared_from_this { // hold graph(forward and grad) info void set_pyobj(FuncGraphPtr g, const std::string obj) { graph_info_map_[g].objects.push_back(obj); } void set_node_map(const FuncGraphPtr &g, const py::object &node, const AnfNodePtr &cnode, bool is_param = false); - void set_node_map(FuncGraphPtr g, const std::string obj, AnfNodePtr node) { + void set_node_map(const FuncGraphPtr &g, const std::string &obj, AnfNodePtr node) { graph_info_map_[g].node_map[obj] = std::make_pair(node, std::vector{-1}); } - void set_node_map(FuncGraphPtr g, const std::string obj, AnfNodePtr node, int index) { + void set_node_map(const FuncGraphPtr &g, const std::string &obj, AnfNodePtr node, int index) { graph_info_map_[g].node_map[obj] = std::make_pair(node, std::vector{index}); } - void set_node_map(FuncGraphPtr g, const std::string obj, AnfNodePtr node, std::vector index) { + void set_node_map(const FuncGraphPtr &g, const std::string &obj, AnfNodePtr node, std::vector index) { graph_info_map_[g].node_map[obj] = std::make_pair(node, index); } void set_tuple_node_map(const FuncGraphPtr &g, const py::object &node, const AnfNodePtr &cnode,