Skip to content

Commit e09ccea

Browse files
danbevlinxiaodong
authored and
linxiaodong
committed
whisper : add check for CPU backend initialization (ggml-org#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: ggml-org#2917
1 parent 58af509 commit e09ccea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/whisper.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,11 @@ static std::vector<ggml_backend_t> whisper_backend_init(const whisper_context_pa
13551355

13561356
GGML_UNUSED(params);
13571357

1358-
result.push_back(ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr));
1358+
ggml_backend_t backend_cpu = ggml_backend_init_by_type(GGML_BACKEND_DEVICE_TYPE_CPU, nullptr);
1359+
if (backend_cpu == nullptr) {
1360+
throw std::runtime_error("failed to initialize CPU backend");
1361+
}
1362+
result.push_back(backend_cpu);
13591363

13601364
return result;
13611365
}

0 commit comments

Comments
 (0)