whisper.rn 0.5.1 → 0.5.3

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 (85) hide show
  1. package/android/src/main/jni.cpp +12 -3
  2. package/cpp/ggml-alloc.c +49 -18
  3. package/cpp/ggml-backend-impl.h +0 -3
  4. package/cpp/ggml-backend-reg.cpp +8 -0
  5. package/cpp/ggml-backend.cpp +0 -2
  6. package/cpp/ggml-backend.h +2 -0
  7. package/cpp/ggml-cpu/amx/amx.cpp +1 -0
  8. package/cpp/ggml-cpu/arch/arm/quants.c +428 -26
  9. package/cpp/ggml-cpu/ggml-cpu-impl.h +4 -2
  10. package/cpp/ggml-cpu/ggml-cpu.c +67 -24
  11. package/cpp/ggml-cpu/ops.cpp +489 -364
  12. package/cpp/ggml-cpu/ops.h +4 -4
  13. package/cpp/ggml-cpu/repack.cpp +143 -29
  14. package/cpp/ggml-cpu/simd-mappings.h +25 -25
  15. package/cpp/ggml-cpu/unary-ops.cpp +151 -0
  16. package/cpp/ggml-cpu/unary-ops.h +7 -0
  17. package/cpp/ggml-cpu/vec.cpp +83 -0
  18. package/cpp/ggml-cpu/vec.h +20 -8
  19. package/cpp/ggml-impl.h +67 -2
  20. package/cpp/ggml-metal/ggml-metal-common.cpp +2 -2
  21. package/cpp/ggml-metal/ggml-metal-context.m +5 -6
  22. package/cpp/ggml-metal/ggml-metal-device.cpp +300 -14
  23. package/cpp/ggml-metal/ggml-metal-device.h +26 -1
  24. package/cpp/ggml-metal/ggml-metal-device.m +243 -28
  25. package/cpp/ggml-metal/ggml-metal-impl.h +177 -9
  26. package/cpp/ggml-metal/ggml-metal-ops.cpp +843 -157
  27. package/cpp/ggml-metal/ggml-metal-ops.h +8 -0
  28. package/cpp/ggml-metal/ggml-metal.cpp +8 -3
  29. package/cpp/ggml-metal/ggml-metal.metal +12436 -0
  30. package/cpp/ggml.c +317 -4
  31. package/cpp/ggml.h +139 -0
  32. package/cpp/jsi/RNWhisperJSI.cpp +7 -2
  33. package/cpp/rn-whisper.h +1 -0
  34. package/cpp/whisper.cpp +8 -2
  35. package/ios/RNWhisperContext.mm +3 -1
  36. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  37. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  38. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +67 -2
  39. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +139 -0
  40. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  41. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
  42. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-metal.metal +12436 -0
  43. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
  44. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  45. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  46. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +67 -2
  47. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +139 -0
  48. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  49. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  50. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
  51. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal.metal +12436 -0
  52. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  53. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  54. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  55. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +67 -2
  56. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +139 -0
  57. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  58. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
  59. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-metal.metal +12436 -0
  60. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
  61. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +0 -3
  62. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +2 -0
  63. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +67 -2
  64. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +139 -0
  65. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  66. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  67. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
  68. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-metal.metal +12436 -0
  69. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  70. package/lib/commonjs/NativeRNWhisper.js.map +1 -1
  71. package/lib/commonjs/version.json +1 -1
  72. package/lib/module/NativeRNWhisper.js.map +1 -1
  73. package/lib/module/version.json +1 -1
  74. package/lib/typescript/NativeRNWhisper.d.ts +2 -0
  75. package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
  76. package/package.json +1 -1
  77. package/src/NativeRNWhisper.ts +2 -0
  78. package/src/version.json +1 -1
  79. package/whisper-rn.podspec +1 -1
  80. package/cpp/ggml-metal/ggml-whisper-sim.metallib +0 -0
  81. package/cpp/ggml-metal/ggml-whisper.metallib +0 -0
  82. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  83. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  84. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  85. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
@@ -69,11 +69,21 @@
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
+ #define FC_ROPE 800
80
+
81
+ // op-specific constants
82
+ #define OP_FLASH_ATTN_EXT_NQPTG 8
83
+ #define OP_FLASH_ATTN_EXT_NCPSG 64
84
+
85
+ #define OP_FLASH_ATTN_EXT_VEC_NQPTG 1
86
+ #define OP_FLASH_ATTN_EXT_VEC_NCPSG 32
77
87
 
78
88
  // kernel argument structs
79
89
  //
@@ -178,6 +188,7 @@ typedef struct {
178
188
  } wsp_ggml_metal_kargs_clamp;
179
189
 
