From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 949AA4F36C for ; Sun, 22 Feb 2026 18:53:12 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'Q7An0jrvM+dNfciwna2yiqWjgRqw/7BqScHWA+OJ8P0=', expected b'5srKgSfgBzlP1vYQbIFRSYd7Vk4vfPVFAaaNWmL4TBA=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771778097; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=Q7An0jrvM+dNfciwna2yiqWjgRqw/7BqScHWA+OJ8P0=; b=lkKvUEN6Et36/ylnTX7bT4jpEnAmyLdJjHiljjBAjOwTqVFnAM0rsDvoTsY8BA4BxOJkC fFX762sgYoZEt/84Ob/aJ+02Rg+0KcDuDZsQ4OWoCG971RsOiZ0QTb+eNZFXWoL0n0ke898 /7U4JXAUr/dABnqGbBXQRmt5w87D4oJWacmTR2mRs1LRRqPy2D/Q0pVcRh2r1QguRSMxVXB fWQG0hu0fr52IBWniXfmiXHewi7SYXXfFYW6mDpby9SNdZq3GjE9gS6yj0UjfiG8VYRIL9W E2X9zkMQMln9WiAyiLLdi0rb6x33xoBJFdml0A0BUHfuegy/OcykVaf/TKyg== Received: from [172.18.0.3] (unknown [172.18.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 7985C6912FE; Sun, 22 Feb 2026 18:34:57 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771778085; b=Y5Pgo6jNoXQMNAUvBDKBof5FJxC32MGwBuG6FWRMlsD/5tPjx1rZhkGBZ5VWEw+o+FxIi diaBaCu2P1p26IMCyEYYhv1cKnzxlNLL7aMhbrlew2BySilH+ptt6MGz1rSzZZAlBSdJ2tH mvdgvbEVzCMt63YMz4/zoKgZrKBZcNYulskaRNzNWqA5bsktcXrEFilFzCP7QYYFdKyLgV9 ebxu9s9fPGoSMz3WNu8OR9Q399rCVgsFTxGLPJ1OIBwDJSwsoUYsQaW/uZ1TD6DPOxj7RtM p6ct9xTbPdxKuiGd68JNk2XIyAKWY4J1TjNmEAQabXRdNUXUyuE97E8E553A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771778085; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=tElaYTKAomMGIgCMV2mXTArzkQY/lvR8Boq2nqJkOFY=; b=FYAEvT11azIU+Zn6R63EO9Ll8gFh/sVKh6hG1h0kUzGEUBH+V9Kplv/eAsoGX5+pjI8BS Y3NirrN4gUBrO4Qw26mNOXU/6slI+5xw18psiURSJFKrS2WJ9TTynSkyUTgDI/FtIcstyuw He4n17yu2oGAHhrdH1548D5VhPZXV6YrjS0IgJJoQLlFGRCodl2z7jPVJmk5d99H7M7nqWu scyzfGo2EgAiG47hIJ8a62W6Sjho/b/NYsD9A0ZhZq4I7178Vx6ls3VAhIYqjOqXMDUBklg 4/L/Hul/4RujvzBkOYKGB6HlPnRjsUuxvJZ53fY1uZ2Oc6svOUYE9RIIthtw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771778077; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=5srKgSfgBzlP1vYQbIFRSYd7Vk4vfPVFAaaNWmL4TBA=; b=cXmTpEzs076BzkYpK1nxHrW9nw7+Uk83AkXbBJSXtNd2LgAMz3SckEdFaoWMYkyZH7NPm 8nN2ZA+VJloSlWvRX8yZ8HDkbBvyu+KNI6nTYox6ykLg4wScoRvmCcgnOB806myA12keu1y qch289FgNrDa0nXWdCsQzg1XN4ZcySPuV4y44MP2ZbjL3P3VCWYNTdJ/A4o/tWmXLyozSVl En0lT6jkvCVcbRVYAMuxKQQtybgcLyyru4e4RcfzI71Jaa90hbnYqL8//Um0ZwmZKNP9avG Q93ewzrWmw8Omb8dejZIFjyn1mgT8/5YPYFNQuELgmLAAedzwEc5Dqf/SoxQ== MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Sun, 22 Feb 2026 16:34:36 -0000 Message-ID: <177177807714.25.12190959235617700830@29965ddac10e> Message-ID-Hash: WKA2QEBK7DRA4GJ7GMAEV7RY4H2PLWGN X-Message-ID-Hash: WKA2QEBK7DRA4GJ7GMAEV7RY4H2PLWGN X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] avfilter/dnn: standardize Torch backend options (PR #22257) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Raja-89 via ffmpeg-devel Cc: Raja-89 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #22257 opened by Raja-89 URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22257 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/22257.patch ## avfilter/dnn: standardize Torch backend options This PR aligns the Torch backend option handling with TensorFlow and OpenVINO backends. ### Problem The `optimize` flag existed in the Torch backend but was not accessible to users via command line. ### Solution - Fixed OFFSET macro to properly reference nested struct - Exposed the `optimize` option in vf_dnn_processing.c - Fixed missing `.unit` parameter for proper option grouping ### Usage ```bash ffmpeg -vf dnn_processing=dnn_backend=torch:model=model.pt:optimize=1 >>From a62b7fde9f4558582c64d405d82cb4838e484f5c Mon Sep 17 00:00:00 2001 From: Raja-89 Date: Sun, 22 Feb 2026 21:42:38 +0530 Subject: [PATCH] avfilter/dnn: standardize Torch backend options This patch aligns the Torch backend option handling with TensorFlow and OpenVINO backends, making options accessible via command-line interface. Changes in libavfilter/dnn/dnn_backend_torch.cpp: - Fix OFFSET macro to use proper nested struct syntax: offsetof(DnnContext, torch_option.x) instead of the incorrect pointer arithmetic - Rename options array from dnn_th_options to dnn_torch_options for consistency - Update DNN_DEFINE_CLASS to use dnn_torch to match the new options array name Changes in libavfilter/vf_dnn_processing.c: - Fix missing .unit parameter in torch backend flag (was "backend", now .unit = "backend") to properly group the option with other backend choices - Add user-facing 'optimize' option that maps to DnnContext.torch_option.optimize, enabling command-line control like :optimize=1 Before this patch, the optimize flag existed in the backend but was not accessible to users. Now users can control graph executor optimization from the command line: ffmpeg -vf dnn_processing=dnn_backend=torch:model=model.pt:optimize=1 This standardization improves consistency across DNN backends and follows the same pattern used by TensorFlow and OpenVINO backends. Tested with: - Compilation: No errors or warnings - Help output: ./ffmpeg -h filter=dnn_processing shows optimize option - Option parsing: Verified with -v debug that optimize=1 is correctly set - Runtime: Confirmed the flag reaches the backend and controls torch::jit::setGraphExecutorOptimize() Signed-off-by: Raja Rathour --- libavfilter/dnn/dnn_backend_torch.cpp | 6 +++--- libavfilter/vf_dnn_processing.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp index d3c4966c09..be765ed4b7 100644 --- a/libavfilter/dnn/dnn_backend_torch.cpp +++ b/libavfilter/dnn/dnn_backend_torch.cpp @@ -65,9 +65,9 @@ typedef struct THRequestItem { } THRequestItem; -#define OFFSET(x) offsetof(THOptions, x) +#define OFFSET(x) offsetof(DnnContext, torch_option.x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM -static const AVOption dnn_th_options[] = { +static const AVOption dnn_torch_options[] = { { "optimize", "turn on graph executor optimization", OFFSET(optimize), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS}, { NULL } }; @@ -667,7 +667,7 @@ static int dnn_flush_th(const DNNModel *model) } extern const DNNModule ff_dnn_backend_torch = { - .clazz = DNN_DEFINE_CLASS(dnn_th), + .clazz = DNN_DEFINE_CLASS(dnn_torch), .type = DNN_TH, .load_model = dnn_load_model_th, .execute_model = dnn_execute_model_th, diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c index 0771ceb5fc..d7e453355f 100644 --- a/libavfilter/vf_dnn_processing.c +++ b/libavfilter/vf_dnn_processing.c @@ -51,7 +51,10 @@ static const AVOption dnn_processing_options[] = { { "openvino", "openvino backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = DNN_OV }, 0, 0, FLAGS, .unit = "backend" }, #endif #if (CONFIG_LIBTORCH == 1) - { "torch", "torch backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = DNN_TH }, 0, 0, FLAGS, "backend" }, + { "torch", "torch backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = DNN_TH }, 0, 0, FLAGS, .unit = "backend" }, +#endif +#if (CONFIG_LIBTORCH == 1) + { "optimize", "enable graph executor optimization (torch backend)", OFFSET(torch_option.optimize), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, #endif { NULL } }; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org