whisper.rn 0.5.4 → 0.5.5

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.
Files changed (91) hide show
  1. package/android/src/main/java/com/rnwhisper/WhisperContext.java +5 -0
  2. package/android/src/main/jni.cpp +13 -0
  3. package/cpp/ggml-alloc.c +78 -26
  4. package/cpp/ggml-alloc.h +9 -0
  5. package/cpp/ggml-backend-impl.h +1 -1
  6. package/cpp/ggml-backend-reg.cpp +19 -3
  7. package/cpp/ggml-backend.cpp +72 -20
  8. package/cpp/ggml-backend.h +2 -1
  9. package/cpp/ggml-cpu/arch/arm/cpu-feats.cpp +4 -0
  10. package/cpp/ggml-cpu/arch/arm/repack.cpp +1004 -0
  11. package/cpp/ggml-cpu/arch/x86/repack.cpp +6 -6
  12. package/cpp/ggml-cpu/arch-fallback.h +50 -2
  13. package/cpp/ggml-cpu/ggml-cpu-impl.h +1 -1
  14. package/cpp/ggml-cpu/ggml-cpu.c +139 -58
  15. package/cpp/ggml-cpu/ggml-cpu.cpp +4 -0
  16. package/cpp/ggml-cpu/ops.cpp +170 -18
  17. package/cpp/ggml-cpu/ops.h +1 -0
  18. package/cpp/ggml-cpu/repack.cpp +531 -5
  19. package/cpp/ggml-cpu/repack.h +14 -0
  20. package/cpp/ggml-cpu/simd-mappings.h +16 -18
  21. package/cpp/ggml-cpu/vec.cpp +41 -1
  22. package/cpp/ggml-cpu/vec.h +241 -138
  23. package/cpp/ggml-cpu.h +1 -0
  24. package/cpp/ggml-impl.h +0 -4
  25. package/cpp/ggml-metal/ggml-metal-context.m +26 -16
  26. package/cpp/ggml-metal/ggml-metal-device.cpp +452 -371
  27. package/cpp/ggml-metal/ggml-metal-device.h +87 -65
  28. package/cpp/ggml-metal/ggml-metal-device.m +263 -104
  29. package/cpp/ggml-metal/ggml-metal-impl.h +58 -4
  30. package/cpp/ggml-metal/ggml-metal-ops.cpp +415 -98
  31. package/cpp/ggml-metal/ggml-metal-ops.h +4 -0
  32. package/cpp/ggml-metal/ggml-metal.cpp +6 -5
  33. package/cpp/ggml-metal/ggml-metal.metal +404 -34
  34. package/cpp/ggml.c +110 -31
  35. package/cpp/ggml.h +51 -12
  36. package/cpp/jsi/RNWhisperJSI.cpp +1 -0
  37. package/cpp/whisper.cpp +16 -3
  38. package/ios/CMakeLists.txt +21 -1
  39. package/ios/RNWhisperContext.mm +5 -0
  40. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
  41. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
  42. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -1
  43. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
  44. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +0 -4
  45. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +51 -12
  46. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
  47. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-metal.metal +404 -34
  48. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
  49. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
  50. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
  51. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -1
  52. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
  53. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +0 -4
  54. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +51 -12
  55. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  56. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
  57. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal.metal +404 -34
  58. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  59. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
  60. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
  61. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -1
  62. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
  63. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +0 -4
  64. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +51 -12
  65. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
  66. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-metal.metal +404 -34
  67. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
  68. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +9 -0
  69. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +1 -1
  70. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -1
  71. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +1 -0
  72. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +0 -4
  73. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +51 -12
  74. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  75. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
  76. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal.metal +404 -34
  77. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  78. package/lib/commonjs/NativeRNWhisper.js.map +1 -1
  79. package/lib/commonjs/jest-mock.js +2 -0
  80. package/lib/commonjs/jest-mock.js.map +1 -1
  81. package/lib/commonjs/version.json +1 -1
  82. package/lib/module/NativeRNWhisper.js.map +1 -1
  83. package/lib/module/jest-mock.js +2 -0
  84. package/lib/module/jest-mock.js.map +1 -1
  85. package/lib/module/version.json +1 -1
  86. package/lib/typescript/NativeRNWhisper.d.ts +1 -0
  87. package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
  88. package/package.json +1 -1
  89. package/src/NativeRNWhisper.ts +1 -0
  90. package/src/jest-mock.ts +2 -0
  91. package/src/version.json +1 -1
@@ -204,6 +204,10 @@
204
204
  # define WSP_GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
205
205
  #endif
206
206
 
207
+ #if defined(_WIN32) && !defined(_WIN32_WINNT)
208
+ # define _WIN32_WINNT 0x0A00
209
+ #endif
210
+
207
211
  #include <stdbool.h>
208
212
  #include <stddef.h>
209
213
  #include <stdint.h>
@@ -230,6 +234,11 @@
230
234
 
231
235
  #if UINTPTR_MAX == 0xFFFFFFFF
232
236
  #define WSP_GGML_MEM_ALIGN 4
237
+ #elif defined(__EMSCRIPTEN__)
238
+ // emscripten uses max_align_t == 8, so we need WSP_GGML_MEM_ALIGN == 8 for 64-bit wasm.
239
+ // (for 32-bit wasm, the first conditional is true and WSP_GGML_MEM_ALIGN stays 4.)
240
+ // ref: https://github.com/ggml-org/llama.cpp/pull/18628
241
+ #define WSP_GGML_MEM_ALIGN 8
233
242
  #else
