whisper.rn 0.5.1 → 0.5.2

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 (66) hide show
  1. package/android/src/main/jni.cpp +12 -3
  2. package/cpp/ggml-alloc.c +38 -14
  3. package/cpp/ggml-backend-impl.h +0 -3
  4. package/cpp/ggml-backend.h +2 -0
  5. package/cpp/ggml-cpu/amx/amx.cpp +1 -0
  6. package/cpp/ggml-cpu/ggml-cpu-impl.h +1 -1
  7. package/cpp/ggml-cpu/ggml-cpu.c +17 -3
  8. package/cpp/ggml-cpu/ops.cpp +33 -17
  9. package/cpp/ggml-cpu/unary-ops.cpp +135 -0
  10. package/cpp/ggml-cpu/unary-ops.h +5 -0
  11. package/cpp/ggml-cpu/vec.cpp +66 -0
  12. package/cpp/ggml-cpu/vec.h +10 -8
  13. package/cpp/ggml-impl.h +51 -2
  14. package/cpp/ggml-metal/ggml-metal-common.cpp +2 -2
  15. package/cpp/ggml-metal/ggml-metal-device.cpp +199 -10
  16. package/cpp/ggml-metal/ggml-metal-device.h +18 -0
  17. package/cpp/ggml-metal/ggml-metal-device.m +27 -14
  18. package/cpp/ggml-metal/ggml-metal-impl.h +87 -7
  19. package/cpp/ggml-metal/ggml-metal-ops.cpp +513 -88
  20. package/cpp/ggml-metal/ggml-metal-ops.h +6 -0
  21. package/cpp/ggml-metal/ggml-metal.cpp +3 -3
  22. package/cpp/ggml-metal/ggml-whisper-sim.metallib +0 -0
  23. package/cpp/ggml-metal/ggml-whisper.metallib +0 -0
  24. package/cpp/ggml.c +166 -2
  25. package/cpp/ggml.h +66 -0
  26. package/cpp/jsi/RNWhisperJSI.cpp +7 -2
  27. package/cpp/rn-whisper.h +1 -0
  28. package/cpp/whisper.cpp +4 -2
  29. package/ios/RNWhisperContext.mm +3 -1
  30. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  31. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  32. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +51 -2
  33. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +66 -0
  34. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  35. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  36. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
  37. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  38. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  39. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +51 -2
  40. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +66 -0
  41. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  42. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  43. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  44. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  45. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  46. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +51 -2
  47. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +66 -0
  48. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  49. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  50. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
  51. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  52. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  53. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +51 -2
  54. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +66 -0
  55. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  56. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  57. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  58. package/lib/commonjs/NativeRNWhisper.js.map +1 -1
  59. package/lib/commonjs/version.json +1 -1
  60. package/lib/module/NativeRNWhisper.js.map +1 -1
  61. package/lib/module/version.json +1 -1
  62. package/lib/typescript/NativeRNWhisper.d.ts +2 -0
  63. package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
  64. package/package.json +1 -1
  65. package/src/NativeRNWhisper.ts +2 -0
  66. package/src/version.json +1 -1
@@ -69,11 +69,20 @@
69
69
  #define N_SG_IQ4_XS 2
70
70
 
71
71
  // function constants offsets
72
- #define FC_FLASH_ATTN_EXT 100
73
- #define FC_FLASH_ATTN_EXT_VEC 200
74
- #define FC_FLASH_ATTN_EXT_VEC_REDUCE 300
75
- #define FC_MUL_MV 400
76
- #define FC_MUL_MM 500
72
+ #define FC_FLASH_ATTN_EXT_PAD 100
73
+ #define FC_FLASH_ATTN_EXT_BLK 200
74
+ #define FC_FLASH_ATTN_EXT 300
75
+ #define FC_FLASH_ATTN_EXT_VEC 400
76
+ #define FC_FLASH_ATTN_EXT_VEC_REDUCE 500
77
+ #define FC_MUL_MV 600
78
+ #define FC_MUL_MM 700
79
+
80
+ // op-specific constants
81
+ #define OP_FLASH_ATTN_EXT_NQPTG 8
82
+ #define OP_FLASH_ATTN_EXT_NCPSG 64
83
+
84
+ #define OP_FLASH_ATTN_EXT_VEC_NQPTG 1
85
+ #define OP_FLASH_ATTN_EXT_VEC_NCPSG 32
77
86
 
78
87
  // kernel argument structs
79
88
  //
@@ -178,6 +187,7 @@ typedef struct {
178
187
  } wsp_ggml_metal_kargs_clamp;
179
188
 
