From c0277e3e11738049d023b9efddc1fda33ccc288f Mon Sep 17 00:00:00 2001 From: bobqianic <129547291+bobqianic@users.noreply.github.com> Date: Tue, 6 Feb 2024 15:42:25 +0000 Subject: [PATCH] revert logsumexp implementation --- whisper.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/whisper.cpp b/whisper.cpp index 54197e47f48..79e0e5eb092 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -4967,13 +4967,14 @@ static void whisper_process_logits( float timestamp_logprob = -INFINITY; { float logsumexp = 0.0f; + const float logprob_max = *std::max_element(logprobs.begin() + vocab.token_beg, logprobs.end()); for (int i = vocab.token_beg; i < n_logits; ++i) { if (logprobs[i] > -INFINITY) { - logsumexp += expf(logprobs[i]); + logsumexp += expf(logprobs[i] - logprob_max); } } if (logsumexp > 0.0f) { - timestamp_logprob = logf(logsumexp); + timestamp_logprob = logf(logsumexp) + logprob_max; } }