diff --git a/src/plugins/auto_batch/src/async_infer_request.cpp b/src/plugins/auto_batch/src/async_infer_request.cpp index a92e8c7f06ff43..d740d9d5861ed6 100644 --- a/src/plugins/auto_batch/src/async_infer_request.cpp +++ b/src/plugins/auto_batch/src/async_infer_request.cpp @@ -69,6 +69,7 @@ AsyncInferRequest::AsyncInferRequest(const std::shared_ptr& re // it is ok to call size() here as the queue only grows (and the bulk removal happens under the mutex) const int sz = static_cast(workerInferRequest->_tasks.size()); if (sz == workerInferRequest->_batch_size) { + workerInferRequest->_is_wakeup = true; workerInferRequest->_cond.notify_one(); } }; diff --git a/src/plugins/auto_batch/src/compiled_model.cpp b/src/plugins/auto_batch/src/compiled_model.cpp index 68de2481a3e019..b02759f53dc1d1 100644 --- a/src/plugins/auto_batch/src/compiled_model.cpp +++ b/src/plugins/auto_batch/src/compiled_model.cpp @@ -64,6 +64,7 @@ CompiledModel::GetWorkerInferRequest() const { workerRequestPtr->_infer_request_batched._so = m_compiled_model_with_batch._so; workerRequestPtr->_batch_size = m_device_info.device_batch_size; workerRequestPtr->_completion_tasks.resize(workerRequestPtr->_batch_size); + workerRequestPtr->_is_wakeup = false; workerRequestPtr->_infer_request_batched->set_callback( [workerRequestPtr](std::exception_ptr exceptionPtr) mutable { if (exceptionPtr) @@ -74,6 +75,7 @@ CompiledModel::GetWorkerInferRequest() const { workerRequestPtr->_completion_tasks[c](); } // reset the timeout + workerRequestPtr->_is_wakeup = true; workerRequestPtr->_cond.notify_one(); }); @@ -83,6 +85,9 @@ CompiledModel::GetWorkerInferRequest() const { { std::unique_lock lock(workerRequestPtr->_mutex); status = workerRequestPtr->_cond.wait_for(lock, std::chrono::milliseconds(m_time_out)); + if ((status != std::cv_status::timeout) && (workerRequestPtr->_is_wakeup == false)) + continue; + workerRequestPtr->_is_wakeup = false; } if (m_terminate) { break; diff --git a/src/plugins/auto_batch/src/compiled_model.hpp b/src/plugins/auto_batch/src/compiled_model.hpp index 200445f0140495..c4cf38d0e701ea 100644 --- a/src/plugins/auto_batch/src/compiled_model.hpp +++ b/src/plugins/auto_batch/src/compiled_model.hpp @@ -30,6 +30,7 @@ class CompiledModel : public ov::ICompiledModel { std::condition_variable _cond; std::mutex _mutex; std::exception_ptr _exception_ptr; + bool _is_wakeup; }; CompiledModel(const std::shared_ptr& model,