180
189
  typedef struct {
190
+ int64_t nk0;
181
191
  int64_t ne00;
182
192
  int64_t ne01;
183
193
  int64_t ne02;
@@ -241,8 +251,38 @@ typedef struct {
241
251
  int32_t sect_1;
242
252
  int32_t sect_2;
243
253
  int32_t sect_3;
254
+ bool src2;
244
255
  } wsp_ggml_metal_kargs_rope;
245
256
 
257
+ typedef struct {
258
+ int32_t ne11;
259
+ int32_t ne_12_2; // assume K and V are same shape
260
+ int32_t ne_12_3;
261
+ uint64_t nb11;
262
+ uint64_t nb12;
263
+ uint64_t nb13;
264
+ uint64_t nb21;
265
+ uint64_t nb22;
266
+ uint64_t nb23;
267
+ int32_t ne31;
268
+ int32_t ne32;
269
+ int32_t ne33;
270
+ uint64_t nb31;
271
+ uint64_t nb32;
272
+ uint64_t nb33;
273
+ } wsp_ggml_metal_kargs_flash_attn_ext_pad;
274
+
275
+ typedef struct {
276
+ int32_t ne01;
277
+ int32_t ne30;
278
+ int32_t ne31;
279
+ int32_t ne32;
280
+ int32_t ne33;
281
+ uint64_t nb31;
282
+ uint64_t nb32;
283
+ uint64_t nb33;
284
+ } wsp_ggml_metal_kargs_flash_attn_ext_blk;
285
+
246
286
  typedef struct {
247
287
  int32_t ne01;
248
288
  int32_t ne02;
@@ -261,6 +301,7 @@ typedef struct {
261
301
  uint64_t nb21;
262
302
  uint64_t nb22;
263
303
  uint64_t nb23;
304
+ int32_t ne31;
264
305
  int32_t ne32;
265
306
  int32_t ne33;
266
307
  uint64_t nb31;
@@ -295,6 +336,7 @@ typedef struct {
295
336
  uint64_t nb21;
296
337
  uint64_t nb22;
297
338
  uint64_t nb23;
339
+ int32_t ne31;
298
340
  int32_t ne32;
299
341
  int32_t ne33;
300
342
  uint64_t nb31;
@@ -472,6 +514,19 @@ typedef struct {
472
514
  uint64_t nb1;
473
515
  } wsp_ggml_metal_kargs_conv_transpose_1d;
474
516
 
517
+ typedef struct {
518
+ int32_t IC;
519
+ int32_t IH;
520
+ int32_t IW;
521
+ int32_t KH;
522
+ int32_t KW;
523
+ int32_t OC;
524
+ int32_t s0;
525
+ uint64_t nb0;
526
+ uint64_t nb1;
527
+ uint64_t nb2;
528
+ } wsp_ggml_metal_kargs_conv_transpose_2d;
529
+
475
530
  typedef struct {
476
531
  uint64_t ofs0;
477
532
  uint64_t ofs1;
@@ -503,6 +558,10 @@ typedef struct{
503
558
  float limit;
504
559
  } wsp_ggml_metal_kargs_glu;
505
560
 
561
+ typedef struct {
562
+ uint64_t np;
563
+ } wsp_ggml_metal_kargs_sum;
564
+
506
565
  typedef struct {
507
566
  int64_t ne00;
508
567
  int64_t ne01;
@@ -572,32 +631,45 @@ typedef struct {
572
631
  int64_t n_seq_tokens;
573
632
  int64_t n_seqs;
574
633
  uint64_t s_off;
634
+ uint64_t nb00;
575
635
  uint64_t nb01;
576
636
  uint64_t nb02;
577
637
  uint64_t nb03;
638
+ uint64_t nb10;
578
639
  uint64_t nb11;
579
640
  uint64_t nb12;
641
+ uint64_t ns12;
580
642
  uint64_t nb13;
643
+ uint64_t nb20;
581
644
  uint64_t nb21;
645
+ uint64_t ns21;
582
646
  uint64_t nb22;
647
+ int64_t ne30;
583
648
  uint64_t nb31;
584
649
  uint64_t nb41;
585
650
  uint64_t nb42;
651
+ uint64_t ns42;
586
652
  uint64_t nb43;
587
653
  uint64_t nb51;
588
654
  uint64_t nb52;
655
+ uint64_t ns52;
589
656
  uint64_t nb53;
657
+ uint64_t nb0;
590
658
  } wsp_ggml_metal_kargs_ssm_scan;
591
659
 
592
660
  typedef struct {
593
- int64_t ne00;
661
+ int32_t ne00t;
662
+ int32_t ne00;
594
663
  uint64_t nb01;
595
664
  uint64_t nb02;
596
- int64_t ne10;
665
+ uint64_t nb03;
666
+ int32_t ne10;
597
667
  uint64_t nb10;
598
668
  uint64_t nb11;
669
+ uint64_t nb12;
599
670
  uint64_t nb1;
600
671
  uint64_t nb2;
672
+ uint64_t nb3;
601
673
  } wsp_ggml_metal_kargs_get_rows;
602
674
 
603
675
  typedef struct {
@@ -719,4 +791,12 @@ typedef struct {
719
791
  uint64_t nb01;
720
792
  } wsp_ggml_metal_kargs_argmax;
721
793
 
794
+ typedef struct {
795
+ int64_t np;
796
+ } wsp_ggml_metal_kargs_opt_step_adamw;
797
+
798
+ typedef struct {
799
+ int64_t np;
800
+ } wsp_ggml_metal_kargs_opt_step_sgd;
801
+
722
802
  #endif // WSP_GGML_METAL_IMPL