Browse Source

Release GIL lock when SyncAsNumpy and run bprop graph in PyNative mod.

tags/v1.2.0-rc1
tanghuikang 4 years ago
parent
commit
b1ce9fed1e
2 changed files with 6 additions and 4 deletions
  1. +1
    -1
      mindspore/ccsrc/backend/session/executor.cc
  2. +5
    -3
      mindspore/ccsrc/pybind_api/ir/tensor_py.cc

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

@@ -428,7 +428,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_;
}



+ 5
- 3
mindspore/ccsrc/pybind_api/ir/tensor_py.cc View File

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



Loading…
Cancel
Save