format codes

This commit is contained in:
kswang 2021-06-03 08:42:54 +08:00
parent 643a25e03b
commit 9d5f754135
12 changed files with 30 additions and 37 deletions

View File

@ -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<KernelGraph> &kernel_graph,
const std::vector<tensor::TensorPtr> &inputs, VectorRef *const outputs) {
const std::vector<tensor::TensorPtr> &inputs, VectorRef *const) {
if (debugger_) {
debugger_->PreExecute(kernel_graph, graph_sum_);
}
@ -674,7 +674,7 @@ void AscendSession::PreExecuteGraph(const std::shared_ptr<KernelGraph> &kernel_g
}
void AscendSession::PostExecuteGraph(const std::shared_ptr<KernelGraph> &kernel_graph,
const std::vector<tensor::TensorPtr> &inputs, VectorRef *const outputs) {
const std::vector<tensor::TensorPtr> &inputs, VectorRef *const) {
// summary
Summary(kernel_graph.get());
// load tensor from device for debugger

View File

@ -17,6 +17,7 @@
#include "backend/session/executor_manager.h"
#include <algorithm>
#include <exception>
#include <set>
#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<std::thread>(&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<std::shared_ptr<RunGraphTask>> 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<std::mutex> 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<std::mutex> 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<uint32_t> ranks) {
bool Executor::CreateCommGroup(const std::string &group_name, const std::vector<uint32_t> &ranks) {
auto task = std::make_shared<CreateCommGroupTask>();
task->group_name_ = group_name;
task->ranks_ = ranks;

View File

@ -166,7 +166,7 @@ class Executor {
const std::vector<int64_t> &tensors_mask);
void RunOpsInGraph(const SessionPtr &session, const GraphId &graph_id, const std::vector<tensor::TensorPtr> &inputs,
VectorRef *outputs);
bool CreateCommGroup(const std::string &group_name, std::vector<uint32_t> ranks);
bool CreateCommGroup(const std::string &group_name, const std::vector<uint32_t> &ranks);
bool DestroyCommGroup(const std::string &group_name);
void OnEvent(const ExecutorEvent &event);

View File

@ -17,7 +17,7 @@
#include "common/thread_pool.h"
namespace mindspore {
namespace session {
std::shared_ptr<Executor> ExecutorManager::GetExecutor(const std::string &device_name, int device_id) {
std::shared_ptr<Executor> 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()) {

View File

@ -29,7 +29,7 @@ class ExecutorManager {
static ExecutorManager instance;
return instance;
}
std::shared_ptr<Executor> GetExecutor(const std::string &device_name, int device_id);
std::shared_ptr<Executor> GetExecutor(const std::string &device_name, uint32_t device_id);
void OnEvent(const ExecutorEvent &event);
void Clear();

View File

@ -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..

View File

@ -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(); }
};

View File

@ -18,6 +18,7 @@
#include <queue>
#include <unordered_set>
#include <set>
#include <exception>
#include "base/core_ops.h"
#include "ir/param_info.h"
#include "utils/utils.h"
@ -831,18 +832,6 @@ std::vector<AnfNodePtr> KernelGraph::GetOutputNodes(const AnfNodePtr &node) {
return output_nodes;
}
void KernelGraph::UpdateNodeInputOutputEdges(const std::vector<AnfNodePtr> &real_prior_nodes,
const std::vector<AnfNodePtr> &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<AnfNodePtr> *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

View File

@ -326,8 +326,6 @@ class KernelGraph : public FuncGraph {
void UpdateNodeEdgeList(std::queue<AnfNodePtr> *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<AnfNodePtr> &real_prior_nodes,
const std::vector<AnfNodePtr> &real_depend_nodes);
std::vector<AnfNodePtr> GetOutputNodes(const AnfNodePtr &node);
AnfNodePtr TransValueNodeTuple(const AbstractBasePtr abstract, const ValuePtr &value);
AnfNodePtr TransParameterTuple(const AbstractBasePtr &abstract);

View File

@ -1618,7 +1618,6 @@ void SessionBasic::GetModelInputsInfo(uint32_t graph_id, std::vector<tensor::Ten
MS_EXCEPTION_IF_NULL(inputs);
MS_EXCEPTION_IF_NULL(inputs_name);
auto kernel_graph_inputs = kernel_graph->inputs();
vector<ParameterPtr> paras;
// find parameters of graph inputs
for (size_t i = 0; i < kernel_graph_inputs.size(); ++i) {
if (!kernel_graph_inputs[i]->isa<Parameter>()) {

View File

@ -17,7 +17,7 @@
#include "frontend/parallel/parallel_stub/executor_manager_stub.h"
namespace mindspore {
namespace parallel {
std::shared_ptr<Executor> ExecutorManager::GetExecutor(const std::string &dev_name, int dev_id) {
std::shared_ptr<Executor> 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()) {

View File

@ -30,7 +30,7 @@ class ExecutorManager {
static ExecutorManager instance;
return instance;
}
std::shared_ptr<Executor> GetExecutor(const std::string &device_name, int device_id);
std::shared_ptr<Executor> GetExecutor(const std::string &device_name, uint32_t device_id);
private:
ExecutorManager() = default;