This is an automated email from the git hooks/post-receive script.
Git pushed a commit to branch master
in repository ffmpeg.
The following commit(s) were added to refs/heads/master by this push:
new 312c830916 avfilter/dnn: auto-initialize nireq for Torch backend
312c830916 is described below
commit 312c8309162eab790d6bed069db7eb1a52263e1e
Author: Raja-89 <[email protected]>
AuthorDate: Mon Jul 13 20:18:47 2026 +0530
Commit: guoyejun <[email protected]>
CommitDate: Tue Jul 14 14:26:53 2026 +0000
avfilter/dnn: auto-initialize nireq for Torch backend
Initialize ctx->nireq with av_cpu_count() / 2 + 1 when
unset, matching the TensorFlow and OpenVINO backends.
Create ctx->nireq THRequestItems in a loop instead of
hardcoding a single request, enabling concurrent async
inference requests for improved throughput.
Signed-off-by: Raja Rathour <[email protected]>
---
libavfilter/dnn/dnn_backend_torch.cpp | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/libavfilter/dnn/dnn_backend_torch.cpp
b/libavfilter/dnn/dnn_backend_torch.cpp
index 62bf7d9e9e..2beffd6e2c 100644
--- a/libavfilter/dnn/dnn_backend_torch.cpp
+++ b/libavfilter/dnn/dnn_backend_torch.cpp
@@ -31,6 +31,7 @@ extern "C" {
#include "dnn_backend_common.h"
#include "libavutil/opt.h"
#include "libavutil/mem.h"
+#include "libavutil/cpu.h"
#include "queue.h"
#include "safe_queue.h"
}
@@ -464,28 +465,34 @@ static DNNModel *dnn_load_model_th(DnnContext *ctx,
DNNFunctionType func_type, A
goto fail;
}
+ if (ctx->nireq <= 0) {
+ ctx->nireq = av_cpu_count() / 2 + 1;
+ }
+
th_model->request_queue = ff_safe_queue_create();
if (!th_model->request_queue) {
goto fail;
}
- item = (THRequestItem *)av_mallocz(sizeof(THRequestItem));
- if (!item) {
- goto fail;
- }
- item->infer_request = th_create_inference_request();
- if (!item->infer_request) {
- goto fail;
- }
+ for (int i = 0; i < ctx->nireq; i++) {
+ item = (THRequestItem *)av_mallocz(sizeof(THRequestItem));
+ if (!item) {
+ goto fail;
+ }
+ item->infer_request = th_create_inference_request();
+ if (!item->infer_request) {
+ goto fail;
+ }
- item->exec_module.start_inference = &th_start_inference;
- item->exec_module.callback = &infer_completion_callback;
- item->exec_module.args = item;
+ item->exec_module.start_inference = &th_start_inference;
+ item->exec_module.callback = &infer_completion_callback;
+ item->exec_module.args = item;
- if (ff_safe_queue_push_back(th_model->request_queue, item) < 0) {
- goto fail;
+ if (ff_safe_queue_push_back(th_model->request_queue, item) < 0) {
+ goto fail;
+ }
+ item = NULL;
}
- item = NULL;
th_model->task_queue = ff_queue_create();
th_model->lltask_queue = ff_queue_create();
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]