OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[CS Issue][Batch Plugin] Fix CS issue in Batch Plugin (#25683)
Xuejun Zhai8e2dc85ddd0a
diff --git a/src/plugins/auto_batch/src/async_infer_request.cpp b/src/plugins/auto_batch/src/async_infer_request.cppindex a92e8c7f06f..d740d9d5861 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<SyncInferRequest>& 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<int>(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.cppindex 68de2481a3e..b02759f53dc 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<std::mutex> 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.hppindex 200445f0140..c4cf38d0e70 100644--- a/src/plugins/auto_batch/src/compiled_model.hpp+++ b/src/plugins/auto_batch/src/compiled_model.hpp@@ -30,6 +30,7 @@ public:std::condition_variable _cond;std::mutex _mutex;std::exception_ptr _exception_ptr;+ bool _is_wakeup;};CompiledModel(const std::shared_ptr<ov::Model>& model,