Skip to content

Commit 0cc4f5e

Browse files
committed
Enable BINGINGS_FLAT in some examples
1 parent bb09c6f commit 0cc4f5e

File tree

8 files changed

+38
-9
lines changed

8 files changed

+38
-9
lines changed

examples/bench/bench.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "whisper.h"
22
#ifdef BINDINGS_FLAT
33
#include "whisper-flat.h"
4+
#include "../ggml/src/ggml-flat.h"
45
#endif
56

67
#include <cstdio>
@@ -65,7 +66,12 @@ static int whisper_bench_full(const whisper_params & params) {
6566
// whisper init
6667

6768
#ifdef BINDINGS_FLAT
68-
whisper_flat_backend_load_all();
69+
fprintf(stderr, "+++ BINDINGS_FLAT +++\n");
70+
if(params.use_gpu) {
71+
whisper_flat_backend_load_all();
72+
} else {
73+
ggml_backend_try_load_best("cpu", nullptr);
74+
}
6975
#endif
7076

7177
struct whisper_context_params cparams = whisper_context_default_params();

examples/cli/cli.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "whisper.h"
55
#ifdef BINDINGS_FLAT
66
#include "whisper-flat.h"
7+
#include "../ggml/src/ggml-flat.h"
78
#endif
89
#include "grammar-parser.h"
910

@@ -1008,7 +1009,12 @@ int main(int argc, char ** argv) {
10081009
// whisper init
10091010

10101011
#ifdef BINDINGS_FLAT
1011-
whisper_flat_backend_load_all();
1012+
fprintf(stderr, "+++ BINDINGS_FLAT +++\n");
1013+
if(params.use_gpu) {
1014+
whisper_flat_backend_load_all();
1015+
} else {
1016+
ggml_backend_try_load_best("cpu", nullptr);
1017+
}
10121018
#endif
10131019

10141020
struct whisper_context_params cparams = whisper_context_default_params();

examples/command/command.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "whisper.h"
1212
#ifdef BINDINGS_FLAT
1313
#include "whisper-flat.h"
14+
#include "../ggml/src/ggml-flat.h"
1415
#endif
1516
#include "grammar-parser.h"
1617

@@ -696,7 +697,12 @@ int main(int argc, char ** argv) {
696697
// whisper init
697698

698699
#ifdef BINDINGS_FLAT
699-
whisper_flat_backend_load_all();
700+
fprintf(stderr, "+++ BINDINGS_FLAT +++\n");
701+
if(params.use_gpu) {
702+
whisper_flat_backend_load_all();
703+
} else {
704+
ggml_backend_try_load_best("cpu", nullptr);
705+
}
700706
#endif
701707

702708
struct whisper_context_params cparams = whisper_context_default_params();

examples/server/server.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ int main(int argc, char ** argv) {
549549
}
550550
// whisper init
551551
#ifdef BINDINGS_FLAT
552+
fprintf(stderr, "+++ BINDINGS_FLAT +++\n");
552553
whisper_flat_backend_load_all();
553554
#endif
554555

examples/stream/stream.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "whisper.h"
99
#ifdef BINDINGS_FLAT
1010
#include "whisper-flat.h"
11+
#include "../ggml/src/ggml-flat.h"
1112
#endif
1213

1314
#include <chrono>
@@ -159,7 +160,12 @@ int main(int argc, char ** argv) {
159160
}
160161

161162
#ifdef BINDINGS_FLAT
162-
whisper_flat_backend_load_all();
163+
fprintf(stderr, "+++ BINDINGS_FLAT +++\n");
164+
if(params.use_gpu) {
165+
whisper_flat_backend_load_all();
166+
} else {
167+
ggml_backend_try_load_best("cpu", nullptr);
168+
}
163169
#endif
164170

165171
struct whisper_context_params cparams = whisper_context_default_params();

examples/talk-llama/talk-llama.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "whisper.h"
88
#ifdef BINDINGS_FLAT
99
#include "whisper-flat.h"
10+
#include "../ggml/src/ggml-flat.h"
1011
#endif
1112
#include "llama.h"
1213

@@ -291,7 +292,12 @@ int main(int argc, char ** argv) {
291292
// whisper init
292293

293294
#ifdef BINDINGS_FLAT
294-
whisper_flat_backend_load_all();
295+
fprintf(stderr, "+++ BINDINGS_FLAT +++\n");
296+
if(params.use_gpu) {
297+
whisper_flat_backend_load_all();
298+
} else {
299+
ggml_backend_try_load_best("cpu", nullptr);
300+
}
295301
#endif
296302

297303
struct whisper_context_params cparams = whisper_context_default_params();

ggml/src/ggml-backend-reg.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ struct dl_handle_deleter {
109109

110110
static dl_handle * dl_load_library(const fs::path & path) {
111111
// suppress error dialogs for missing DLLs
112-
#ifdef GGML_BINDINGS_FLAT // sbdbg
113-
fprintf(stderr, "dl_load_library()%s",path.wstring().c_str()); // sbdbg
114-
#endif // sbdbg
115112
DWORD old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
116113
SetErrorMode(old_mode | SEM_FAILCRITICALERRORS);
117114

@@ -595,7 +592,7 @@ void ggml_backend_load_all_from_path(const char * dir_path) {
595592
#ifdef GGML_BINDINGS_FLAT
596593
ggml_backend_reg_t ggml_backend_try_load_best(const char * name, const char * dir_path) {
597594
bool silent = true;
598-
fprintf(stderr, "Performing ggml_backend_try_load_best(%s)\n", name);
595+
fprintf(stderr, "%s: (%s)\n", __func__, name);
599596
return ggml_backend_load_best(name, silent, dir_path);
600597
}
601598
#endif

ggml/src/ggml-flat.h

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#ifdef BINDINGS_FLAT
4+
#define GGML_BINDINGS_FLAT
45
#endif
56

67
#ifdef GGML_SHARED

0 commit comments

Comments
 (0)