Skip to content

Commit a42be6c

Browse files
sandrohanealiuyang.marshall
authored andcommitted
whisper : add OpenVINO init with state (ggml-org#2464)
* Fixed OpenVino init on state * Removed an empty line * Fixed typo * Replaced tabs with spaces --------- Co-authored-by: Sandro Hanea <[email protected]>
1 parent d390a2e commit a42be6c

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

include/whisper.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ extern "C" {
238238
// GPU, by caching compiled 'blobs' there.
239239
// Set to nullptr if not used.
240240
// Returns 0 on success. If OpenVINO is not enabled in build, this simply returns 1.
241+
WHISPER_API int whisper_ctx_init_openvino_encoder_with_state(
242+
struct whisper_context * ctx,
243+
struct whisper_state * state,
244+
const char * model_path,
245+
const char * device,
246+
const char * cache_dir);
247+
241248
WHISPER_API int whisper_ctx_init_openvino_encoder(
242249
struct whisper_context * ctx,
243250
const char * model_path,

src/whisper.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3492,13 +3492,15 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) {
34923492
return state;
34933493
}
34943494

3495-
int whisper_ctx_init_openvino_encoder(
3495+
int whisper_ctx_init_openvino_encoder_with_state(
34963496
struct whisper_context * ctx,
3497+
struct whisper_state * state,
34973498
const char * model_path,
34983499
const char * device,
34993500
const char * cache_dir) {
35003501
#ifndef WHISPER_USE_OPENVINO
35013502
(void)(ctx);
3503+
(void)(state);
35023504
(void)(model_path);
35033505
(void)(device);
35043506
(void)(cache_dir);
@@ -3529,8 +3531,8 @@ int whisper_ctx_init_openvino_encoder(
35293531
WHISPER_LOG_INFO("%s: loading OpenVINO model from '%s'\n", __func__, path_encoder.c_str());
35303532
WHISPER_LOG_INFO("%s: first run on a device may take a while ...\n", __func__);
35313533

3532-
ctx->state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str());
3533-
if (!ctx->state->ctx_openvino) {
3534+
state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str());
3535+
if (!state->ctx_openvino) {
35343536
WHISPER_LOG_ERROR("%s: failed to init OpenVINO encoder from '%s'\n", __func__, path_encoder.c_str());
35353537
return 1;
35363538
} else {
@@ -3541,6 +3543,14 @@ int whisper_ctx_init_openvino_encoder(
35413543
#endif
35423544
}
35433545

3546+
int whisper_ctx_init_openvino_encoder(
3547+
struct whisper_context * ctx,
3548+
const char * model_path,
3549+
const char * device,
3550+
const char * cache_dir) {
3551+
return whisper_ctx_init_openvino_encoder_with_state(ctx, ctx->state, model_path, device, cache_dir);
3552+
}
3553+
35443554
struct whisper_context_params whisper_context_default_params() {
35453555
struct whisper_context_params result = {
35463556
/*.use_gpu =*/ true,

0 commit comments

Comments
 (0)