!46047 fix the DeviceContext exception

Merge pull request !46047 from liujunzhu/master
This commit is contained in:
i-robot 2022-11-30 02:52:04 +00:00 committed by Gitee
commit f292133c39
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 0 additions and 31 deletions

View File

@ -589,27 +589,11 @@ py::dict GraphExecutorPy::GetAllreduceFusion(const std::string &phase) {
// Not support multi thread, not support nested call too.
// Here using nested_called flg to avoid nested call.
void GraphExecutorPy::DelNetRes(const py::object &source_obj, const py::set &id) {
auto ms_context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(ms_context);
auto device_target = ms_context->get_param<std::string>(MS_CTX_DEVICE_TARGET);
std::string backend = ms_context->backend_policy();
if (device_target == kAscendDevice && backend == "ge") {
FinalizeBackend();
}
ClearArgCache(source_obj);
// Del all graphs by different phase
for (auto item : id) {
DelOneNetRes(item);
}
#ifdef WITH_BACKEND
if (backend == "ge" && !id.empty() && info_.size() == 0) {
DeviceContext *device_context = device::DeviceContextManager::GetInstance().GetOrCreateDeviceContext({"GE", 0});
MS_EXCEPTION_IF_NULL(device_context);
MS_EXCEPTION_IF_NULL(device_context->GetDeprecatedInterface());
// because Ge only support one Session exist at the same time ,so we delete the old one
device_context->GetDeprecatedInterface()->EraseGeResource();
}
#endif
}
void GraphExecutorPy::DelOneNetRes(const py::handle &py_phase) {

View File

@ -212,12 +212,6 @@ void AscendDeprecatedInterface::ClearGraphWrapper() { transform::DfGraphManager:
void AscendDeprecatedInterface::ClearOpAdapterMap() { transform::OpAdapterMap::get().clear(); }
void AscendDeprecatedInterface::EraseGeResource() {
transform::DfGraphManager::GetInstance().DeleteGraphRunner();
transform::DfGraphManager::GetInstance().EraseAnfGraph();
transform::DfGraphManager::GetInstance().DeleteGeSession();
}
void AscendDeprecatedInterface::DumpProfileParallelStrategy(const FuncGraphPtr &func_graph) {
return profiler::ascend::ParallelStrategy::GetInstance()->DumpProfileParallelStrategy(func_graph);
}

View File

@ -46,7 +46,6 @@ class AscendDeprecatedInterface : public DeprecatedInterface {
FuncGraphPtr BuildDFGraph(const FuncGraphPtr &anf_graph, const pybind11::dict &init_params) override;
void ClearGraphWrapper() override;
void ClearOpAdapterMap() override;
void EraseGeResource() override;
void DumpProfileParallelStrategy(const FuncGraphPtr &func_graph) override;
bool OpenTsd(const std::shared_ptr<MsContext> &ms_context_ptr) override;

View File

@ -47,7 +47,6 @@ class DeprecatedInterface {
}
virtual void ClearGraphWrapper() {}
virtual void ClearOpAdapterMap() {}
virtual void EraseGeResource() {}
// ascend
virtual void DumpProfileParallelStrategy(const FuncGraphPtr &func_graph) {}

View File

@ -142,11 +142,6 @@ AnfGraphPtr DfGraphManager::GetAnfGraph(uint32_t graph_id) {
return iter->second;
}
void DfGraphManager::EraseAnfGraph() {
std::lock_guard<std::mutex> lg(lock_);
anf_graphs_.clear();
}
void DfGraphManager::SetGeSession(const std::shared_ptr<::ge::Session> &sess_ptr) {
std::lock_guard<std::mutex> lg(lock_);
if (sess_ptr == nullptr) {

View File

@ -51,7 +51,6 @@ class BACKEND_EXPORT DfGraphManager {
void SetGeSession(const std::shared_ptr<::ge::Session> &sess_ptr);
std::shared_ptr<::ge::Session> GetGeSession();
void DeleteGeSession() noexcept;
void EraseAnfGraph();
private:
DfGraphManager();

View File

@ -30,7 +30,6 @@ void AscendDeprecatedInterface::ExportDFGraph(const std::string &, const std::st
FuncGraphPtr AscendDeprecatedInterface::BuildDFGraph(const FuncGraphPtr &, const pybind11::dict &) { return nullptr; }
void AscendDeprecatedInterface::ClearGraphWrapper() {}
void AscendDeprecatedInterface::ClearOpAdapterMap() {}
void AscendDeprecatedInterface::EraseGeResource() {}
void AscendDeprecatedInterface::DumpProfileParallelStrategy(const FuncGraphPtr &) {}
bool AscendDeprecatedInterface::OpenTsd(const std::shared_ptr<MsContext> &) { return true; }