diff --git a/mindspore/ccsrc/backend/session/executor.cc b/mindspore/ccsrc/backend/session/executor.cc index cd225ebf1d..f4f147f142 100644 --- a/mindspore/ccsrc/backend/session/executor.cc +++ b/mindspore/ccsrc/backend/session/executor.cc @@ -14,6 +14,7 @@ * limitations under the License. */ #include "backend/session/executor.h" +#include #include #include "backend/session/executor_manager.h" #include "runtime/device/kernel_runtime_manager.h" @@ -169,11 +170,12 @@ void Executor::WorkerLoop() { } catch (const std::exception &e) { MsException::GetInstance().SetException(); } + { + std::unique_lock lock(task_mutex_); + done_tasks_.emplace_back(task); + } if (task->type_ != kRunGraph || task->sync_run_) { - task = nullptr; sync_cond_var_.notify_all(); - } else { - task = nullptr; } } } @@ -304,6 +306,7 @@ void Executor::RunGraphAsync(const SessionPtr &session, const GraphId &graph_id, } std::unique_lock lock(task_mutex_); ready_tasks_.push(task); + done_tasks_.clear(); task_cond_var_.notify_all(); } diff --git a/mindspore/ccsrc/backend/session/executor.h b/mindspore/ccsrc/backend/session/executor.h index abc0f9f684..b0c67993db 100644 --- a/mindspore/ccsrc/backend/session/executor.h +++ b/mindspore/ccsrc/backend/session/executor.h @@ -183,6 +183,7 @@ class Executor { std::condition_variable sync_cond_var_; std::queue> ready_tasks_; std::list> pending_tasks_; + std::vector> done_tasks_; std::shared_ptr worker_; }; } // namespace session