Skip to content

Commit

Permalink
feat: sync whisper.cpp & update patches & api usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Nov 19, 2024
1 parent b8cf5d8 commit fec8617
Show file tree
Hide file tree
Showing 21 changed files with 21,110 additions and 21,659 deletions.
1 change: 1 addition & 0 deletions 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-cpu.c
${RNWHISPER_LIB_DIR}/ggml-alloc.c
${RNWHISPER_LIB_DIR}/ggml-backend.cpp
${RNWHISPER_LIB_DIR}/ggml-quants.c
Expand Down
269 changes: 269 additions & 0 deletions cpp/ggml-aarch64.c

Large diffs are not rendered by default.

19 changes: 4 additions & 15 deletions cpp/ggml-backend-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
size_t (*get_max_size) (wsp_ggml_backend_buffer_type_t buft);
// (optional) data size needed to allocate the tensor, including padding (defaults to wsp_ggml_nbytes)
size_t (*get_alloc_size)(wsp_ggml_backend_buffer_type_t buft, const struct wsp_ggml_tensor * tensor);
// (optional) check if tensor data is in host memory (defaults to false)
// (optional) check if tensor data is in host memory and uses standard ggml tensor layout (defaults to false)
bool (*is_host) (wsp_ggml_backend_buffer_type_t buft);
};

Expand All @@ -37,7 +37,6 @@ extern "C" {
//

struct wsp_ggml_backend_buffer_i {
const char * (*get_name) (wsp_ggml_backend_buffer_t buffer);
// (optional) free the buffer
void (*free_buffer) (wsp_ggml_backend_buffer_t buffer);
// base address of the buffer
Expand Down Expand Up @@ -88,19 +87,16 @@ extern "C" {

void (*free)(wsp_ggml_backend_t backend);

// Will be moved to the device interface
// buffer allocation
wsp_ggml_backend_buffer_type_t (*get_default_buffer_type)(wsp_ggml_backend_t backend);

// (optional) asynchronous tensor data access
void (*set_tensor_async)(wsp_ggml_backend_t backend, struct wsp_ggml_tensor * tensor, const void * data, size_t offset, size_t size);
void (*get_tensor_async)(wsp_ggml_backend_t backend, const struct wsp_ggml_tensor * tensor, void * data, size_t offset, size_t size);
bool (*cpy_tensor_async)(wsp_ggml_backend_t backend_src, wsp_ggml_backend_t backend_dst, const struct wsp_ggml_tensor * src, struct wsp_ggml_tensor * dst);

// (optional) complete all pending operations
// (optional) complete all pending operations (required if the backend supports async operations)
void (*synchronize)(wsp_ggml_backend_t backend);

// (optional) compute graph with a plan (not used currently)
// (optional) graph plans (not used currently)
// compute graph with a plan
wsp_ggml_backend_graph_plan_t (*graph_plan_create) (wsp_ggml_backend_t backend, const struct wsp_ggml_cgraph * cgraph);
void (*graph_plan_free) (wsp_ggml_backend_t backend, wsp_ggml_backend_graph_plan_t plan);
// update the plan with a new graph - this should be faster than creating a new plan when the graph has the same topology
Expand All @@ -111,13 +107,6 @@ extern "C" {
// compute graph (always async if supported by the backend)
enum wsp_ggml_status (*graph_compute) (wsp_ggml_backend_t backend, struct wsp_ggml_cgraph * cgraph);

// IMPORTANT: these functions have been moved to the device interface and will be removed from the backend interface
// new backends should implement the device interface instead
// These functions are being moved to the device interface
bool (*supports_op) (wsp_ggml_backend_t backend, const struct wsp_ggml_tensor * op);
bool (*supports_buft)(wsp_ggml_backend_t backend, wsp_ggml_backend_buffer_type_t buft);
bool (*offload_op) (wsp_ggml_backend_t backend, const struct wsp_ggml_tensor * op);

// (optional) event synchronization
// record an event on this stream
void (*event_record)(wsp_ggml_backend_t backend, wsp_ggml_backend_event_t event);
Expand Down
Loading

0 comments on commit fec8617

Please sign in to comment.