whisper.rn 0.5.0 → 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 (113) hide show
  1. package/android/build.gradle +2 -1
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/jni.cpp +12 -3
  4. package/cpp/ggml-alloc.c +292 -130
  5. package/cpp/ggml-backend-impl.h +4 -4
  6. package/cpp/ggml-backend-reg.cpp +13 -5
  7. package/cpp/ggml-backend.cpp +207 -17
  8. package/cpp/ggml-backend.h +19 -1
  9. package/cpp/ggml-cpu/amx/amx.cpp +5 -2
  10. package/cpp/ggml-cpu/arch/x86/repack.cpp +2 -2
  11. package/cpp/ggml-cpu/arch-fallback.h +0 -4
  12. package/cpp/ggml-cpu/common.h +14 -0
  13. package/cpp/ggml-cpu/ggml-cpu-impl.h +14 -7
  14. package/cpp/ggml-cpu/ggml-cpu.c +65 -44
  15. package/cpp/ggml-cpu/ggml-cpu.cpp +14 -4
  16. package/cpp/ggml-cpu/ops.cpp +542 -775
  17. package/cpp/ggml-cpu/ops.h +2 -0
  18. package/cpp/ggml-cpu/simd-mappings.h +88 -59
  19. package/cpp/ggml-cpu/unary-ops.cpp +135 -0
  20. package/cpp/ggml-cpu/unary-ops.h +5 -0
  21. package/cpp/ggml-cpu/vec.cpp +227 -20
  22. package/cpp/ggml-cpu/vec.h +407 -56
  23. package/cpp/ggml-cpu.h +1 -1
  24. package/cpp/ggml-impl.h +94 -12
  25. package/cpp/ggml-metal/ggml-metal-common.cpp +446 -0
  26. package/cpp/ggml-metal/ggml-metal-common.h +52 -0
  27. package/cpp/ggml-metal/ggml-metal-context.h +33 -0
  28. package/cpp/ggml-metal/ggml-metal-context.m +600 -0
  29. package/cpp/ggml-metal/ggml-metal-device.cpp +1565 -0
  30. package/cpp/ggml-metal/ggml-metal-device.h +244 -0
  31. package/cpp/ggml-metal/ggml-metal-device.m +1325 -0
  32. package/cpp/ggml-metal/ggml-metal-impl.h +802 -0
  33. package/cpp/ggml-metal/ggml-metal-ops.cpp +3583 -0
  34. package/cpp/ggml-metal/ggml-metal-ops.h +88 -0
  35. package/cpp/ggml-metal/ggml-metal.cpp +718 -0
  36. package/cpp/ggml-metal/ggml-whisper-sim.metallib +0 -0
  37. package/cpp/ggml-metal/ggml-whisper.metallib +0 -0
  38. package/cpp/ggml-metal-impl.h +40 -40
  39. package/cpp/ggml-metal.h +1 -6
  40. package/cpp/ggml-quants.c +1 -0
  41. package/cpp/ggml.c +341 -15
  42. package/cpp/ggml.h +150 -5
  43. package/cpp/jsi/RNWhisperJSI.cpp +9 -2
  44. package/cpp/jsi/ThreadPool.h +3 -3
  45. package/cpp/rn-whisper.h +1 -0
  46. package/cpp/whisper.cpp +89 -72
  47. package/cpp/whisper.h +1 -0
  48. package/ios/CMakeLists.txt +6 -1
  49. package/ios/RNWhisperContext.mm +3 -1
  50. package/ios/RNWhisperVadContext.mm +14 -13
  51. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +4 -4
  52. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +19 -1
  53. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpu.h +1 -1
  54. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +94 -12
  55. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +40 -40
  56. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal.h +1 -6
  57. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +150 -5
  58. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  59. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper.h +1 -0
  60. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
  61. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  62. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
  63. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +4 -4
  64. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +19 -1
  65. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +1 -1
  66. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +94 -12
  67. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +40 -40
  68. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +1 -6
  69. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +150 -5
  70. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  71. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +1 -0
  72. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  73. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
  74. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  75. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  76. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +4 -4
  77. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +19 -1
  78. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpu.h +1 -1
  79. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +94 -12
  80. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +40 -40
  81. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal.h +1 -6
  82. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +150 -5
  83. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  84. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper.h +1 -0
  85. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
  86. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  87. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
  88. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +4 -4
  89. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +19 -1
  90. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +1 -1
  91. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +94 -12
  92. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +40 -40
  93. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +1 -6
  94. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +150 -5
  95. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +1 -0
  96. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +1 -0
  97. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  98. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +1 -1
  99. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  100. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  101. package/lib/commonjs/NativeRNWhisper.js.map +1 -1
  102. package/lib/commonjs/version.json +1 -1
  103. package/lib/module/NativeRNWhisper.js.map +1 -1
  104. package/lib/module/version.json +1 -1
  105. package/lib/typescript/NativeRNWhisper.d.ts +2 -0
  106. package/lib/typescript/NativeRNWhisper.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/src/NativeRNWhisper.ts +2 -0
  109. package/src/version.json +1 -1
  110. package/whisper-rn.podspec +8 -9
  111. package/cpp/ggml-metal.m +0 -6779
  112. package/cpp/ggml-whisper-sim.metallib +0 -0
  113. package/cpp/ggml-whisper.metallib +0 -0
