From e73efd54bd04471d7d52036d03981901525994be Mon Sep 17 00:00:00 2001 From: Sandro Hanea Date: Mon, 7 Oct 2024 20:57:12 +0200 Subject: [PATCH 1/4] Fixed OpenVino init on state --- include/whisper.h | 8 ++++++++ src/whisper.cpp | 16 +++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/whisper.h b/include/whisper.h index 375c1ebc139..933e39f6cb0 100644 --- a/include/whisper.h +++ b/include/whisper.h @@ -238,6 +238,14 @@ extern "C" { // GPU, by caching compiled 'blobs' there. // Set to nullptr if not used. // Returns 0 on success. If OpenVINO is not enabled in build, this simply returns 1. + + WHISPER_API int whisper_ctx_init_openvino_encoder_with_state( + struct whisper_context * ctx, + struct whisper_state * state, + const char * model_path, + const char * device, + const char * cache_dir); + WHISPER_API int whisper_ctx_init_openvino_encoder( struct whisper_context * ctx, const char * model_path, diff --git a/src/whisper.cpp b/src/whisper.cpp index 31c6861e43c..629cc3c7159 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -3492,13 +3492,15 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) { return state; } -int whisper_ctx_init_openvino_encoder( +int whisper_ctx_init_openvino_encoder_with_state( struct whisper_context * ctx, + struct whisper_sate * state, const char * model_path, const char * device, const char * cache_dir) { #ifndef WHISPER_USE_OPENVINO (void)(ctx); + (void)(state); (void)(model_path); (void)(device); (void)(cache_dir); @@ -3529,8 +3531,8 @@ int whisper_ctx_init_openvino_encoder( WHISPER_LOG_INFO("%s: loading OpenVINO model from '%s'\n", __func__, path_encoder.c_str()); WHISPER_LOG_INFO("%s: first run on a device may take a while ...\n", __func__); - ctx->state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str()); - if (!ctx->state->ctx_openvino) { + state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str()); + if (!state->ctx_openvino) { WHISPER_LOG_ERROR("%s: failed to init OpenVINO encoder from '%s'\n", __func__, path_encoder.c_str()); return 1; } else { @@ -3541,6 +3543,14 @@ int whisper_ctx_init_openvino_encoder( #endif } +int whisper_ctx_init_openvino_encoder( + struct whisper_context * ctx, + const char * model_path, + const char * device, + const char * cache_dir) { + return whisper_ctx_init_openvino_encoder_with_state(ctx, ctx->state, model_path, device, cache_dir); +} + struct whisper_context_params whisper_context_default_params() { struct whisper_context_params result = { /*.use_gpu =*/ true, From a77c131c49283ed89bb011ee7794d31b13351043 Mon Sep 17 00:00:00 2001 From: Sandro Hanea Date: Mon, 7 Oct 2024 20:58:28 +0200 Subject: [PATCH 2/4] Removed an empty line --- include/whisper.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/whisper.h b/include/whisper.h index 933e39f6cb0..cb53274fe4f 100644 --- a/include/whisper.h +++ b/include/whisper.h @@ -238,7 +238,6 @@ extern "C" { // GPU, by caching compiled 'blobs' there. // Set to nullptr if not used. // Returns 0 on success. If OpenVINO is not enabled in build, this simply returns 1. - WHISPER_API int whisper_ctx_init_openvino_encoder_with_state( struct whisper_context * ctx, struct whisper_state * state, From a4adcf839402638bc18775d5f3d44e077bc22d8c Mon Sep 17 00:00:00 2001 From: Sandro Hanea Date: Mon, 7 Oct 2024 21:04:35 +0200 Subject: [PATCH 3/4] Fixed typo --- src/whisper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/whisper.cpp b/src/whisper.cpp index 629cc3c7159..dd7fb409618 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -3494,7 +3494,7 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) { int whisper_ctx_init_openvino_encoder_with_state( struct whisper_context * ctx, - struct whisper_sate * state, + struct whisper_state * state, const char * model_path, const char * device, const char * cache_dir) { From 527771776dffa58b867ed77e3961007bde9e8e63 Mon Sep 17 00:00:00 2001 From: Sandro Hanea Date: Mon, 7 Oct 2024 21:08:21 +0200 Subject: [PATCH 4/4] Replaced tabs with spaces --- include/whisper.h | 4 ++-- src/whisper.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/whisper.h b/include/whisper.h index cb53274fe4f..320cac8c581 100644 --- a/include/whisper.h +++ b/include/whisper.h @@ -240,11 +240,11 @@ extern "C" { // Returns 0 on success. If OpenVINO is not enabled in build, this simply returns 1. WHISPER_API int whisper_ctx_init_openvino_encoder_with_state( struct whisper_context * ctx, - struct whisper_state * state, + struct whisper_state * state, const char * model_path, const char * device, const char * cache_dir); - + WHISPER_API int whisper_ctx_init_openvino_encoder( struct whisper_context * ctx, const char * model_path, diff --git a/src/whisper.cpp b/src/whisper.cpp index dd7fb409618..fedd471b495 100644 --- a/src/whisper.cpp +++ b/src/whisper.cpp @@ -3494,7 +3494,7 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) { int whisper_ctx_init_openvino_encoder_with_state( struct whisper_context * ctx, - struct whisper_state * state, + struct whisper_state * state, const char * model_path, const char * device, const char * cache_dir) { @@ -3548,7 +3548,7 @@ int whisper_ctx_init_openvino_encoder( const char * model_path, const char * device, const char * cache_dir) { - return whisper_ctx_init_openvino_encoder_with_state(ctx, ctx->state, model_path, device, cache_dir); + return whisper_ctx_init_openvino_encoder_with_state(ctx, ctx->state, model_path, device, cache_dir); } struct whisper_context_params whisper_context_default_params() {