Sandro Hanea Sandro Hanea commited on
Commit
6d5166f
·
unverified ·
1 Parent(s): 1b81cb9

whisper : add OpenVINO init with state (#2464)

Browse files

* Fixed OpenVino init on state

* Removed an empty line

* Fixed typo

* Replaced tabs with spaces

---------

Co-authored-by: Sandro Hanea <[email protected]>

Files changed (2) hide show
  1. include/whisper.h +7 -0
  2. src/whisper.cpp +13 -3
include/whisper.h CHANGED
@@ -238,6 +238,13 @@ extern "C" {
238
  // GPU, by caching compiled 'blobs' there.
239
  // Set to nullptr if not used.
240
  // Returns 0 on success. If OpenVINO is not enabled in build, this simply returns 1.
 
 
 
 
 
 
 
241
  WHISPER_API int whisper_ctx_init_openvino_encoder(
242
  struct whisper_context * ctx,
243
  const char * model_path,
 
238
  // GPU, by caching compiled 'blobs' there.
239
  // Set to nullptr if not used.
240
  // 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
+
248
  WHISPER_API int whisper_ctx_init_openvino_encoder(
249
  struct whisper_context * ctx,
250
  const char * model_path,
src/whisper.cpp CHANGED
@@ -3492,13 +3492,15 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) {
3492
  return state;
3493
  }
3494
 
3495
- int whisper_ctx_init_openvino_encoder(
3496
  struct whisper_context * ctx,
 
3497
  const char * model_path,
3498
  const char * device,
3499
  const char * cache_dir) {
3500
  #ifndef WHISPER_USE_OPENVINO
3501
  (void)(ctx);
 
3502
  (void)(model_path);
3503
  (void)(device);
3504
  (void)(cache_dir);
@@ -3529,8 +3531,8 @@ int whisper_ctx_init_openvino_encoder(
3529
  WHISPER_LOG_INFO("%s: loading OpenVINO model from '%s'\n", __func__, path_encoder.c_str());
3530
  WHISPER_LOG_INFO("%s: first run on a device may take a while ...\n", __func__);
3531
 
3532
- ctx->state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str());
3533
- if (!ctx->state->ctx_openvino) {
3534
  WHISPER_LOG_ERROR("%s: failed to init OpenVINO encoder from '%s'\n", __func__, path_encoder.c_str());
3535
  return 1;
3536
  } else {
@@ -3541,6 +3543,14 @@ int whisper_ctx_init_openvino_encoder(
3541
  #endif
3542
  }
3543
 
 
 
 
 
 
 
 
 
3544
  struct whisper_context_params whisper_context_default_params() {
3545
  struct whisper_context_params result = {
3546
  /*.use_gpu =*/ true,
 
3492
  return state;
3493
  }
3494
 
3495
+ int whisper_ctx_init_openvino_encoder_with_state(
3496
  struct whisper_context * ctx,
3497
+ struct whisper_state * state,
3498
  const char * model_path,
3499
  const char * device,
3500
  const char * cache_dir) {
3501
  #ifndef WHISPER_USE_OPENVINO
3502
  (void)(ctx);
3503
+ (void)(state);
3504
  (void)(model_path);
3505
  (void)(device);
3506
  (void)(cache_dir);
 
3531
  WHISPER_LOG_INFO("%s: loading OpenVINO model from '%s'\n", __func__, path_encoder.c_str());
3532
  WHISPER_LOG_INFO("%s: first run on a device may take a while ...\n", __func__);
3533
 
3534
+ state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str());
3535
+ if (!state->ctx_openvino) {
3536
  WHISPER_LOG_ERROR("%s: failed to init OpenVINO encoder from '%s'\n", __func__, path_encoder.c_str());
3537
  return 1;
3538
  } else {
 
3543
  #endif
3544
  }
3545
 
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
+
3554
  struct whisper_context_params whisper_context_default_params() {
3555
  struct whisper_context_params result = {
3556
  /*.use_gpu =*/ true,