diff mbox series

[FFmpeg-devel,3/6] lavfi/dnn_backend_openvino.c: move the logic for batch mode earlier

Message ID 20210418100802.19017-3-yejun.guo@intel.com
State New
Headers show
Series [FFmpeg-devel,1/6] lavfi/dnn_backend_openvino.c: unify code for infer request for sync/async
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Guo, Yejun April 18, 2021, 10:07 a.m. UTC
---
 libavfilter/dnn/dnn_backend_openvino.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 3692a381e2..a695d863b5 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -432,13 +432,6 @@  static DNNReturnType execute_model_ov(RequestItem *request, Queue *inferenceq)
     ctx = &task->ov_model->ctx;
 
     if (task->async) {
-        if (ff_queue_size(inferenceq) < ctx->options.batch_size) {
-            if (ff_safe_queue_push_front(task->ov_model->request_queue, request) < 0) {
-                av_log(ctx, AV_LOG_ERROR, "Failed to push back request_queue.\n");
-                return DNN_ERROR;
-            }
-            return DNN_SUCCESS;
-        }
         ret = fill_model_input_ov(task->ov_model, request);
         if (ret != DNN_SUCCESS) {
             return ret;
@@ -793,6 +786,11 @@  DNNReturnType ff_dnn_execute_model_async_ov(const DNNModel *model, const char *i
         return DNN_ERROR;
     }
 
+    if (ff_queue_size(ov_model->inference_queue) < ctx->options.batch_size) {
+        // not enough inference items queued for a batch
+        return DNN_SUCCESS;
+    }
+
     request = ff_safe_queue_pop_front(ov_model->request_queue);
     if (!request) {
         av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");