whisper.rn 0.4.0-rc.4 → 0.4.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/android/build.gradle +4 -0
- package/android/src/main/CMakeLists.txt +5 -0
- package/android/src/main/java/com/rnwhisper/AudioUtils.java +0 -80
- package/android/src/main/java/com/rnwhisper/WhisperContext.java +57 -134
- package/android/src/main/jni-utils.h +76 -0
- package/android/src/main/jni.cpp +188 -112
- package/cpp/README.md +1 -1
- package/cpp/coreml/whisper-encoder-impl.h +1 -1
- package/cpp/coreml/whisper-encoder.h +4 -0
- package/cpp/coreml/whisper-encoder.mm +4 -2
- package/cpp/ggml-alloc.c +55 -19
- package/cpp/ggml-alloc.h +8 -1
- package/cpp/ggml-backend-impl.h +46 -21
- package/cpp/ggml-backend.c +563 -156
- package/cpp/ggml-backend.h +62 -17
- package/cpp/ggml-impl.h +1 -1
- package/cpp/ggml-metal-whisper.metal +2444 -359
- package/cpp/ggml-metal.h +7 -1
- package/cpp/ggml-metal.m +1105 -197
- package/cpp/ggml-quants.c +66 -61
- package/cpp/ggml-quants.h +40 -40
- package/cpp/ggml.c +1040 -1590
- package/cpp/ggml.h +109 -30
- package/cpp/rn-audioutils.cpp +68 -0
- package/cpp/rn-audioutils.h +14 -0
- package/cpp/rn-whisper-log.h +11 -0
- package/cpp/rn-whisper.cpp +143 -59
- package/cpp/rn-whisper.h +48 -15
- package/cpp/whisper.cpp +1635 -928
- package/cpp/whisper.h +55 -10
- package/ios/RNWhisper.mm +7 -7
- package/ios/RNWhisperAudioUtils.h +0 -2
- package/ios/RNWhisperAudioUtils.m +0 -56
- package/ios/RNWhisperContext.h +3 -11
- package/ios/RNWhisperContext.mm +68 -137
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/index.ts +5 -0
- package/src/version.json +1 -1
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -4
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RNWhisper.xcodeproj/project.xcworkspace/xcuserdata/jhen.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNWhisper.xcodeproj/xcuserdata/jhen.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
package/cpp/ggml-backend-impl.h
CHANGED
|
@@ -12,31 +12,50 @@ extern "C" {
|
|
|
12
12
|
// Backend buffer
|
|
13
13
|
//
|
|
14
14
|
|
|
15
|
+
// buffer type
|
|
16
|
+
typedef void * wsp_ggml_backend_buffer_type_context_t;
|
|
17
|
+
|
|
18
|
+
struct wsp_ggml_backend_buffer_type_i {
|
|
19
|
+
wsp_ggml_backend_buffer_t (*alloc_buffer) (wsp_ggml_backend_buffer_type_t buft, size_t size);
|
|
20
|
+
size_t (*get_alignment) (wsp_ggml_backend_buffer_type_t buft); // tensor alignment
|
|
21
|
+
size_t (*get_alloc_size) (wsp_ggml_backend_buffer_type_t buft, struct wsp_ggml_tensor * tensor); // data size needed to allocate the tensor, including padding
|
|
22
|
+
bool (*supports_backend)(wsp_ggml_backend_buffer_type_t buft, wsp_ggml_backend_t backend); // check if the buffer type is usable by the backend
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
struct wsp_ggml_backend_buffer_type {
|
|
26
|
+
struct wsp_ggml_backend_buffer_type_i iface;
|
|
27
|
+
wsp_ggml_backend_buffer_type_context_t context;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// buffer
|
|
15
31
|
typedef void * wsp_ggml_backend_buffer_context_t;
|
|
16
32
|
|
|
17
33
|
struct wsp_ggml_backend_buffer_i {
|
|
18
|
-
void
|
|
19
|
-
void
|
|
20
|
-
|
|
21
|
-
void
|
|
22
|
-
void
|
|
34
|
+
void (*free_buffer)(wsp_ggml_backend_buffer_t buffer);
|
|
35
|
+
//void (*reset) (wsp_ggml_backend_buffer_t buffer); // reset any internal state due to tensor initialization, such as tensor extras
|
|
36
|
+
void * (*get_base) (wsp_ggml_backend_buffer_t buffer);
|
|
37
|
+
void (*init_tensor)(wsp_ggml_backend_buffer_t buffer, struct wsp_ggml_tensor * tensor);
|
|
38
|
+
void (*set_tensor) (wsp_ggml_backend_buffer_t buffer, struct wsp_ggml_tensor * tensor, const void * data, size_t offset, size_t size);
|
|
39
|
+
void (*get_tensor) (wsp_ggml_backend_buffer_t buffer, const struct wsp_ggml_tensor * tensor, void * data, size_t offset, size_t size);
|
|
40
|
+
// (optional) copy tensor between different buffer-type, allow for single-copy tranfers
|
|
41
|
+
void (*cpy_tensor_from)(wsp_ggml_backend_buffer_t buffer, struct wsp_ggml_tensor * src, struct wsp_ggml_tensor * dst);
|
|
42
|
+
void (*cpy_tensor_to) (wsp_ggml_backend_buffer_t buffer, struct wsp_ggml_tensor * src, struct wsp_ggml_tensor * dst);
|
|
23
43
|
};
|
|
24
44
|
|
|
25
45
|
struct wsp_ggml_backend_buffer {
|
|
26
|
-
struct wsp_ggml_backend_buffer_i
|
|
27
|
-
|
|
28
|
-
wsp_ggml_backend_t backend;
|
|
46
|
+
struct wsp_ggml_backend_buffer_i iface;
|
|
47
|
+
wsp_ggml_backend_buffer_type_t buft;
|
|
29
48
|
wsp_ggml_backend_buffer_context_t context;
|
|
30
|
-
|
|
31
49
|
size_t size;
|
|
32
50
|
};
|
|
33
51
|
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
wsp_ggml_backend_buffer_t wsp_ggml_backend_buffer_init(
|
|
53
|
+
wsp_ggml_backend_buffer_type_t buft,
|
|
36
54
|
struct wsp_ggml_backend_buffer_i iface,
|
|
37
55
|
wsp_ggml_backend_buffer_context_t context,
|
|
38
56
|
size_t size);
|
|
39
57
|
|
|
58
|
+
|
|
40
59
|
//
|
|
41
60
|
// Backend
|
|
42
61
|
//
|
|
@@ -49,20 +68,17 @@ extern "C" {
|
|
|
49
68
|
void (*free)(wsp_ggml_backend_t backend);
|
|
50
69
|
|
|
51
70
|
// buffer allocation
|
|
52
|
-
|
|
71
|
+
wsp_ggml_backend_buffer_type_t (*get_default_buffer_type)(wsp_ggml_backend_t backend);
|
|
53
72
|
|
|
54
|
-
//
|
|
55
|
-
size_t (*get_alignment)(wsp_ggml_backend_t backend);
|
|
56
|
-
|
|
57
|
-
// tensor data access
|
|
58
|
-
// these functions can be asynchronous, helper functions are provided for synchronous access that automatically call synchronize
|
|
73
|
+
// (optional) asynchroneous tensor data access
|
|
59
74
|
void (*set_tensor_async)(wsp_ggml_backend_t backend, struct wsp_ggml_tensor * tensor, const void * data, size_t offset, size_t size);
|
|
60
75
|
void (*get_tensor_async)(wsp_ggml_backend_t backend, const struct wsp_ggml_tensor * tensor, void * data, size_t offset, size_t size);
|
|
61
|
-
void (*synchronize) (wsp_ggml_backend_t backend);
|
|
62
76
|
|
|
63
|
-
// (optional)
|
|
64
|
-
void (*
|
|
65
|
-
void (*
|
|
77
|
+
// (optional) asynchroneous tensor copy
|
|
78
|
+
void (*cpy_tensor_from_async)(wsp_ggml_backend_t backend, struct wsp_ggml_tensor * src, struct wsp_ggml_tensor * dst);
|
|
79
|
+
void (*cpy_tensor_to_async) (wsp_ggml_backend_t backend, struct wsp_ggml_tensor * src, struct wsp_ggml_tensor * dst);
|
|
80
|
+
|
|
81
|
+
void (*synchronize) (wsp_ggml_backend_t backend);
|
|
66
82
|
|
|
67
83
|
// compute graph with a plan
|
|
68
84
|
wsp_ggml_backend_graph_plan_t (*graph_plan_create) (wsp_ggml_backend_t backend, struct wsp_ggml_cgraph * cgraph);
|
|
@@ -82,6 +98,15 @@ extern "C" {
|
|
|
82
98
|
wsp_ggml_backend_context_t context;
|
|
83
99
|
};
|
|
84
100
|
|
|
101
|
+
|
|
102
|
+
//
|
|
103
|
+
// Backend registry
|
|
104
|
+
//
|
|
105
|
+
|
|
106
|
+
typedef wsp_ggml_backend_t (*wsp_ggml_backend_init_fn)(const char * params, void * user_data);
|
|
107
|
+
|
|
108
|
+
void wsp_ggml_backend_register(const char * name, wsp_ggml_backend_init_fn init_fn, wsp_ggml_backend_buffer_type_t default_buffer_type, void * user_data);
|
|
109
|
+
|
|
85
110
|
#ifdef __cplusplus
|
|
86
111
|
}
|
|
87
112
|
#endif
|