234
243
  #define WSP_GGML_MEM_ALIGN 16
235
244
  #endif
@@ -530,6 +539,7 @@ extern "C" {
530
539
  WSP_GGML_OP_ARANGE,
531
540
  WSP_GGML_OP_TIMESTEP_EMBEDDING,
532
541
  WSP_GGML_OP_ARGSORT,
542
+ WSP_GGML_OP_TOP_K,
533
543
  WSP_GGML_OP_LEAKY_RELU,
534
544
  WSP_GGML_OP_TRI,
535
545
  WSP_GGML_OP_FILL,
@@ -2147,7 +2157,8 @@ extern "C" {
2147
2157
  };
2148
2158
 
2149
2159
  enum wsp_ggml_scale_flag {
2150
- WSP_GGML_SCALE_FLAG_ALIGN_CORNERS = (1 << 8)
2160
+ WSP_GGML_SCALE_FLAG_ALIGN_CORNERS = (1 << 8),
2161
+ WSP_GGML_SCALE_FLAG_ANTIALIAS = (1 << 9),
2151
2162
  };
2152
2163
 
2153
2164
  // interpolate
@@ -2190,6 +2201,15 @@ extern "C" {
2190
2201
  int p2,
2191
2202
  int p3);
2192
2203
 
2204
+ // pad each dimension with values on the other side of the torus (looping around)
2205
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_pad_circular(
2206
+ struct wsp_ggml_context * ctx,
2207
+ struct wsp_ggml_tensor * a,
2208
+ int p0,
2209
+ int p1,
2210
+ int p2,
2211
+ int p3);
2212
+
2193
2213
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_pad_ext(
2194
2214
  struct wsp_ggml_context * ctx,
2195
2215
  struct wsp_ggml_tensor * a,
@@ -2203,6 +2223,19 @@ extern "C" {
2203
2223
  int rp3
2204
2224
  );
2205
2225
 
2226
+ // pad each dimension with values on the other side of the torus (looping around)
2227
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_pad_ext_circular(
2228
+ struct wsp_ggml_context * ctx,
2229
+ struct wsp_ggml_tensor * a,
2230
+ int lp0,
2231
+ int rp0,
2232
+ int lp1,
2233
+ int rp1,
2234
+ int lp2,
2235
+ int rp2,
2236
+ int lp3,
2237
+ int rp3);
2238
+
2206
2239
  // pad each dimension with reflection: [a, b, c, d] -> [b, a, b, c, d, c]
2207
2240
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_pad_reflect_1d(
2208
2241
  struct wsp_ggml_context * ctx,
@@ -2258,25 +2291,30 @@ extern "C" {
2258
2291
  struct wsp_ggml_tensor * a,
2259
2292
  enum wsp_ggml_sort_order order);
2260
2293
 
2261
- WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_arange(
2294
+ // similar to wsp_ggml_top_k but implemented as `argsort` + `view`
2295
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_argsort_top_k(
2262
2296
  struct wsp_ggml_context * ctx,
2263
- float start,
2264
- float stop,
2265
- float step);
2297
+ struct wsp_ggml_tensor * a,
2298
+ int k);
2266
2299
 
2267
2300
  // top k elements per row
2301
+ // note: the resulting top k indices are in no particular order
2268
2302
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_top_k(
2269
2303
  struct wsp_ggml_context * ctx,
2270
2304
  struct wsp_ggml_tensor * a,
2271
2305
  int k);
2272
2306
 
2273
- #define WSP_GGML_KQ_MASK_PAD 64
2307
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_arange(
2308
+ struct wsp_ggml_context * ctx,
2309
+ float start,
2310
+ float stop,
2311
+ float step);
2274
2312
 
2275
- // q: [n_embd_k, n_batch, n_head, ne3 ]
2276
- // k: [n_embd_k, n_kv, n_head_kv, ne3 ]
2277
- // v: [n_embd_v, n_kv, n_head_kv, ne3 ] !! not transposed !!
2278
- // mask: [n_kv, n_batch_pad, ne32, ne33] !! n_batch_pad = WSP_GGML_PAD(n_batch, WSP_GGML_KQ_MASK_PAD) !!
2279
- // res: [n_embd_v, n_head, n_batch, ne3 ] !! permuted !!
2313
+ // q: [n_embd_k, n_batch, n_head, ne3 ]
2314
+ // k: [n_embd_k, n_kv, n_head_kv, ne3 ]
2315
+ // v: [n_embd_v, n_kv, n_head_kv, ne3 ] !! not transposed !!
2316
+ // mask: [n_kv, n_batch, ne32, ne33]
2317
+ // res: [n_embd_v, n_head, n_batch, ne3 ] !! permuted !!
2280
2318
  //
2281
2319
  // broadcast:
2282
2320
  // n_head % n_head_kv == 0
@@ -2582,7 +2620,8 @@ extern "C" {
2582
2620
 
2583
2621
  // Set callback for all future logging events.
2584
2622
  // If this is not called, or NULL is supplied, everything is output on stderr.
2585
- WSP_GGML_API void wsp_ggml_log_set(wsp_ggml_log_callback log_callback, void * user_data);
2623
+ WSP_GGML_API void wsp_ggml_log_get(wsp_ggml_log_callback * log_callback, void ** user_data);
2624
+ WSP_GGML_API void wsp_ggml_log_set(wsp_ggml_log_callback log_callback, void * user_data);
2586
2625
 
2587
2626
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_set_zero(struct wsp_ggml_tensor * tensor);
2588
2627