* [FFmpeg-devel] [PATCH v2 FFmpeg 12/20] libavfilter/dnn/dnn_backend_torch: Add ClxpContext to THModel
@ 2025-03-10 19:54 m.kaindl0208
0 siblings, 0 replies; only message in thread
From: m.kaindl0208 @ 2025-03-10 19:54 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: MaximilianKaindl <m.kaindl0208@gmail.com>
---
libavfilter/dnn/dnn_backend_torch.cpp | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/libavfilter/dnn/dnn_backend_torch.cpp b/libavfilter/dnn/dnn_backend_torch.cpp
index 062821949d..ea09845e05 100644
--- a/libavfilter/dnn/dnn_backend_torch.cpp
+++ b/libavfilter/dnn/dnn_backend_torch.cpp
@@ -39,6 +39,13 @@ extern "C" {
#include <c10/cuda/CUDAStream.h>
#endif
+typedef struct THClxpContext {
+ torch::Tensor *tokenized_text;
+ torch::Tensor *attention_mask;
+ int *softmax_units;
+ int softmax_units_count;
+} THClxpContext;
+
typedef struct THModel {
DNNModel model;
DnnContext *ctx;
@@ -46,6 +53,7 @@ typedef struct THModel {
SafeQueue *request_queue;
Queue *task_queue;
Queue *lltask_queue;
+ THClxpContext *clxp_ctx;
} THModel;
typedef struct THInferRequest {
@@ -116,6 +124,21 @@ static inline void destroy_request_item(THRequestItem **arg)
av_freep(arg);
}
+static void free_clxp_context(THClxpContext *clxp_ctx)
+{
+ if (!clxp_ctx)
+ return;
+ if (clxp_ctx->tokenized_text) {
+ delete clxp_ctx->tokenized_text;
+ clxp_ctx->tokenized_text = nullptr;
+ }
+ if (clxp_ctx->attention_mask) {
+ delete clxp_ctx->attention_mask;
+ clxp_ctx->attention_mask = nullptr;
+ }
+ av_freep(&clxp_ctx);
+}
+
static void dnn_free_model_th(DNNModel **model)
{
THModel *th_model;
@@ -143,6 +166,9 @@ static void dnn_free_model_th(DNNModel **model)
}
ff_queue_destroy(th_model->task_queue);
delete th_model->jit_model;
+#if (CONFIG_LIBTOKENIZERS == 1)
+ free_clxp_context(th_model->clxp_ctx);
+#endif
av_freep(&th_model);
*model = NULL;
}
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-03-10 19:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 19:54 [FFmpeg-devel] [PATCH v2 FFmpeg 12/20] libavfilter/dnn/dnn_backend_torch: Add ClxpContext to THModel m.kaindl0208
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