Skip to content

Commit

Permalink
fix(cpp): patch
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Oct 12, 2023
1 parent abad240 commit 598abbd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
4 changes: 3 additions & 1 deletion cpp/whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,6 @@ struct whisper_state {
std::string path_model; // populated by whisper_init_from_file()
#ifdef WHISPER_USE_COREML
whisper_coreml_context * ctx_coreml = nullptr;
bool load_coreml = true;
#endif

#ifdef WSP_GGML_USE_METAL
Expand Down Expand Up @@ -771,6 +770,9 @@ struct whisper_context {
whisper_state * state = nullptr;

std::string path_model; // populated by whisper_init_from_file()
#ifdef WHISPER_USE_COREML
bool load_coreml = true;
#endif
};

static void whisper_default_log(const char * text) {
Expand Down
34 changes: 18 additions & 16 deletions scripts/whisper.cpp.patch
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
--- whisper.cpp.orig 2023-10-12 10:40:07
+++ whisper.cpp 2023-10-12 10:38:11
@@ -738,6 +738,7 @@
--- whisper.cpp.orig 2023-10-12 11:44:51
+++ whisper.cpp 2023-10-12 11:43:31
@@ -770,6 +770,9 @@
whisper_state * state = nullptr;

std::string path_model; // populated by whisper_init_from_file()
#ifdef WHISPER_USE_COREML
whisper_coreml_context * ctx_coreml = nullptr;
+#ifdef WHISPER_USE_COREML
+ bool load_coreml = true;
#endif

#ifdef WSP_GGML_USE_METAL
@@ -2854,6 +2855,7 @@
+#endif
};

static void whisper_default_log(const char * text) {
@@ -2854,6 +2857,7 @@
}

#ifdef WHISPER_USE_COREML
+if (ctx->load_coreml) { // Not in correct layer for easy patch
const auto path_coreml = whisper_get_coreml_path_encoder(ctx->path_model);

log("%s: loading Core ML model from '%s'\n", __func__, path_coreml.c_str());
@@ -2869,6 +2871,7 @@
@@ -2869,6 +2873,7 @@
} else {
log("%s: Core ML model loaded\n", __func__);
}
+}
#endif

state->logits.reserve(ctx->vocab.n_vocab * ctx->model.hparams.n_text_ctx);
@@ -2987,7 +2990,24 @@
@@ -2987,7 +2992,24 @@
state->rng = std::mt19937(0);

return state;
+}
+
Expand All @@ -46,6 +48,6 @@
+ return ctx;
}
+#endif

int whisper_ctx_init_openvino_encoder(
struct whisper_context * ctx,

0 comments on commit 598abbd

Please sign in to comment.