mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2024-11-07 08:34:37 +01:00
whisper : add OpenVINO init with state (#2464)
* Fixed OpenVino init on state * Removed an empty line * Fixed typo * Replaced tabs with spaces --------- Co-authored-by: Sandro Hanea <sandrohanea@users.noreply.github.com>
This commit is contained in:
parent
ebca09a3d1
commit
fdbfb460ed
@ -238,6 +238,13 @@ extern "C" {
|
|||||||
// GPU, by caching compiled 'blobs' there.
|
// GPU, by caching compiled 'blobs' there.
|
||||||
// Set to nullptr if not used.
|
// Set to nullptr if not used.
|
||||||
// Returns 0 on success. If OpenVINO is not enabled in build, this simply returns 1.
|
// 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(
|
WHISPER_API int whisper_ctx_init_openvino_encoder(
|
||||||
struct whisper_context * ctx,
|
struct whisper_context * ctx,
|
||||||
const char * model_path,
|
const char * model_path,
|
||||||
|
@ -3492,13 +3492,15 @@ struct whisper_state * whisper_init_state(whisper_context * ctx) {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
int whisper_ctx_init_openvino_encoder(
|
int whisper_ctx_init_openvino_encoder_with_state(
|
||||||
struct whisper_context * ctx,
|
struct whisper_context * ctx,
|
||||||
|
struct whisper_state * state,
|
||||||
const char * model_path,
|
const char * model_path,
|
||||||
const char * device,
|
const char * device,
|
||||||
const char * cache_dir) {
|
const char * cache_dir) {
|
||||||
#ifndef WHISPER_USE_OPENVINO
|
#ifndef WHISPER_USE_OPENVINO
|
||||||
(void)(ctx);
|
(void)(ctx);
|
||||||
|
(void)(state);
|
||||||
(void)(model_path);
|
(void)(model_path);
|
||||||
(void)(device);
|
(void)(device);
|
||||||
(void)(cache_dir);
|
(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: 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__);
|
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());
|
state->ctx_openvino = whisper_openvino_init(path_encoder.c_str(), device, path_cache.c_str());
|
||||||
if (!ctx->state->ctx_openvino) {
|
if (!state->ctx_openvino) {
|
||||||
WHISPER_LOG_ERROR("%s: failed to init OpenVINO encoder from '%s'\n", __func__, path_encoder.c_str());
|
WHISPER_LOG_ERROR("%s: failed to init OpenVINO encoder from '%s'\n", __func__, path_encoder.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
@ -3541,6 +3543,14 @@ int whisper_ctx_init_openvino_encoder(
|
|||||||
#endif
|
#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 whisper_context_default_params() {
|
||||||
struct whisper_context_params result = {
|
struct whisper_context_params result = {
|
||||||
/*.use_gpu =*/ true,
|
/*.use_gpu =*/ true,
|
||||||
|
Loading…
Reference in New Issue
Block a user