From: <m.kaindl0208@gmail.com> To: <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH v2 FFmpeg 12/20] libavfilter/dnn/dnn_backend_torch: Add ClxpContext to THModel Date: Mon, 10 Mar 2025 20:54:37 +0100 Message-ID: <004001db91f6$40f45ba0$c2dd12e0$@gmail.com> (raw) 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".
reply other threads:[~2025-03-10 19:54 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='004001db91f6$40f45ba0$c2dd12e0$@gmail.com' \ --to=m.kaindl0208@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /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