@@ -1,5 +1,5 @@
1
- #ifndef WSP_GGML_METAL_IMPL
2
- #define WSP_GGML_METAL_IMPL
1
+ #ifndef WSP_WSP_WSP_GGML_METAL_IMPL
2
+ #define WSP_WSP_WSP_GGML_METAL_IMPL
3
3
 
4
4
  // kernel parameters for mat-vec threadgroups
5
5
  //
@@ -101,7 +101,7 @@ typedef struct {
101
101
  uint64_t nb2;
102
102
  uint64_t nb3;
103
103
  int32_t dim;
104
- } wsp_ggml_metal_kargs_concat;
104
+ } wsp_wsp_wsp_ggml_metal_kargs_concat;
105
105
 
106
106
  typedef struct {
107
107
  int32_t ne00;
@@ -130,7 +130,7 @@ typedef struct {
130
130
  uint64_t nb3;
131
131
  uint64_t offs;
132
132
  uint64_t o1[8];
133
- } wsp_ggml_metal_kargs_bin;
133
+ } wsp_wsp_wsp_ggml_metal_kargs_bin;
134
134
 
135
135
  typedef struct {
136
136
  int64_t ne0;
@@ -139,7 +139,7 @@ typedef struct {
139
139
  size_t nb02;
140
140
  size_t nb11;
141
141
  size_t nb21;
142
- } wsp_ggml_metal_kargs_add_id;
142
+ } wsp_wsp_wsp_ggml_metal_kargs_add_id;
143
143
 
144
144
  typedef struct {
145
145
  int32_t ne00;
@@ -158,7 +158,7 @@ typedef struct {
158
158
  uint64_t nb1;
159
159
  uint64_t nb2;
160
160
  uint64_t nb3;
161
- } wsp_ggml_metal_kargs_repeat;
161
+ } wsp_wsp_wsp_ggml_metal_kargs_repeat;
162
162
 
163
163
  typedef struct {
164
164
  int64_t ne00;
@@ -177,7 +177,7 @@ typedef struct {
177
177
  uint64_t nb1;
178
178
  uint64_t nb2;
179
179
  uint64_t nb3;
180
- } wsp_ggml_metal_kargs_cpy;
180
+ } wsp_wsp_wsp_ggml_metal_kargs_cpy;
181
181
 
182
182
  typedef struct {
183
183
  int64_t ne10;
@@ -192,7 +192,7 @@ typedef struct {
192
192
  uint64_t nb3;
193
193
  uint64_t offs;
194
194
  bool inplace;
195
- } wsp_ggml_metal_kargs_set;
195
+ } wsp_wsp_wsp_ggml_metal_kargs_set;
196
196
 
197
197
  typedef struct {
198
198
  int32_t ne00;
@@ -224,7 +224,7 @@ typedef struct {
224
224
  int32_t sect_1;
225
225
  int32_t sect_2;
226
226
  int32_t sect_3;
227
- } wsp_ggml_metal_kargs_rope;
227
+ } wsp_wsp_wsp_ggml_metal_kargs_rope;
228
228
 
229
229
  typedef struct {
230
230
  int32_t ne01;
@@ -255,7 +255,7 @@ typedef struct {
255
255
  float m1;
256
256
  int32_t n_head_log2;
257
257
  float logit_softcap;
258
- } wsp_ggml_metal_kargs_flash_attn_ext;
258
+ } wsp_wsp_wsp_ggml_metal_kargs_flash_attn_ext;
259
259
 
