From: Daniel Bevenius Date: Fri, 21 Mar 2025 08:53:26 +0000 (+0100) Subject: whisper : add check for CPU backend initialization (#2918) X-Git-Tag: upstream/1.7.5~123 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=be9de811717f3072ce485922a83b6ac92df96f52;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp whisper : add check for CPU backend initialization (#2918) This commit adds a check for the CPU backend initialization in the whisper library. If the initialization fails, an exception is thrown. The motivation for this change is to make the library more robust and handle the case when the CPU backend initialization fails. Resolves: https://github.com/ggerganov/whisper.cpp/issues/2917 --- diff --git a/src/whisper.cpp b/src/whisper.cpp index 2c535cfd..1fcb670e 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -1355,7 +1355,11 @@ static std::vector whisper_backend_init(const whisper_context_pa GGML_UNUSED(params); - result.push_back(ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr)); + ggml_backend_t backend_cpu = ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr); + if (backend_cpu == nullptr) { + throw std::runtime_error("failed to initialize CPU backend"); + } + result.push_back(backend_cpu); return result; }