From 12030358ee852efd4ff155b0aaf0e5097cf8557c Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Fri, 10 Nov 2023 12:45:26 +0200 Subject: [PATCH] whisper : free backends + fix compile warning --- examples/common.h | 2 +- whisper.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/common.h b/examples/common.h index 9a94bab7..54f0b00d 100644 --- a/examples/common.h +++ b/examples/common.h @@ -181,7 +181,7 @@ private: // It is assumed that PCM data is normalized to a range from -1 to 1 bool write_audio(const float * data, size_t length) { for (size_t i = 0; i < length; ++i) { - const auto intSample = static_cast(data[i] * 32767); + const int16_t intSample = data[i] * 32767; file.write(reinterpret_cast(&intSample), sizeof(int16_t)); dataSize += sizeof(int16_t); } diff --git a/whisper.cpp b/whisper.cpp index d999e548..62d9af25 100644 --- a/whisper.cpp +++ b/whisper.cpp @@ -3276,6 +3276,12 @@ void whisper_free(struct whisper_context * ctx) { whisper_free_state(ctx->state); + ggml_backend_free(ctx->backend_cpu); + + if (ctx->backend_gpu) { + ggml_backend_free(ctx->backend_gpu); + } + delete ctx; } }