260
260
  typedef struct {
261
261
  int32_t ne00;
@@ -272,7 +272,7 @@ typedef struct {
272
272
  int32_t ne1;
273
273
  int16_t r2;
274
274
  int16_t r3;
275
- } wsp_ggml_metal_kargs_mul_mm;
275
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mm;
276
276
 
277
277
  typedef struct {
278
278
  int32_t ne00;
@@ -293,7 +293,7 @@ typedef struct {
293
293
  int32_t ne1;
294
294
  int16_t r2;
295
295
  int16_t r3;
296
- } wsp_ggml_metal_kargs_mul_mv;
296
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mv;
297
297
 
298
298
  typedef struct {
299
299
  int32_t ne00;
@@ -317,7 +317,7 @@ typedef struct {
317
317
  int16_t nsg;
318
318
  int16_t nxpsg;
319
319
  int16_t r1ptg;
320
- } wsp_ggml_metal_kargs_mul_mv_ext;
320
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mv_ext;
321
321
 
322
322
  typedef struct {
323
323
  int32_t ne10;
@@ -328,7 +328,7 @@ typedef struct {
328
328
  uint64_t nbh11;
329
329
  int32_t ne20; // n_expert_used
330
330
  uint64_t nb21;
331
- } wsp_ggml_metal_kargs_mul_mm_id_map0;
331
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mm_id_map0;
332
332
 
333
333
  typedef struct {
334
334
  int32_t ne20; // n_expert_used
@@ -339,7 +339,7 @@ typedef struct {
339
339
  int32_t ne0;
340
340
  uint64_t nb1;
341
341
  uint64_t nb2;
342
- } wsp_ggml_metal_kargs_mul_mm_id_map1;
342
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mm_id_map1;
343
343
 
344
344
  typedef struct {
345
345
  int32_t ne00;
@@ -356,7 +356,7 @@ typedef struct {
356
356
  int32_t neh1;
357
357
  int16_t r2;
358
358
  int16_t r3;
359
- } wsp_ggml_metal_kargs_mul_mm_id;
359
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mm_id;
360
360
 
361
361
  typedef struct {
362
362
  int32_t nei0;
@@ -378,14 +378,14 @@ typedef struct {
378
378
  int32_t ne0;
379
379
  int32_t ne1;
380
380
  uint64_t nb1;
381
- } wsp_ggml_metal_kargs_mul_mv_id;
381
+ } wsp_wsp_wsp_ggml_metal_kargs_mul_mv_id;
382
382
 
383
383
  typedef struct {
384
384
  int32_t ne00;
385
385
  int32_t ne00_4;
386
386
  uint64_t nb01;
387
387
  float eps;
388
- } wsp_ggml_metal_kargs_norm;
388
+ } wsp_wsp_wsp_ggml_metal_kargs_norm;
389
389
 
390
390
  typedef struct {
391
391
  int32_t ne00;
@@ -400,14 +400,14 @@ typedef struct {
400
400
  uint64_t nbf1[3];
401
401
  uint64_t nbf2[3];
402
402
  uint64_t nbf3[3];
403
- } wsp_ggml_metal_kargs_rms_norm;
403
+ } wsp_wsp_wsp_ggml_metal_kargs_rms_norm;
404
404
 
405
405
  typedef struct {
406
406
  int32_t ne00;
407
407
  int32_t ne00_4;
408
408
  uint64_t nb01;
409
409
  float eps;
410
- } wsp_ggml_metal_kargs_l2_norm;
410
+ } wsp_wsp_wsp_ggml_metal_kargs_l2_norm;
411
411
 
412
412
  typedef struct {
413
413
  int64_t ne00;
@@ -418,7 +418,7 @@ typedef struct {
418
418
  uint64_t nb02;
419
419
  int32_t n_groups;
420
420
  float eps;
421
- } wsp_ggml_metal_kargs_group_norm;
421
+ } wsp_wsp_wsp_ggml_metal_kargs_group_norm;
422
422
 
423
423
  typedef struct {
424
424
  int32_t IC;
@@ -427,7 +427,7 @@ typedef struct {
427
427
  int32_t s0;
428
428
  uint64_t nb0;
429
429
  uint64_t nb1;
430
- } wsp_ggml_metal_kargs_conv_transpose_1d;
430
+ } wsp_wsp_wsp_ggml_metal_kargs_conv_transpose_1d;
431
431
 
432
432
  typedef struct {
433
433
  uint64_t ofs0;
@@ -445,7 +445,7 @@ typedef struct {
445
445
  int32_t KH;
446
446
  int32_t KW;
447
447
  int32_t KHW; // KH * KW, pre-computed on CPU to save GPU resources
448
- } wsp_ggml_metal_kargs_im2col;
448
+ } wsp_wsp_wsp_ggml_metal_kargs_im2col;
449
449
 
450
450
  typedef struct{
451
451
  int32_t ne00;
@@ -458,7 +458,7 @@ typedef struct{
458
458
  int32_t i10;
459
459
  float alpha;
460
460
  float limit;
461
- } wsp_ggml_metal_kargs_glu;
461
+ } wsp_wsp_wsp_ggml_metal_kargs_glu;
462
462
 
463
463
  typedef struct {
464
464
  int64_t ne00;
@@ -485,7 +485,7 @@ typedef struct {
485
485
  uint64_t nb1;
486
486
  uint64_t nb2;
487
487
  uint64_t nb3;
488
- } wsp_ggml_metal_kargs_sum_rows;
488
+ } wsp_wsp_wsp_ggml_metal_kargs_sum_rows;
489
489
 
490
490
  typedef struct {
491
491
  int32_t ne00;
@@ -508,13 +508,13 @@ typedef struct {
508
508
  float m0;
509
509
  float m1;
510
510
  int32_t n_head_log2;
511
- } wsp_ggml_metal_kargs_soft_max;
511
+ } wsp_wsp_wsp_ggml_metal_kargs_soft_max;
512
512
 
513
513
  typedef struct {
514
514
  int64_t ne00;
515
515
  int64_t ne01;
516
516
  int n_past;
517
- } wsp_ggml_metal_kargs_diag_mask_inf;
517
+ } wsp_wsp_wsp_ggml_metal_kargs_diag_mask_inf;
518
518
 
519
519
  typedef struct {
520
520
  int64_t ne00;
@@ -533,7 +533,7 @@ typedef struct {
533
533
  uint64_t nb0;
534
534
  uint64_t nb1;
535
535
  uint64_t nb2;
536
- } wsp_ggml_metal_kargs_ssm_conv;
536
+ } wsp_wsp_wsp_ggml_metal_kargs_ssm_conv;
537
537
 
538
538
  typedef struct {
539
539
  int64_t d_state;
@@ -558,7 +558,7 @@ typedef struct {
558
558
  uint64_t nb51;
559
559
  uint64_t nb52;
560
560
  uint64_t nb53;
561
- } wsp_ggml_metal_kargs_ssm_scan;
561
+ } wsp_wsp_wsp_ggml_metal_kargs_ssm_scan;
562
562
 
563
563
  typedef struct {
564
564
  int64_t ne00;
@@ -569,7 +569,7 @@ typedef struct {
569
569
  uint64_t nb11;
570
570
  uint64_t nb1;
571
571
  uint64_t nb2;
572
- } wsp_ggml_metal_kargs_get_rows;
572
+ } wsp_wsp_wsp_ggml_metal_kargs_get_rows;
573
573
 
574
574
  typedef struct {
575
575
  int32_t nk0;
@@ -585,7 +585,7 @@ typedef struct {
585
585
  uint64_t nb1;
586
586
  uint64_t nb2;
587
587
  uint64_t nb3;
588
- } wsp_ggml_metal_kargs_set_rows;
588
+ } wsp_wsp_wsp_ggml_metal_kargs_set_rows;
589
589
 
590
590
  typedef struct {
591
591
  int64_t ne00;
@@ -608,7 +608,7 @@ typedef struct {
608
608
  float sf1;
609
609
  float sf2;
610
610
  float sf3;
611
- } wsp_ggml_metal_kargs_upscale;
611
+ } wsp_wsp_wsp_ggml_metal_kargs_upscale;
612
612
 
613
613
  typedef struct {
614
614
  int64_t ne00;
@@ -627,7 +627,7 @@ typedef struct {
627
627
  uint64_t nb1;
628
628
  uint64_t nb2;
629
629
  uint64_t nb3;
630
- } wsp_ggml_metal_kargs_pad;
630
+ } wsp_wsp_wsp_ggml_metal_kargs_pad;
631
631
 
632
632
  typedef struct {
633
633
  int64_t ne00;
@@ -648,28 +648,28 @@ typedef struct {
648
648
  uint64_t nb3;
649
649
  int32_t p0;
650
650
  int32_t p1;
651
- } wsp_ggml_metal_kargs_pad_reflect_1d;
651
+ } wsp_wsp_wsp_ggml_metal_kargs_pad_reflect_1d;
652
652
 
653
653
  typedef struct {
654
654
  uint64_t nb1;
655
655
  int dim;
656
656
  int max_period;
657
- } wsp_ggml_metal_kargs_timestep_embedding;
657
+ } wsp_wsp_wsp_ggml_metal_kargs_timestep_embedding;
658
658
 
659
659
  typedef struct {
660
660
  float slope;
661
- } wsp_ggml_metal_kargs_leaky_relu;
661
+ } wsp_wsp_wsp_ggml_metal_kargs_leaky_relu;
662
662
 
663
663
  typedef struct {
664
664
  int64_t ncols;
665
665
  int64_t ncols_pad;
666
- } wsp_ggml_metal_kargs_argsort;
666
+ } wsp_wsp_wsp_ggml_metal_kargs_argsort;
667
667
 
