danbev commited on
Commit
749d15b
·
unverified ·
1 Parent(s): e5e2e61

examples : add GGML_USE_CPU=ON flag to whisper.objc (#2880)

Browse files

This commit adds the GGML_USE_CPU=ON flag to the whisper.objc project in
order to enable the CPU backend for the whisper.objc project.

The motivation for this change is that currently the following error
is generated when running the example:
```console
ggml_backend_buffer_type_t ggml_backend_get_default_buffer_type(ggml_backend_t backend) {
return ggml_backend_dev_buffer_type(backend->device); <- Thread 1: EXC_BAD_ACCESS (code=1, address=0x70)
}
```
If we inspect the `backend` variable we can see that it is a `nullptr`.
```console
(lldb) p backend
(ggml_backend_t) nullptr
```
When running in a simulator and that automatically means that there will
be no gpu as there is a check for this in the code. But the CPU backend
should still be present.

The objective-c code will compile the whisper sources including the ggml
sources. And if `-DGGMLL_USE_CPU` is not defined then there will be no
CPU backend, and in this particular case of backend at all.

Resolves: https://github.com/ggerganov/whisper.cpp/issues/2870

examples/whisper.objc/whisper.objc.xcodeproj/project.pbxproj CHANGED
@@ -450,6 +450,7 @@
450
  );
451
  MARKETING_VERSION = 1.0;
452
  MTL_HEADER_SEARCH_PATHS = "";
 
453
  PRODUCT_BUNDLE_IDENTIFIER = "com.ggerganov.whisper-objc";
454
  PRODUCT_NAME = "$(TARGET_NAME)";
455
  SWIFT_EMIT_LOC_STRINGS = YES;
@@ -481,6 +482,7 @@
481
  );
482
  MARKETING_VERSION = 1.0;
483
  MTL_HEADER_SEARCH_PATHS = "";
 
484
  PRODUCT_BUNDLE_IDENTIFIER = "com.ggerganov.whisper-objc";
485
  PRODUCT_NAME = "$(TARGET_NAME)";
486
  SWIFT_EMIT_LOC_STRINGS = YES;
 
450
  );
451
  MARKETING_VERSION = 1.0;
452
  MTL_HEADER_SEARCH_PATHS = "";
453
+ OTHER_CFLAGS = "-DGGML_USE_CPU=ON";
454
  PRODUCT_BUNDLE_IDENTIFIER = "com.ggerganov.whisper-objc";
455
  PRODUCT_NAME = "$(TARGET_NAME)";
456
  SWIFT_EMIT_LOC_STRINGS = YES;
 
482
  );
483
  MARKETING_VERSION = 1.0;
484
  MTL_HEADER_SEARCH_PATHS = "";
485
+ OTHER_CFLAGS = "-DGGML_USE_CPU=ON";
486
  PRODUCT_BUNDLE_IDENTIFIER = "com.ggerganov.whisper-objc";
487
  PRODUCT_NAME = "$(TARGET_NAME)";
488
  SWIFT_EMIT_LOC_STRINGS = YES;