diff --git a/imperative/python/src/imperative_rt.cpp b/imperative/python/src/imperative_rt.cpp index 92cd9238b617895db1eb8fd654b74a3ecfe25fed..90c28761c6a0b17c1e8a2f0bff31d1af19f436e0 100644 --- a/imperative/python/src/imperative_rt.cpp +++ b/imperative/python/src/imperative_rt.cpp @@ -75,7 +75,7 @@ void init_imperative_rt(py::module m) { .def("get_shape", &Interpreter::Channel::get_shape) .def("_get_dev_tensor", &Interpreter::Channel::get_dev_tensor) .def("apply_op", &Interpreter::Channel::apply_op) - .def("sync", &Interpreter::Channel::sync); + .def("sync", &Interpreter::Channel::sync, py::call_guard()); std::unique_ptr ch = Interpreter::inst().create_channel(); m.attr("interpreter") = py::detail::make_caster::cast( @@ -86,6 +86,7 @@ void init_imperative_rt(py::module m) { m.def("sync", [m]() { m.attr("interpreter").attr("sync")(); + py::gil_scoped_release _; py_task_q.wait_all_task_finish(); });