Skip to content

Commit

Permalink
feat: sync whisper.cpp (enable ggml-alloc) (#123)
Browse files Browse the repository at this point in the history
* feat: test metal-and-alloc of whisper.cpp

* fix(ios): temp workaround for -fno-objc-arc

* fix(android): add ggml-alloc

* feat(ios): still use ARC for ggml-metal.m

* feat(example, ios): add extended virtual addressing entitlement

* feat: update whisper.cpp branch

* feat: update whisper.cpp branch

* feat: sync whisper.cpp

* feat(ios): temp disable metal

* feat(ios): use MLComputeUnitsAll by patch
  • Loading branch information
jhen0409 committed Oct 5, 2023
1 parent 309e1f2 commit 8a58082
Show file tree
Hide file tree
Showing 22 changed files with 11,089 additions and 3,712 deletions.
3 changes: 2 additions & 1 deletion android/src/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(RNWHISPER_LIB_DIR ${CMAKE_SOURCE_DIR}/../../../cpp)
set(
SOURCE_FILES
${RNWHISPER_LIB_DIR}/ggml.c
${RNWHISPER_LIB_DIR}/ggml-alloc.c
${RNWHISPER_LIB_DIR}/whisper.cpp
${RNWHISPER_LIB_DIR}/rn-whisper.cpp
${CMAKE_SOURCE_DIR}/jni.cpp
Expand All @@ -21,7 +22,7 @@ function(build_library target_name)
SHARED
${SOURCE_FILES}
)

target_link_libraries(${target_name} ${LOG_LIB} android)

if (${target_name} STREQUAL "whisper_v8fp16_va")
Expand Down
8 changes: 7 additions & 1 deletion cpp/coreml/whisper-encoder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@

NSURL * url_model = [NSURL fileURLWithPath: path_model_str];

const void * data = CFBridgingRetain([[whisper_encoder_impl alloc] initWithContentsOfURL:url_model error:nil]);
// select which device to run the Core ML model on
MLModelConfiguration *config = [[MLModelConfiguration alloc] init];
//config.computeUnits = MLComputeUnitsCPUAndGPU;
//config.computeUnits = MLComputeUnitsCPUAndNeuralEngine;
config.computeUnits = MLComputeUnitsAll;

const void * data = CFBridgingRetain([[whisper_encoder_impl alloc] initWithContentsOfURL:url_model configuration:config error:nil]);

if (data == NULL) {
return NULL;
Expand Down

0 comments on commit 8a58082

Please sign in to comment.