diff --git a/mindspore/ccsrc/backend/session/executor.cc b/mindspore/ccsrc/backend/session/executor.cc index 6430f5e606..bba5f8f3bb 100644 --- a/mindspore/ccsrc/backend/session/executor.cc +++ b/mindspore/ccsrc/backend/session/executor.cc @@ -420,7 +420,7 @@ void Executor::RunOpsInGraph(const SessionPtr &session, const GraphId &graph_id, task->session_ = session; task->graph_id_ = graph_id; task->input_tensors_ = inputs; - RunTask(task, true); + RunTask(task, true, true); *outputs = task->outputs_; } diff --git a/mindspore/ccsrc/pybind_api/ir/tensor_py.cc b/mindspore/ccsrc/pybind_api/ir/tensor_py.cc index 1f51e6b51c..c8a4a2a949 100644 --- a/mindspore/ccsrc/pybind_api/ir/tensor_py.cc +++ b/mindspore/ccsrc/pybind_api/ir/tensor_py.cc @@ -259,11 +259,13 @@ py::tuple TensorPy::GetPyTupleShape(const Tensor &tensor) { } py::array TensorPy::SyncAsNumpy(const Tensor &tensor) { - if (tensor.NeedWait()) { + { py::gil_scoped_release gil_release; - tensor.Wait(); + if (tensor.NeedWait()) { + tensor.Wait(); + } + tensor.data_sync(); } - tensor.data_sync(); return AsNumpy(tensor); }