diff --git a/mindspore/ccsrc/pipeline/pynative/grad/grad.cc b/mindspore/ccsrc/pipeline/pynative/grad/grad.cc index f480d6ce380..e1bc8022260 100644 --- a/mindspore/ccsrc/pipeline/pynative/grad/grad.cc +++ b/mindspore/ccsrc/pipeline/pynative/grad/grad.cc @@ -780,6 +780,7 @@ void GradExecutor::CheckNeedCompileGraph(const InputArgsInfoPtr &input_args_info { py::gil_scoped_acquire acquire; EraseTopCellFromTopCellList(pre_top_cell); + pre_top_cell->ClearDeviceMemory(); } already_run_top_cell_[already_top_cell_id] = new_top_cell; new_top_cell->set_force_top_cell_compile(false); diff --git a/mindspore/ccsrc/runtime/pynative/async/async_queue.cc b/mindspore/ccsrc/runtime/pynative/async/async_queue.cc index 24f45a7f4ff..b692a118d3a 100644 --- a/mindspore/ccsrc/runtime/pynative/async/async_queue.cc +++ b/mindspore/ccsrc/runtime/pynative/async/async_queue.cc @@ -40,17 +40,10 @@ void AsyncQueue::WorkerLoop() { while (true) { std::shared_ptr task; - bool task_empty = false; { std::unique_lock lock(task_mutex_); - task_empty = tasks_.empty(); - if (!task_empty) { - task = tasks_.front(); - } - } - if (task_empty) { - std::this_thread::yield(); - continue; + task_cond_var_.wait(lock, [this]() { return !tasks_.empty(); }); + task = tasks_.front(); } MS_LOG(DEBUG) << "Get task";