diff --git a/mindspore/ccsrc/backend/session/ascend_session.cc b/mindspore/ccsrc/backend/session/ascend_session.cc index f87ceb47fff..e7ee0c2eb04 100644 --- a/mindspore/ccsrc/backend/session/ascend_session.cc +++ b/mindspore/ccsrc/backend/session/ascend_session.cc @@ -659,7 +659,7 @@ void AscendSession::CompileChildGraph(const KernelGraphPtr &child_graph) { bool AscendSession::IsSupportSummary() { return !device::KernelAdjust::NeedInsertSwitch(); } void AscendSession::PreExecuteGraph(const std::shared_ptr &kernel_graph, - const std::vector &inputs, VectorRef *const outputs) { + const std::vector &inputs, VectorRef *const) { if (debugger_) { debugger_->PreExecute(kernel_graph, graph_sum_); } @@ -674,7 +674,7 @@ void AscendSession::PreExecuteGraph(const std::shared_ptr &kernel_g } void AscendSession::PostExecuteGraph(const std::shared_ptr &kernel_graph, - const std::vector &inputs, VectorRef *const outputs) { + const std::vector &inputs, VectorRef *const) { // summary Summary(kernel_graph.get()); // load tensor from device for debugger diff --git a/mindspore/ccsrc/backend/session/executor.cc b/mindspore/ccsrc/backend/session/executor.cc index 3dccb80e085..b275a1a657e 100644 --- a/mindspore/ccsrc/backend/session/executor.cc +++ b/mindspore/ccsrc/backend/session/executor.cc @@ -17,6 +17,7 @@ #include "backend/session/executor_manager.h" #include #include +#include #include "runtime/device/kernel_runtime_manager.h" #include "utils/comm_manager.h" #include "utils/scoped_long_running.h" @@ -168,7 +169,13 @@ Executor::Executor(const std::string &device_name, uint32_t device_id) { worker_ = std::make_shared(&Executor::WorkerLoop, this); } -Executor::~Executor() { WorkerJoin(); } +Executor::~Executor() { + try { + WorkerJoin(); + } catch (const std::exception &e) { + MS_LOG(ERROR) << "Executor call destructor failed: " << e.what(); + } +} void Executor::WorkerJoin() { // Avoid worker thread join itself which will cause deadlock @@ -220,7 +227,7 @@ std::vector> Executor::GetReadyTasksFromPendingLis for (auto iter = pending_tasks_.begin(); iter != pending_tasks_.end();) { auto task = *iter; if (IsTaskReady(task)) { - ready_tasks.emplace_back(task); + (void)ready_tasks.emplace_back(task); pending_tasks_.erase(iter++); } else { ++iter; @@ -249,13 +256,13 @@ void Executor::OnException() { { std::lock_guard lock(task_mutex_); while (!ready_tasks_.empty()) { - done_tasks.emplace_back(ready_tasks_.front()); + (void)done_tasks.emplace_back(ready_tasks_.front()); ready_tasks_.pop(); } } { std::lock_guard lock(pending_task_mutex_); - std::copy(pending_tasks_.begin(), pending_tasks_.end(), std::back_inserter(done_tasks)); + (void)std::copy(pending_tasks_.begin(), pending_tasks_.end(), std::back_inserter(done_tasks)); pending_tasks_.clear(); } { @@ -429,7 +436,7 @@ void Executor::RunOpsInGraph(const SessionPtr &session, const GraphId &graph_id, *outputs = task->outputs_; } -bool Executor::CreateCommGroup(const std::string &group_name, std::vector ranks) { +bool Executor::CreateCommGroup(const std::string &group_name, const std::vector &ranks) { auto task = std::make_shared(); task->group_name_ = group_name; task->ranks_ = ranks; diff --git a/mindspore/ccsrc/backend/session/executor.h b/mindspore/ccsrc/backend/session/executor.h index c89ad81abee..3e32f0af1cf 100644 --- a/mindspore/ccsrc/backend/session/executor.h +++ b/mindspore/ccsrc/backend/session/executor.h @@ -166,7 +166,7 @@ class Executor { const std::vector &tensors_mask); void RunOpsInGraph(const SessionPtr &session, const GraphId &graph_id, const std::vector &inputs, VectorRef *outputs); - bool CreateCommGroup(const std::string &group_name, std::vector ranks); + bool CreateCommGroup(const std::string &group_name, const std::vector &ranks); bool DestroyCommGroup(const std::string &group_name); void OnEvent(const ExecutorEvent &event); diff --git a/mindspore/ccsrc/backend/session/executor_manager.cc b/mindspore/ccsrc/backend/session/executor_manager.cc index d4e01a2bdd4..c9601650ec8 100644 --- a/mindspore/ccsrc/backend/session/executor_manager.cc +++ b/mindspore/ccsrc/backend/session/executor_manager.cc @@ -17,7 +17,7 @@ #include "common/thread_pool.h" namespace mindspore { namespace session { -std::shared_ptr ExecutorManager::GetExecutor(const std::string &device_name, int device_id) { +std::shared_ptr ExecutorManager::GetExecutor(const std::string &device_name, uint32_t device_id) { std::string device_key = device_name + "_" + std::to_string(device_id); auto iter = executors_.find(device_key); if (iter != executors_.end()) { diff --git a/mindspore/ccsrc/backend/session/executor_manager.h b/mindspore/ccsrc/backend/session/executor_manager.h index 9d1cbaa0951..c5a897fee3a 100644 --- a/mindspore/ccsrc/backend/session/executor_manager.h +++ b/mindspore/ccsrc/backend/session/executor_manager.h @@ -29,7 +29,7 @@ class ExecutorManager { static ExecutorManager instance; return instance; } - std::shared_ptr GetExecutor(const std::string &device_name, int device_id); + std::shared_ptr GetExecutor(const std::string &device_name, uint32_t device_id); void OnEvent(const ExecutorEvent &event); void Clear(); diff --git a/mindspore/ccsrc/backend/session/kernel_build_client.cc b/mindspore/ccsrc/backend/session/kernel_build_client.cc index 9e5b0e5e547..5cdf0f6c5fb 100644 --- a/mindspore/ccsrc/backend/session/kernel_build_client.cc +++ b/mindspore/ccsrc/backend/session/kernel_build_client.cc @@ -76,9 +76,9 @@ bool KernelBuildClient::AkgWait() { return true; } -bool AscendKernelBuildClient::TbePre(const std::string &mode) { +void AscendKernelBuildClient::TbePre(const std::string &mode) { auto res = SendRequest(kTbePre); - if (res.find(kSuccess) == res.npos) { + if (res.find(kSuccess) == std::string::npos) { MS_LOG(EXCEPTION) << "PRE failed, res: " << res; } MS_LOG(INFO) << "Pre " << res; @@ -91,15 +91,11 @@ bool AscendKernelBuildClient::TbePre(const std::string &mode) { if (res != kSuccess) { MS_LOG(EXCEPTION) << "PRE failed, res: " << res; } - - return true; } int AscendKernelBuildClient::TbeStart(const std::string &json, const std::string &mode) { if (!init_flag) { - if (!TbePre(mode)) { - MS_LOG(EXCEPTION) << "START failed"; - } + TbePre(mode); init_flag = true; } // Start compiling.. diff --git a/mindspore/ccsrc/backend/session/kernel_build_client.h b/mindspore/ccsrc/backend/session/kernel_build_client.h index 16b69d11a6c..b722848eb8f 100644 --- a/mindspore/ccsrc/backend/session/kernel_build_client.h +++ b/mindspore/ccsrc/backend/session/kernel_build_client.h @@ -239,7 +239,7 @@ class AscendKernelBuildClient : public KernelBuildClient { AscendKernelBuildClient &operator=(AscendKernelBuildClient &&) = delete; private: - bool TbePre(const std::string &mode); + void TbePre(const std::string &mode); AscendKernelBuildClient() { Open(); } ~AscendKernelBuildClient() override { Close(); } }; diff --git a/mindspore/ccsrc/backend/session/kernel_graph.cc b/mindspore/ccsrc/backend/session/kernel_graph.cc index 94cffd67780..1e186b2a3be 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.cc +++ b/mindspore/ccsrc/backend/session/kernel_graph.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include "base/core_ops.h" #include "ir/param_info.h" #include "utils/utils.h" @@ -831,18 +832,6 @@ std::vector KernelGraph::GetOutputNodes(const AnfNodePtr &node) { return output_nodes; } -void KernelGraph::UpdateNodeInputOutputEdges(const std::vector &real_prior_nodes, - const std::vector &real_depend_nodes) { - for (auto &first_node : real_prior_nodes) { - for (auto &second_node : real_depend_nodes) { - MS_EXCEPTION_IF_NULL(first_node); - MS_EXCEPTION_IF_NULL(second_node); - MS_LOG(DEBUG) << "Add first node:" << first_node->DebugString() << ",second node:" << second_node->DebugString(); - AddDependEdge(second_node, first_node, 1); - } - } -} - void KernelGraph::UpdateNodeEdgeList(std::queue *seed_nodes) { MS_EXCEPTION_IF_NULL(seed_nodes); node_output_edges_.clear(); @@ -1275,8 +1264,12 @@ void KernelGraph::SetOptimizerFlag() { std::string KernelGraph::ToString() const { return std::string("kernel_graph_").append(std::to_string(graph_id_)); } KernelGraph::~KernelGraph() { - device::KernelRuntimeManager::Instance().ClearGraphResource(graph_id_, *inputs_, graph_value_nodes_, - execution_order_); + try { + device::KernelRuntimeManager::Instance().ClearGraphResource(graph_id_, *inputs_, graph_value_nodes_, + execution_order_); + } catch (const std::exception &e) { + MS_LOG(ERROR) << "KernelGraph call destructor failed: " << e.what(); + } } } // namespace session } // namespace mindspore diff --git a/mindspore/ccsrc/backend/session/kernel_graph.h b/mindspore/ccsrc/backend/session/kernel_graph.h index 59f9bdc740b..bdceb20f83e 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.h +++ b/mindspore/ccsrc/backend/session/kernel_graph.h @@ -326,8 +326,6 @@ class KernelGraph : public FuncGraph { void UpdateNodeEdgeList(std::queue *seed_nodes); // add node depend edge by data edge void AddDependEdge(const AnfNodePtr &node, const AnfNodePtr &input, size_t depend_edge_num); - void UpdateNodeInputOutputEdges(const std::vector &real_prior_nodes, - const std::vector &real_depend_nodes); std::vector GetOutputNodes(const AnfNodePtr &node); AnfNodePtr TransValueNodeTuple(const AbstractBasePtr abstract, const ValuePtr &value); AnfNodePtr TransParameterTuple(const AbstractBasePtr &abstract); diff --git a/mindspore/ccsrc/backend/session/session_basic.cc b/mindspore/ccsrc/backend/session/session_basic.cc index d5c4f6959fc..b1b6a8f6940 100644 --- a/mindspore/ccsrc/backend/session/session_basic.cc +++ b/mindspore/ccsrc/backend/session/session_basic.cc @@ -1618,7 +1618,6 @@ void SessionBasic::GetModelInputsInfo(uint32_t graph_id, std::vectorinputs(); - vector paras; // find parameters of graph inputs for (size_t i = 0; i < kernel_graph_inputs.size(); ++i) { if (!kernel_graph_inputs[i]->isa()) { diff --git a/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.cc b/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.cc index 8cb2eaab3c6..2edd737068d 100644 --- a/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.cc +++ b/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.cc @@ -17,7 +17,7 @@ #include "frontend/parallel/parallel_stub/executor_manager_stub.h" namespace mindspore { namespace parallel { -std::shared_ptr ExecutorManager::GetExecutor(const std::string &dev_name, int dev_id) { +std::shared_ptr ExecutorManager::GetExecutor(const std::string &dev_name, uint32_t dev_id) { std::string dev_key = dev_name + "_" + std::to_string(dev_id); auto iter = executors_.find(dev_key); if (iter != executors_.end()) { diff --git a/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.h b/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.h index 6a987d0ba5e..e6bb8803e9e 100644 --- a/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.h +++ b/mindspore/ccsrc/frontend/parallel/parallel_stub/executor_manager_stub.h @@ -30,7 +30,7 @@ class ExecutorManager { static ExecutorManager instance; return instance; } - std::shared_ptr GetExecutor(const std::string &device_name, int device_id); + std::shared_ptr GetExecutor(const std::string &device_name, uint32_t device_id); private: ExecutorManager() = default;