|
|
|
@ -595,7 +595,7 @@ py::tuple RunOp(const py::args &args) {
|
|
|
|
|
|
|
|
|
|
void ClearPyNativeSession() { session = nullptr; }
|
|
|
|
|
|
|
|
|
|
PynativeExecutor::~PynativeExecutor() { Clean(); }
|
|
|
|
|
PynativeExecutor::~PynativeExecutor() { ClearRes(); }
|
|
|
|
|
|
|
|
|
|
PynativeExecutor::PynativeExecutor() { grad_flag_ = false; }
|
|
|
|
|
|
|
|
|
@ -849,17 +849,32 @@ void PynativeExecutor::GradNet(const GradOperationPtr &grad, const py::object &c
|
|
|
|
|
pipeline::ReclaimOptimizer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PynativeExecutor::Clear() {
|
|
|
|
|
MS_LOG(INFO) << "Clear all res";
|
|
|
|
|
top_g_ = curr_g_ = nullptr;
|
|
|
|
|
std::stack<FuncGraphPtr>().swap(graph_p_);
|
|
|
|
|
void PynativeExecutor::Clear(const std::string &flag) {
|
|
|
|
|
if (flag == "resource") {
|
|
|
|
|
MS_LOG(INFO) << "Clear res";
|
|
|
|
|
Clean();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
MS_LOG(INFO) << "Clear";
|
|
|
|
|
top_g_ = nullptr;
|
|
|
|
|
curr_g_ = nullptr;
|
|
|
|
|
graph_info_map_.clear();
|
|
|
|
|
std::stack<FuncGraphPtr>().swap(graph_p_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PynativeExecutor::Clean() {
|
|
|
|
|
MS_LOG(INFO) << "Clean all res";
|
|
|
|
|
Clear();
|
|
|
|
|
grad_flag_ = false;
|
|
|
|
|
graph_map_.clear();
|
|
|
|
|
cell_graph_map_.clear();
|
|
|
|
|
Clear();
|
|
|
|
|
df_builder_ = nullptr;
|
|
|
|
|
ad::CleanRes();
|
|
|
|
|
pipeline::ReclaimOptimizer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PynativeExecutor::ClearRes() {
|
|
|
|
|
Clean();
|
|
|
|
|
resource_.reset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|