180
190
  typedef struct {
191
+ int64_t nk0;
181
192
  int64_t ne00;
182
193
  int64_t ne01;
183
194
  int64_t ne02;
@@ -241,8 +252,38 @@ typedef struct {
241
252
  int32_t sect_1;
242
253
  int32_t sect_2;
243
254
  int32_t sect_3;
255
+ bool src2;
244
256
  } wsp_ggml_metal_kargs_rope;
245
257
 
258
+ typedef struct {
259
+ int32_t ne11;
260
+ int32_t ne_12_2; // assume K and V are same shape
261
+ int32_t ne_12_3;
262
+ uint64_t nb11;
263
+ uint64_t nb12;
264
+ uint64_t nb13;
265
+ uint64_t nb21;
266
+ uint64_t nb22;
267
+ uint64_t nb23;
268
+ int32_t ne31;
269
+ int32_t ne32;
270
+ int32_t ne33;
271
+ uint64_t nb31;
272
+ uint64_t nb32;
273
+ uint64_t nb33;
274
+ } wsp_ggml_metal_kargs_flash_attn_ext_pad;
275
+
276
+ typedef struct {
277
+ int32_t ne01;
278
+ int32_t ne30;
279
+ int32_t ne31;
280
+ int32_t ne32;
281
+ int32_t ne33;
282
+ uint64_t nb31;
283
+ uint64_t nb32;
284
+ uint64_t nb33;
285
+ } wsp_ggml_metal_kargs_flash_attn_ext_blk;
286
+
246
287
  typedef struct {
247
288
  int32_t ne01;
248
289
  int32_t ne02;
@@ -261,6 +302,7 @@ typedef struct {
261
302
  uint64_t nb21;
262
303
  uint64_t nb22;
263
304
  uint64_t nb23;
305
+ int32_t ne31;
264
306
  int32_t ne32;
265
307
  int32_t ne33;
266
308
  uint64_t nb31;
@@ -295,6 +337,7 @@ typedef struct {
295
337
  uint64_t nb21;
296
338
  uint64_t nb22;
297
339
  uint64_t nb23;
340
+ int32_t ne31;
298
341
  int32_t ne32;
299
342
  int32_t ne33;
300
343
  uint64_t nb31;
@@ -472,6 +515,49 @@ typedef struct {
472
515
  uint64_t nb1;
473
516
  } wsp_ggml_metal_kargs_conv_transpose_1d;
474
517
 
518
+ typedef struct {
519
+ int32_t IC;
520
+ int32_t IH;
521
+ int32_t IW;
522
+ int32_t KH;
523
+ int32_t KW;
524
+ int32_t OC;
525
+ int32_t s0;
526
+ uint64_t nb0;
527
+ uint64_t nb1;
528
+ uint64_t nb2;
529
+ } wsp_ggml_metal_kargs_conv_transpose_2d;
530
+
531
+ typedef struct {
532
+ uint64_t nb00;
533
+ uint64_t nb01;
534
+ uint64_t nb02;
535
+ uint64_t nb03;
536
+ uint64_t nb10;
537
+ uint64_t nb11;
538
+ uint64_t nb12;
539
+ uint64_t nb13;
540
+ uint64_t nb0;
541
+ uint64_t nb1;
542
+ uint64_t nb2;
543
+ uint64_t nb3;
544
+ int32_t IW;
545
+ int32_t IH;
546
+ int32_t KW;
547
+ int32_t KH;
548
+ int32_t IC;
549
+ int32_t OC;
550
+ int32_t OW;
551
+ int32_t OH;
552
+ int32_t N;
553
+ int32_t s0;
554
+ int32_t s1;
555
+ int32_t p0;
556
+ int32_t p1;
557
+ int32_t d0;
558
+ int32_t d1;
559
+ } wsp_ggml_metal_kargs_conv_2d;
560
+
475
561
  typedef struct {
476
562
  uint64_t ofs0;
477
563
  uint64_t ofs1;
@@ -503,6 +589,10 @@ typedef struct{
503
589
  float limit;
504
590
  } wsp_ggml_metal_kargs_glu;
505
591
 
592
+ typedef struct {
593
+ uint64_t np;
594
+ } wsp_ggml_metal_kargs_sum;
595
+
506
596
  typedef struct {
507
597
  int64_t ne00;
508
598
  int64_t ne01;
@@ -522,6 +612,45 @@ typedef struct {
522
612
  uint64_t nb3;
523
613
  } wsp_ggml_metal_kargs_sum_rows;
524
614
 
615
+ typedef struct {
616
+ int64_t ne00;
617
+ int64_t ne01;
618
+ int64_t ne02;
619
+ int64_t ne03;
620
+ uint64_t nb00;
621
+ uint64_t nb01;
622
+ uint64_t nb02;
623
+ uint64_t nb03;
624
+ int64_t net0;
625
+ int64_t net1;
626
+ int64_t net2;
627
+ int64_t net3;
628
+ uint64_t nbt0;
629
+ uint64_t nbt1;
630
+ uint64_t nbt2;
631
+ uint64_t nbt3;
632
+ bool outb;
633
+ } wsp_ggml_metal_kargs_cumsum_blk;
634
+
635
+ typedef struct {
636
+ int64_t ne00;
637
+ int64_t ne01;
638
+ int64_t ne02;
639
+ int64_t ne03;
640
+ uint64_t nb00;
641
+ uint64_t nb01;
642
+ uint64_t nb02;
643
+ uint64_t nb03;
644
+ int64_t net0;
645
+ int64_t net1;
646
+ int64_t net2;
647
+ int64_t net3;
648
+ uint64_t nbt0;
649
+ uint64_t nbt1;
650
+ uint64_t nbt2;
651
+ uint64_t nbt3;
652
+ } wsp_ggml_metal_kargs_cumsum_add;
653
+
525
654
  typedef struct {
526
655
  int32_t ne00;
527
656
  int32_t ne01;
@@ -572,32 +701,45 @@ typedef struct {
572
701
  int64_t n_seq_tokens;
573
702
  int64_t n_seqs;
574
703
  uint64_t s_off;
704
+ uint64_t nb00;
575
705
  uint64_t nb01;
576
706
  uint64_t nb02;
577
707
  uint64_t nb03;
708
+ uint64_t nb10;
578
709
  uint64_t nb11;
579
710
  uint64_t nb12;
711
+ uint64_t ns12;
580
712
  uint64_t nb13;
713
+ uint64_t nb20;
581
714
  uint64_t nb21;
715
+ uint64_t ns21;
582
716
  uint64_t nb22;
717
+ int64_t ne30;
583
718
  uint64_t nb31;
584
719
  uint64_t nb41;
585
720
  uint64_t nb42;
721
+ uint64_t ns42;
586
722
  uint64_t nb43;
587
723
  uint64_t nb51;
588
724
  uint64_t nb52;
725
+ uint64_t ns52;
589
726
  uint64_t nb53;
727
+ uint64_t nb0;
590
728
  } wsp_ggml_metal_kargs_ssm_scan;
591
729
 
592
730
  typedef struct {
593
- int64_t ne00;
731
+ int32_t ne00t;
732
+ int32_t ne00;
594
733
  uint64_t nb01;
595
734
  uint64_t nb02;
596
- int64_t ne10;
735
+ uint64_t nb03;
736
+ int32_t ne10;
597
737
  uint64_t nb10;
598
738
  uint64_t nb11;
739
+ uint64_t nb12;
599
740
  uint64_t nb1;
600
741
  uint64_t nb2;
742
+ uint64_t nb3;
601
743
  } wsp_ggml_metal_kargs_get_rows;
602
744
 
603
745
  typedef struct {
@@ -690,10 +832,28 @@ typedef struct {
690
832
  } wsp_ggml_metal_kargs_leaky_relu;
691
833
 
692
834
  typedef struct {
693
- int64_t ncols;
694
- int64_t ncols_pad;
835
+ int64_t ne00;
836
+ int64_t ne01;
837
+ int64_t ne02;
838
+ int64_t ne03;
839
+ uint64_t nb00;
840
+ uint64_t nb01;
841
+ uint64_t nb02;
842
+ uint64_t nb03;
695
843
  } wsp_ggml_metal_kargs_argsort;
696
844
 
845
+ typedef struct {
846
+ int64_t ne00;
847
+ int64_t ne01;
848
+ int64_t ne02;
849
+ int64_t ne03;
850
+ uint64_t nb00;
851
+ uint64_t nb01;
852
+ uint64_t nb02;
853
+ uint64_t nb03;
854
+ int32_t len;
855
+ } wsp_ggml_metal_kargs_argsort_merge;
856
+
697
857
  typedef struct {
698
858
  int64_t ne0;
699
859
  float start;
@@ -719,4 +879,12 @@ typedef struct {
719
879
  uint64_t nb01;
720
880
  } wsp_ggml_metal_kargs_argmax;
721
881
 
882
+ typedef struct {
883
+ int64_t np;
884
+ } wsp_ggml_metal_kargs_opt_step_adamw;
885
+
886
+ typedef struct {
887
+ int64_t np;
888
+ } wsp_ggml_metal_kargs_opt_step_sgd;
889
+
722
890
  #endif // WSP_GGML_METAL_IMPL