From 9109de6b1ffdc67d2714e985fd2ba509cbce4742 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Mon, 18 Apr 2022 10:40:15 -0700 Subject: [PATCH] Scoped GIL release in run_with_iobinding --- onnxruntime/python/onnxruntime_pybind_state.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/onnxruntime/python/onnxruntime_pybind_state.cc b/onnxruntime/python/onnxruntime_pybind_state.cc index 95a6a725082cf..1c1adcf20582d 100644 --- a/onnxruntime/python/onnxruntime_pybind_state.cc +++ b/onnxruntime/python/onnxruntime_pybind_state.cc @@ -1547,6 +1547,8 @@ including arg name, arg type (contains both type and shape).)pbdoc") py::return_value_policy::reference_internal) .def("run_with_iobinding", [](PyInferenceSession* sess, SessionIOBinding& io_binding, RunOptions* run_options = nullptr) -> void { Status status; + // release GIL to allow multiple python threads to invoke Run() in parallel. + py::gil_scoped_release release; if (!run_options) status = sess->GetSessionHandle()->Run(*io_binding.Get()); else