Browse Source

!14154 fix executor last task not clear

From: @kisnwang
Reviewed-by: @zhoufeng54,@chujinjin
Signed-off-by:
tags/v1.2.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
e93cd6df85
2 changed files with 9 additions and 2 deletions
  1. +8
    -2
      mindspore/ccsrc/backend/session/executor.cc
  2. +1
    -0
      mindspore/ccsrc/backend/session/executor.h

+ 8
- 2
mindspore/ccsrc/backend/session/executor.cc View File

@@ -192,6 +192,7 @@ void Executor::WorkerLoop() {
done_tasks_.emplace_back(task);
}
if (task->type_ != kRunGraph || task->sync_run_) {
std::lock_guard<std::mutex> lock(task_mutex_);
sync_run_task_finished_ = true;
sync_cond_var_.notify_all();
}
@@ -217,12 +218,17 @@ void Executor::OnEvent(const ExecutorEvent &event) {
if (event == ExecutorEvent::kRunGraphFinished) {
OnRunGraphFinished();
} else if (event == ExecutorEvent::kClear) {
WorkerJoin();
OnClear();
} else if (event == ExecutorEvent::kException) {
OnException();
}
}

void Executor::OnClear() {
WorkerJoin();
ClearDoneTasks();
}

void Executor::OnException() {
std::vector<std::shared_ptr<Task>> new_done_tasks;
{
@@ -278,9 +284,9 @@ void Executor::ClearDoneTasks() {
}

void Executor::RunTask(const std::shared_ptr<Task> &task, bool sync, bool long_run) {
sync_run_task_finished_ = false;
{
std::lock_guard<std::mutex> lock(task_mutex_);
sync_run_task_finished_ = false;
ready_tasks_.push(task);
}
task_cond_var_.notify_all();


+ 1
- 0
mindspore/ccsrc/backend/session/executor.h View File

@@ -176,6 +176,7 @@ class Executor {
bool IsTaskReady(const std::shared_ptr<RunGraphTask> &task);
void WaitLockedInputs(const SessionPtr &session, const std::shared_ptr<RunGraphTask> &task);
void OnWorkerExit();
void OnClear();
void OnRunGraphFinished();
void OnException();
void ClearDoneTasks();


Loading…
Cancel
Save