From 5ecdafd60b81d0e80b13f897b8a69d7f8d618b3d Mon Sep 17 00:00:00 2001 From: Aleksandras Kostarevas <aleks076@protonmail.com> Date: Sat, 30 Mar 2024 18:45:54 -0500 Subject: [PATCH] Ensure conv graph measurement never undermeasures memory with dynamic audio ctx --- native/jni/src/ggml/whisper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/jni/src/ggml/whisper.cpp b/native/jni/src/ggml/whisper.cpp index 7e522e84a..a7a7f0695 100644 --- a/native/jni/src/ggml/whisper.cpp +++ b/native/jni/src/ggml/whisper.cpp @@ -1738,7 +1738,7 @@ static struct ggml_cgraph * whisper_build_graph_conv( // convolution + gelu { cur = ggml_conv_1d_ph(ctx0, model.e_conv_1_w, mel, 1, 1); - if (n_ctx == hparams.n_audio_ctx) { + if (!ggml_allocr_is_measure(alloc) && n_ctx == hparams.n_audio_ctx) { cur = ggml_add(ctx0, cur, model.e_conv_1_b); } else { cur = ggml_add(ctx0, cur, ggml_cont(ctx0, ggml_view_2d(ctx0, model.e_conv_1_b, cur->ne[0], cur->ne[1], model.e_conv_1_b->nb[1], 0))); @@ -1747,7 +1747,7 @@ static struct ggml_cgraph * whisper_build_graph_conv( cur = ggml_gelu(ctx0, cur); cur = ggml_conv_1d_ph(ctx0, model.e_conv_2_w, cur, 2, 1); - if (n_ctx == hparams.n_audio_ctx) { + if (!ggml_allocr_is_measure(alloc) && n_ctx == hparams.n_audio_ctx) { cur = ggml_add(ctx0, cur, model.e_conv_2_b); } else { cur = ggml_add(ctx0, cur, ggml_cont(ctx0, ggml_view_2d(ctx0, model.e_conv_2_b, cur->ne[0], cur->ne[1], model.e_conv_2_b->nb[1], 0)));