Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Raja Rathour via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: guoyejun@gmail.com, Raja Rathour <imraja729@gmail.com>
Subject: [FFmpeg-devel] [PATCH v2 2/3] avfilter/dnn_backend_torch: implement async execution logic
Date: Thu,  1 Jan 2026 13:37:21 +0530
Message-ID: <20260101080722.133215-3-imraja729@gmail.com> (raw)
In-Reply-To: <20260101080722.133215-1-imraja729@gmail.com>

Update execute_model_th to support asynchronous execution by pushing tasks to the pending queue and notifying the worker thread.

Signed-off-by: Raja Rathour <imraja729@gmail.com>
---
 libavfilter/dnn/dnn_backend_torch.cpp | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp
index af92cd13da..b5ff5b44d1 100644
--- a/libavfilter/dnn/dnn_backend_torch.cpp
+++ b/libavfilter/dnn/dnn_backend_torch.cpp
@@ -375,14 +375,12 @@ static int execute_model_th(THRequestItem *request, Queue *lltask_queue)
         goto err;
     }
     if (task->async) {
-        avpriv_report_missing_feature(th_model->ctx, "LibTorch async");
-    } else {
-        ret = th_start_inference((void *)(request));
-        if (ret != 0) {
-            goto err;
+        std::lock_guard<std::mutex> lock(*th_model->mutex);
+        if (ff_safe_queue_push_back(th_model->pending_queue, request) < 0) {
+            return AVERROR(ENOMEM);
         }
-        infer_completion_callback(request);
-        return (task->inference_done == task->inference_todo) ? 0 : DNN_GENERIC_ERROR;
+        th_model->cond->notify_one();
+        return 0;
     }
 
 err:
-- 
2.48.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

  parent reply	other threads:[~2026-01-01  8:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-25 10:33 [FFmpeg-devel] [PATCH 1/3] avfilter/dnn_backend_torch: implement async execution Raja Rathour via ffmpeg-devel
2025-12-31  6:41 ` [FFmpeg-devel] " Guo, Yejun via ffmpeg-devel
2026-01-01  8:07   ` [FFmpeg-devel] [PATCH v2 0/3] avfilter/dnn: add async support for LibTorch backend Raja Rathour via ffmpeg-devel
2026-01-01  8:07     ` [FFmpeg-devel] [PATCH v2 1/3] avfilter/dnn_backend_torch: add async infrastructure Raja Rathour via ffmpeg-devel
2026-01-01  8:07     ` Raja Rathour via ffmpeg-devel [this message]
2026-01-01  8:07     ` [FFmpeg-devel] [PATCH v2 3/3] avfilter/dnn_backend_torch: handle lifecycle of worker thread Raja Rathour via ffmpeg-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260101080722.133215-3-imraja729@gmail.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=guoyejun@gmail.com \
    --cc=imraja729@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git