668
668
  typedef struct {
669
669
  int64_t ne0;
670
670
  float start;
671
671
  float step;
672
- } wsp_ggml_metal_kargs_arange;
672
+ } wsp_wsp_wsp_ggml_metal_kargs_arange;
673
673
 
674
674
  typedef struct {
675
675
  int32_t k0;
@@ -683,6 +683,6 @@ typedef struct {
683
683
  int64_t OH;
684
684
  int64_t OW;
685
685
  int64_t parallel_elements;
686
- } wsp_ggml_metal_kargs_pool_2d;
686
+ } wsp_wsp_wsp_ggml_metal_kargs_pool_2d;
687
687
 
688
- #endif // WSP_GGML_METAL_IMPL
688
+ #endif // WSP_WSP_WSP_GGML_METAL_IMPL
@@ -39,18 +39,13 @@ extern "C" {
39
39
  // user-code should use only these functions
40
40
  //
41
41
 
42
+ // TODO: remove in the future
42
43
  WSP_GGML_BACKEND_API wsp_ggml_backend_t wsp_ggml_backend_metal_init(void);
43
44
 
44
45
  WSP_GGML_BACKEND_API bool wsp_ggml_backend_is_metal(wsp_ggml_backend_t backend);
45
46
 
46
- WSP_GGML_DEPRECATED(
47
- WSP_GGML_BACKEND_API wsp_ggml_backend_buffer_t wsp_ggml_backend_metal_buffer_from_ptr(void * data, size_t size, size_t max_size),
48
- "obsoleted by the new device interface - https://github.com/ggml-org/llama.cpp/pull/9713");
49
-
50
47
  WSP_GGML_BACKEND_API void wsp_ggml_backend_metal_set_abort_callback(wsp_ggml_backend_t backend, wsp_ggml_abort_callback abort_callback, void * user_data);
51
48
 
52
- WSP_GGML_BACKEND_API wsp_ggml_backend_buffer_type_t wsp_ggml_backend_metal_buffer_type(void);
53
-
54
49
  // helper to check if the device supports a specific family
55
50
  // ideally, the user code should be doing these checks
56
51
  // ref: https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf
@@ -237,6 +237,8 @@
237
237
  #define WSP_GGML_EXIT_SUCCESS 0
238
238
  #define WSP_GGML_EXIT_ABORTED 1
239
239
 
240
+ // TODO: convert to enum https://github.com/ggml-org/llama.cpp/pull/16187#discussion_r2388538726
241
+ #define WSP_GGML_ROPE_TYPE_NORMAL 0
240
242
  #define WSP_GGML_ROPE_TYPE_NEOX 2
241
243
  #define WSP_GGML_ROPE_TYPE_MROPE 8
242
244
  #define WSP_GGML_ROPE_TYPE_VISION 24
@@ -244,6 +246,13 @@
244
246
  #define WSP_GGML_MROPE_SECTIONS 4
245
247
 
246
248
  #define WSP_GGML_UNUSED(x) (void)(x)
249
+ #ifdef __CUDACC__
250
+ template<typename... Args>
251
+ __host__ __device__ constexpr inline void wsp_ggml_unused_vars_impl(Args&&...) noexcept {}
252
+ #define WSP_GGML_UNUSED_VARS(...) wsp_ggml_unused_vars_impl(__VA_ARGS__)
253
+ #else
254
+ #define WSP_GGML_UNUSED_VARS(...) do { (void)sizeof((__VA_ARGS__, 0)); } while(0)
255
+ #endif // __CUDACC__
247
256
 
248
257
  #define WSP_GGML_PAD(x, n) (((x) + (n) - 1) & ~((n) - 1))
249
258
 
@@ -277,19 +286,19 @@
277
286
  // WSP_GGML_TENSOR_LOCALS(size_t, nb1, src1, nb);
278
287
  //
279
288
  #define WSP_GGML_TENSOR_LOCALS_1(type, prefix, pointer, array) \
280
- const type prefix##0 = (pointer)->array[0]; \
289
+ const type prefix##0 = (pointer) ? (pointer)->array[0] : 0; \
281
290
  WSP_GGML_UNUSED(prefix##0);
282
291
  #define WSP_GGML_TENSOR_LOCALS_2(type, prefix, pointer, array) \
283
292
  WSP_GGML_TENSOR_LOCALS_1 (type, prefix, pointer, array) \
284
- const type prefix##1 = (pointer)->array[1]; \
293
+ const type prefix##1 = (pointer) ? (pointer)->array[1] : 0; \
285
294
  WSP_GGML_UNUSED(prefix##1);
286
295
  #define WSP_GGML_TENSOR_LOCALS_3(type, prefix, pointer, array) \
287
296
  WSP_GGML_TENSOR_LOCALS_2 (type, prefix, pointer, array) \
288
- const type prefix##2 = (pointer)->array[2]; \
297
+ const type prefix##2 = (pointer) ? (pointer)->array[2] : 0; \
289
298
  WSP_GGML_UNUSED(prefix##2);
290
299
  #define WSP_GGML_TENSOR_LOCALS(type, prefix, pointer, array) \
291
300
  WSP_GGML_TENSOR_LOCALS_3 (type, prefix, pointer, array) \
292
- const type prefix##3 = (pointer)->array[3]; \
301
+ const type prefix##3 = (pointer) ? (pointer)->array[3] : 0; \
293
302
  WSP_GGML_UNUSED(prefix##3);
294
303
 
295
304
  #define WSP_GGML_TENSOR_UNARY_OP_LOCALS \
@@ -504,7 +513,9 @@ extern "C" {
504
513
  WSP_GGML_OP_CONV_TRANSPOSE_1D,
505
514
  WSP_GGML_OP_IM2COL,
506
515
  WSP_GGML_OP_IM2COL_BACK,
516
+ WSP_GGML_OP_IM2COL_3D,
507
517
  WSP_GGML_OP_CONV_2D,
518
+ WSP_GGML_OP_CONV_3D,
508
519
  WSP_GGML_OP_CONV_2D_DW,
509
520
  WSP_GGML_OP_CONV_TRANSPOSE_2D,
510
521
  WSP_GGML_OP_POOL_1D,
@@ -565,6 +576,11 @@ extern "C" {
565
576
  WSP_GGML_UNARY_OP_HARDSIGMOID,
566
577
  WSP_GGML_UNARY_OP_EXP,
567
578
  WSP_GGML_UNARY_OP_GELU_ERF,
579
+ WSP_GGML_UNARY_OP_XIELU,
580
+ WSP_GGML_UNARY_OP_FLOOR,
581
+ WSP_GGML_UNARY_OP_CEIL,
582
+ WSP_GGML_UNARY_OP_ROUND,
583
+ WSP_GGML_UNARY_OP_TRUNC,
568
584
 
569
585
  WSP_GGML_UNARY_OP_COUNT,
570
586
  };
@@ -1139,6 +1155,58 @@ extern "C" {
1139
1155
  struct wsp_ggml_context * ctx,
1140
1156
  struct wsp_ggml_tensor * a);
1141
1157
 
1158
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_floor(
1159
+ struct wsp_ggml_context * ctx,
1160
+ struct wsp_ggml_tensor * a);
1161
+
1162
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_floor_inplace(
1163
+ struct wsp_ggml_context * ctx,
1164
+ struct wsp_ggml_tensor * a);
1165
+
1166
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_ceil(
1167
+ struct wsp_ggml_context * ctx,
1168
+ struct wsp_ggml_tensor * a);
1169
+
1170
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_ceil_inplace(
1171
+ struct wsp_ggml_context * ctx,
1172
+ struct wsp_ggml_tensor * a);
1173
+
1174
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_round(
1175
+ struct wsp_ggml_context * ctx,
1176
+ struct wsp_ggml_tensor * a);
1177
+
1178
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_round_inplace(
1179
+ struct wsp_ggml_context * ctx,
1180
+ struct wsp_ggml_tensor * a);
1181
+
1182
+ /**
1183
+ * Truncates the fractional part of each element in the tensor (towards zero).
1184
+ * For example: trunc(3.7) = 3.0, trunc(-2.9) = -2.0
1185
+ * Similar to std::trunc in C/C++.
1186
+ */
1187
+
1188
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_trunc(
1189
+ struct wsp_ggml_context * ctx,
1190
+ struct wsp_ggml_tensor * a);
1191
+
1192
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_trunc_inplace(
1193
+ struct wsp_ggml_context * ctx,
1194
+ struct wsp_ggml_tensor * a);
1195
+
1196
+
1197
+
1198
+ // xIELU activation function
1199
+ // x = x * (c_a(alpha_n) + c_b(alpha_p, beta) * sigmoid(beta * x)) + eps * (x > 0)
1200
+ // where c_a = softplus and c_b(a, b) = softplus(a) + b are constraining functions
1201
+ // that constrain the positive and negative source alpha values respectively
1202
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_xielu(
1203
+ struct wsp_ggml_context * ctx,
1204
+ struct wsp_ggml_tensor * a,
1205
+ float alpha_n,
1206
+ float alpha_p,
1207
+ float beta,
1208
+ float eps);
1209
+
1142
1210
  // gated linear unit ops
1143
1211
  // A: n columns, r rows,
1144
1212
  // result is n / 2 columns, r rows,
@@ -1395,6 +1463,7 @@ extern "C" {
1395
1463
  struct wsp_ggml_tensor * a,
1396
1464
  struct wsp_ggml_tensor * b);
1397
1465
 
1466
+ // note: casting from f32 to i32 will discard the fractional part
1398
1467
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_cast(
1399
1468
  struct wsp_ggml_context * ctx,
1400
1469
  struct wsp_ggml_tensor * a,
@@ -1519,7 +1588,11 @@ extern "C" {
1519
1588
  struct wsp_ggml_context * ctx,
1520
1589
  struct wsp_ggml_tensor * a);
1521
1590
 
1522
- // supports 3D: a->ne[2] == b->ne[1]
1591
+ // supports 4D a:
1592
+ // a [n_embd, ne1, ne2, ne3]
1593
+ // b I32 [n_rows, ne2, ne3, 1]
1594
+ //
1595
+ // return [n_embd, n_rows, ne2, ne3]
1523
1596
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_get_rows(
1524
1597
  struct wsp_ggml_context * ctx,
1525
1598
  struct wsp_ggml_tensor * a, // data
@@ -1601,6 +1674,13 @@ extern "C" {
1601
1674
  float scale,
1602
1675
  float max_bias);
1603
1676
 
1677
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_soft_max_ext_inplace(
1678
+ struct wsp_ggml_context * ctx,
1679
+ struct wsp_ggml_tensor * a,
1680
+ struct wsp_ggml_tensor * mask,
1681
+ float scale,
1682
+ float max_bias);
1683
+
1604
1684
  WSP_GGML_API void wsp_ggml_soft_max_add_sinks(
1605
1685
  struct wsp_ggml_tensor * a,
1606
1686
  struct wsp_ggml_tensor * sinks);
@@ -1862,6 +1942,41 @@ extern "C" {
1862
1942
  int d0, // dilation dimension 0
1863
1943
  int d1); // dilation dimension 1
1864
1944
 
1945
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_im2col_3d(
1946
+ struct wsp_ggml_context * ctx,
1947
+ struct wsp_ggml_tensor * a,
1948
+ struct wsp_ggml_tensor * b,
1949
+ int64_t IC,
1950
+ int s0, // stride width
1951
+ int s1, // stride height
1952
+ int s2, // stride depth
1953
+ int p0, // padding width
1954
+ int p1, // padding height
1955
+ int p2, // padding depth
1956
+ int d0, // dilation width
1957
+ int d1, // dilation height
1958
+ int d2, // dilation depth
1959
+ enum wsp_ggml_type dst_type);
1960
+
1961
+ // a: [OC*IC, KD, KH, KW]
1962
+ // b: [N*IC, ID, IH, IW]
1963
+ // result: [N*OC, OD, OH, OW]
1964
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_conv_3d(
1965
+ struct wsp_ggml_context * ctx,
1966
+ struct wsp_ggml_tensor * a,
1967
+ struct wsp_ggml_tensor * b,
1968
+ int64_t IC,
1969
+ int s0, // stride width
1970
+ int s1, // stride height
1971
+ int s2, // stride depth
1972
+ int p0, // padding width
1973
+ int p1, // padding height
1974
+ int p2, // padding depth
1975
+ int d0, // dilation width
1976
+ int d1, // dilation height
1977
+ int d2 // dilation depth
1978
+ );
1979
+
1865
1980
  // kernel size is a->ne[0] x a->ne[1]
1866
1981
  // stride is equal to kernel size
1867
1982
  // padding is zero
@@ -1933,6 +2048,23 @@ extern "C" {
1933
2048
  int d0, // dilation dimension 0
1934
2049
  int d1); // dilation dimension 1
1935
2050
 
2051
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_conv_3d_direct(
2052
+ struct wsp_ggml_context * ctx,
2053
+ struct wsp_ggml_tensor * a, // kernel [KW, KH, KD, IC * OC]
2054
+ struct wsp_ggml_tensor * b, // input [W, H, D, C * N]
2055
+ int s0, // stride
2056
+ int s1,
2057
+ int s2,
2058
+ int p0, // padding
2059
+ int p1,
2060
+ int p2,
2061
+ int d0, // dilation
2062
+ int d1,
2063
+ int d2,
2064
+ int n_channels,
2065
+ int n_batch,
2066
+ int n_channels_out);
2067
+
1936
2068
  enum wsp_ggml_op_pool {
1937
2069
  WSP_GGML_OP_POOL_MAX,
1938
2070
  WSP_GGML_OP_POOL_AVG,
@@ -2023,6 +2155,19 @@ extern "C" {
2023
2155
  int p2,
2024
2156
  int p3);
2025
2157
 
2158
+ WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_pad_ext(
2159
+ struct wsp_ggml_context * ctx,
2160
+ struct wsp_ggml_tensor * a,
2161
+ int lp0,
2162
+ int rp0,
2163
+ int lp1,
2164
+ int rp1,
2165
+ int lp2,
2166
+ int rp2,
2167
+ int lp3,
2168
+ int rp3
2169
+ );
2170
+
2026
2171
  // pad each dimension with reflection: [a, b, c, d] -> [b, a, b, c, d, c]
2027
2172
  WSP_GGML_API struct wsp_ggml_tensor * wsp_ggml_pad_reflect_1d(
2028
2173
  struct wsp_ggml_context * ctx,
@@ -24,6 +24,7 @@ struct job {
24
24
  int job_id;
25
25
  bool aborted = false;
26
26
  whisper_full_params params;
27
+ int n_processors = 1;
27
28
 
28
29
  ~job();
29
30
  bool is_aborted();
@@ -526,6 +526,7 @@ extern "C" {
526
526
  // use whisper_tokenize() to convert text to tokens
527
527
  // maximum of whisper_n_text_ctx()/2 tokens are used (typically 224)
528
528
  const char * initial_prompt;
529
+ bool carry_initial_prompt; // if true, always prepend initial_prompt to every decode window (may reduce conditioning on previous text)
529
530
  const whisper_token * prompt_tokens;
530
531
  int prompt_n_tokens;
531
532
 
@@ -6,7 +6,7 @@
6
6
  <dict>
7
7
  <key>Info.plist</key>
8
8
  <data>
9
- 9+jKFkf8K+DLOL7jFxUpqrh71/Y=
9
+ HE4CAM+4fVV3a4XZzcH+gj1efyQ=
10
10
  </data>
11
11
  </dict>
12
12
  <key>files2</key>
@@ -8,7 +8,7 @@
8
8
  extern "C" {
9
9
  #endif
10
10
 
11
- #define WSP_GGML_BACKEND_API_VERSION 1
11
+ #define WSP_GGML_BACKEND_API_VERSION 2
12
12
 
13
13
  //
14
14
  // Backend buffer type
@@ -114,6 +114,9 @@ extern "C" {
114
114
  void (*event_record)(wsp_ggml_backend_t backend, wsp_ggml_backend_event_t event);
115
115
  // wait for an event on on a different stream
116
116
  void (*event_wait) (wsp_ggml_backend_t backend, wsp_ggml_backend_event_t event);
117
+
118
+ // (optional) sort/optimize the nodes in the graph
119
+ void (*graph_optimize) (wsp_ggml_backend_t backend, struct wsp_ggml_cgraph * cgraph);
117
120
  };
118
121
 
119
122
  struct wsp_ggml_backend {
@@ -206,9 +209,6 @@ extern "C" {
206
209
  void * context;
207
210
  };
208
211
 
209
- // Internal backend registry API
210
- WSP_GGML_API void wsp_ggml_backend_register(wsp_ggml_backend_reg_t reg);
211
-
212
212
  // Add backend dynamic loading support to the backend
213
213
 
214
214
  // Initialize the backend