whisper.rn 0.4.0-rc.9 → 0.4.0

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 (183) hide show
  1. package/README.md +5 -1
  2. package/android/build.gradle +12 -3
  3. package/android/src/main/CMakeLists.txt +43 -13
  4. package/android/src/main/java/com/rnwhisper/WhisperContext.java +33 -35
  5. package/android/src/main/jni.cpp +9 -0
  6. package/android/src/main/jniLibs/arm64-v8a/librnwhisper.so +0 -0
  7. package/android/src/main/jniLibs/arm64-v8a/librnwhisper_v8fp16_va_2.so +0 -0
  8. package/android/src/main/jniLibs/armeabi-v7a/librnwhisper.so +0 -0
  9. package/android/src/main/jniLibs/armeabi-v7a/librnwhisper_vfpv4.so +0 -0
  10. package/android/src/main/jniLibs/x86_64/librnwhisper.so +0 -0
  11. package/android/src/main/jniLibs/x86_64/librnwhisper_x86_64.so +0 -0
  12. package/cpp/coreml/whisper-compat.h +10 -0
  13. package/cpp/coreml/whisper-compat.m +35 -0
  14. package/cpp/coreml/whisper-decoder-impl.h +27 -15
  15. package/cpp/coreml/whisper-decoder-impl.m +36 -10
  16. package/cpp/coreml/whisper-encoder-impl.h +21 -9
  17. package/cpp/coreml/whisper-encoder-impl.m +29 -3
  18. package/cpp/ggml-alloc.c +39 -37
  19. package/cpp/ggml-alloc.h +1 -1
  20. package/cpp/ggml-backend-impl.h +55 -27
  21. package/cpp/ggml-backend-reg.cpp +591 -0
  22. package/cpp/ggml-backend.cpp +336 -955
  23. package/cpp/ggml-backend.h +70 -42
  24. package/cpp/ggml-common.h +57 -49
  25. package/cpp/ggml-cpp.h +39 -0
  26. package/cpp/ggml-cpu/amx/amx.cpp +221 -0
  27. package/cpp/ggml-cpu/amx/amx.h +8 -0
  28. package/cpp/ggml-cpu/amx/common.h +91 -0
  29. package/cpp/ggml-cpu/amx/mmq.cpp +2511 -0
  30. package/cpp/ggml-cpu/amx/mmq.h +10 -0
  31. package/cpp/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
  32. package/cpp/ggml-cpu/arch/arm/quants.c +4113 -0
  33. package/cpp/ggml-cpu/arch/arm/repack.cpp +2162 -0
  34. package/cpp/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
  35. package/cpp/ggml-cpu/arch/x86/quants.c +4310 -0
  36. package/cpp/ggml-cpu/arch/x86/repack.cpp +3284 -0
  37. package/cpp/ggml-cpu/arch-fallback.h +184 -0
  38. package/cpp/ggml-cpu/binary-ops.cpp +158 -0
  39. package/cpp/ggml-cpu/binary-ops.h +16 -0
  40. package/cpp/ggml-cpu/common.h +72 -0
  41. package/cpp/ggml-cpu/ggml-cpu-impl.h +511 -0
  42. package/cpp/ggml-cpu/ggml-cpu.c +3473 -0
  43. package/cpp/ggml-cpu/ggml-cpu.cpp +671 -0
  44. package/cpp/ggml-cpu/ops.cpp +9085 -0
  45. package/cpp/ggml-cpu/ops.h +111 -0
  46. package/cpp/ggml-cpu/quants.c +1157 -0
  47. package/cpp/ggml-cpu/quants.h +89 -0
  48. package/cpp/ggml-cpu/repack.cpp +1570 -0
  49. package/cpp/ggml-cpu/repack.h +98 -0
  50. package/cpp/ggml-cpu/simd-mappings.h +1006 -0
  51. package/cpp/ggml-cpu/traits.cpp +36 -0
  52. package/cpp/ggml-cpu/traits.h +38 -0
  53. package/cpp/ggml-cpu/unary-ops.cpp +186 -0
  54. package/cpp/ggml-cpu/unary-ops.h +28 -0
  55. package/cpp/ggml-cpu/vec.cpp +321 -0
  56. package/cpp/ggml-cpu/vec.h +973 -0
  57. package/cpp/ggml-cpu.h +143 -0
  58. package/cpp/ggml-impl.h +417 -23
  59. package/cpp/ggml-metal-impl.h +622 -0
  60. package/cpp/ggml-metal.h +9 -9
  61. package/cpp/ggml-metal.m +3451 -1344
  62. package/cpp/ggml-opt.cpp +1037 -0
  63. package/cpp/ggml-opt.h +237 -0
  64. package/cpp/ggml-quants.c +296 -10818
  65. package/cpp/ggml-quants.h +78 -125
  66. package/cpp/ggml-threading.cpp +12 -0
  67. package/cpp/ggml-threading.h +14 -0
  68. package/cpp/ggml-whisper-sim.metallib +0 -0
  69. package/cpp/ggml-whisper.metallib +0 -0
  70. package/cpp/ggml.c +4633 -21450
  71. package/cpp/ggml.h +320 -661
  72. package/cpp/gguf.cpp +1347 -0
  73. package/cpp/gguf.h +202 -0
  74. package/cpp/rn-whisper.cpp +4 -11
  75. package/cpp/whisper-arch.h +197 -0
  76. package/cpp/whisper.cpp +2022 -495
  77. package/cpp/whisper.h +75 -18
  78. package/ios/CMakeLists.txt +95 -0
  79. package/ios/RNWhisper.h +5 -0
  80. package/ios/RNWhisperAudioUtils.m +4 -0
  81. package/ios/RNWhisperContext.h +5 -0
  82. package/ios/RNWhisperContext.mm +4 -2
  83. package/ios/rnwhisper.xcframework/Info.plist +74 -0
  84. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  85. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  86. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  87. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  88. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  89. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  90. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  91. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  92. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  93. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  94. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  95. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  96. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/ggml.h +2221 -0
  97. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/gguf.h +202 -0
  98. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  99. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  100. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  101. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  102. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Headers/whisper.h +739 -0
  103. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/Info.plist +0 -0
  104. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  105. package/ios/rnwhisper.xcframework/ios-arm64/rnwhisper.framework/rnwhisper +0 -0
  106. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  107. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  108. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  109. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  110. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  111. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  112. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  113. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  114. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  115. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  116. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  117. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  118. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +2221 -0
  119. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +202 -0
  120. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  121. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  122. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  123. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  124. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +739 -0
  125. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  126. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +101 -0
  127. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  128. package/ios/rnwhisper.xcframework/ios-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  129. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  130. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  131. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  132. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  133. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  134. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  135. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  136. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  137. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  138. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  139. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  140. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  141. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/ggml.h +2221 -0
  142. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/gguf.h +202 -0
  143. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  144. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  145. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  146. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  147. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Headers/whisper.h +739 -0
  148. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/Info.plist +0 -0
  149. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/ggml-whisper.metallib +0 -0
  150. package/ios/rnwhisper.xcframework/tvos-arm64/rnwhisper.framework/rnwhisper +0 -0
  151. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-alloc.h +76 -0
  152. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend-impl.h +255 -0
  153. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-backend.h +354 -0
  154. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-common.h +1861 -0
  155. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpp.h +39 -0
  156. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-cpu.h +143 -0
  157. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-impl.h +603 -0
  158. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal-impl.h +622 -0
  159. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-metal.h +66 -0
  160. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-opt.h +237 -0
  161. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-quants.h +100 -0
  162. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml-threading.h +14 -0
  163. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/ggml.h +2221 -0
  164. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/gguf.h +202 -0
  165. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-audioutils.h +14 -0
  166. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper-log.h +11 -0
  167. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/rn-whisper.h +52 -0
  168. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper-arch.h +197 -0
  169. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Headers/whisper.h +739 -0
  170. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/Info.plist +0 -0
  171. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/_CodeSignature/CodeResources +101 -0
  172. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/ggml-whisper-sim.metallib +0 -0
  173. package/ios/rnwhisper.xcframework/tvos-arm64_x86_64-simulator/rnwhisper.framework/rnwhisper +0 -0
  174. package/jest/mock.js +5 -0
  175. package/lib/commonjs/version.json +1 -1
  176. package/lib/module/version.json +1 -1
  177. package/package.json +10 -6
  178. package/src/version.json +1 -1
  179. package/whisper-rn.podspec +11 -18
  180. package/cpp/README.md +0 -4
  181. package/cpp/ggml-aarch64.c +0 -3209
  182. package/cpp/ggml-aarch64.h +0 -39
  183. package/cpp/ggml-cpu-impl.h +0 -614
package/cpp/gguf.h ADDED
@@ -0,0 +1,202 @@
1
+ // This file contains functionality related to "GGUF" files, the binary file format used by ggml.
2
+ // GGUF files have the following structure:
3
+ //
4
+ // 1. File magic "GGUF" (4 bytes).
5
+ // 2. File version (uint32_t).
6
+ // 3. Number of ggml tensors in file (int64_t).
7
+ // 4. Number of key-value-pairs in file (int64_t).
8
+ // 5. For each KV pair:
9
+ // 1. The key (string).
10
+ // 2. The value type (wsp_gguf_type).
11
+ // 3a. If the value type is WSP_GGUF_TYPE_ARRAY:
12
+ // 1. The type of the array (wsp_gguf_type).
13
+ // 2. The number of elements in the array (uint64_t).
14
+ // 3. The binary representation of each element in the array.
15
+ // 3b. Otherwise:
16
+ // 1. The binary representation of the value.
17
+ // 6. For each ggml tensor:
18
+ // 1. The tensor name (string).
19
+ // 2. The number of dimensions of the tensor (uint32_t).
20
+ // 3. For each dimension:
21
+ // 1. The size of the tensor in the dimension (int64_t).
22
+ // 4. The tensor data type (wsp_ggml_type).
23
+ // 5. The tensor data offset in the tensor data binary blob (uint64_t).
24
+ // 7. The tensor data binary blob (optional, aligned).
25
+ //
26
+ // Strings are serialized as the string length (uint64_t) followed by the C string without the null terminator.
27
+ // All enums are stored as int32_t.
28
+ // All bool values are stored as int8_t.
29
+ // If the special key "general.alignment" (uint32_t) is defined it is used for alignment,
30
+ // otherwise WSP_GGUF_DEFAULT_ALIGNMENT is used.
31
+ //
32
+ // Module maintainer: Johannes Gäßler (@JohannesGaessler, johannesg@5d6.de)
33
+
34
+ #pragma once
35
+
36
+ #include "ggml.h"
37
+
38
+ #include <stdbool.h>
39
+ #include <stdint.h>
40
+
41
+ #define WSP_GGUF_MAGIC "GGUF"
42
+ #define WSP_GGUF_VERSION 3
43
+
44
+ #define WSP_GGUF_KEY_GENERAL_ALIGNMENT "general.alignment"
45
+
46
+ #define WSP_GGUF_DEFAULT_ALIGNMENT 32
47
+
48
+ #ifdef __cplusplus
49
+ extern "C" {
50
+ #endif
51
+
52
+ // types that can be stored as GGUF KV data
53
+ enum wsp_gguf_type {
54
+ WSP_GGUF_TYPE_UINT8 = 0,
55
+ WSP_GGUF_TYPE_INT8 = 1,
56
+ WSP_GGUF_TYPE_UINT16 = 2,
57
+ WSP_GGUF_TYPE_INT16 = 3,
58
+ WSP_GGUF_TYPE_UINT32 = 4,
59
+ WSP_GGUF_TYPE_INT32 = 5,
60
+ WSP_GGUF_TYPE_FLOAT32 = 6,
61
+ WSP_GGUF_TYPE_BOOL = 7,
62
+ WSP_GGUF_TYPE_STRING = 8,
63
+ WSP_GGUF_TYPE_ARRAY = 9,
64
+ WSP_GGUF_TYPE_UINT64 = 10,
65
+ WSP_GGUF_TYPE_INT64 = 11,
66
+ WSP_GGUF_TYPE_FLOAT64 = 12,
67
+ WSP_GGUF_TYPE_COUNT, // marks the end of the enum
68
+ };
69
+
70
+ struct wsp_gguf_context;
71
+
72
+ struct wsp_gguf_init_params {
73
+ bool no_alloc;
74
+
75
+ // if not NULL, create a wsp_ggml_context and allocate the tensor data in it
76
+ struct wsp_ggml_context ** ctx;
77
+ };
78
+
79
+ WSP_GGML_API struct wsp_gguf_context * wsp_gguf_init_empty(void);
80
+ WSP_GGML_API struct wsp_gguf_context * wsp_gguf_init_from_file(const char * fname, struct wsp_gguf_init_params params);
81
+ //WSP_GGML_API struct wsp_gguf_context * wsp_gguf_init_from_buffer(..);
82
+
83
+ WSP_GGML_API void wsp_gguf_free(struct wsp_gguf_context * ctx);
84
+
85
+ WSP_GGML_API const char * wsp_gguf_type_name(enum wsp_gguf_type type);
86
+
87
+ WSP_GGML_API uint32_t wsp_gguf_get_version (const struct wsp_gguf_context * ctx);
88
+ WSP_GGML_API size_t wsp_gguf_get_alignment (const struct wsp_gguf_context * ctx);
89
+ WSP_GGML_API size_t wsp_gguf_get_data_offset(const struct wsp_gguf_context * ctx);
90
+
91
+ WSP_GGML_API int64_t wsp_gguf_get_n_kv(const struct wsp_gguf_context * ctx);
92
+ WSP_GGML_API int64_t wsp_gguf_find_key(const struct wsp_gguf_context * ctx, const char * key); // returns -1 if key is not found
93
+ WSP_GGML_API const char * wsp_gguf_get_key (const struct wsp_gguf_context * ctx, int64_t key_id);
94
+
95
+ WSP_GGML_API enum wsp_gguf_type wsp_gguf_get_kv_type (const struct wsp_gguf_context * ctx, int64_t key_id);
96
+ WSP_GGML_API enum wsp_gguf_type wsp_gguf_get_arr_type(const struct wsp_gguf_context * ctx, int64_t key_id);
97
+
98
+ // will abort if the wrong type is used for the key
99
+ WSP_GGML_API uint8_t wsp_gguf_get_val_u8 (const struct wsp_gguf_context * ctx, int64_t key_id);
100
+ WSP_GGML_API int8_t wsp_gguf_get_val_i8 (const struct wsp_gguf_context * ctx, int64_t key_id);
101
+ WSP_GGML_API uint16_t wsp_gguf_get_val_u16 (const struct wsp_gguf_context * ctx, int64_t key_id);
102
+ WSP_GGML_API int16_t wsp_gguf_get_val_i16 (const struct wsp_gguf_context * ctx, int64_t key_id);
103
+ WSP_GGML_API uint32_t wsp_gguf_get_val_u32 (const struct wsp_gguf_context * ctx, int64_t key_id);
104
+ WSP_GGML_API int32_t wsp_gguf_get_val_i32 (const struct wsp_gguf_context * ctx, int64_t key_id);
105
+ WSP_GGML_API float wsp_gguf_get_val_f32 (const struct wsp_gguf_context * ctx, int64_t key_id);
106
+ WSP_GGML_API uint64_t wsp_gguf_get_val_u64 (const struct wsp_gguf_context * ctx, int64_t key_id);
107
+ WSP_GGML_API int64_t wsp_gguf_get_val_i64 (const struct wsp_gguf_context * ctx, int64_t key_id);
108
+ WSP_GGML_API double wsp_gguf_get_val_f64 (const struct wsp_gguf_context * ctx, int64_t key_id);
109
+ WSP_GGML_API bool wsp_gguf_get_val_bool(const struct wsp_gguf_context * ctx, int64_t key_id);
110
+ WSP_GGML_API const char * wsp_gguf_get_val_str (const struct wsp_gguf_context * ctx, int64_t key_id);
111
+ WSP_GGML_API const void * wsp_gguf_get_val_data(const struct wsp_gguf_context * ctx, int64_t key_id);
112
+ WSP_GGML_API size_t wsp_gguf_get_arr_n (const struct wsp_gguf_context * ctx, int64_t key_id);
113
+
114
+ // get raw pointer to the first element of the array with the given key_id
115
+ // for bool arrays, note that they are always stored as int8 on all platforms (usually this makes no difference)
116
+ WSP_GGML_API const void * wsp_gguf_get_arr_data(const struct wsp_gguf_context * ctx, int64_t key_id);
117
+
118
+ // get ith C string from array with given key_id
119
+ WSP_GGML_API const char * wsp_gguf_get_arr_str (const struct wsp_gguf_context * ctx, int64_t key_id, size_t i);
120
+
121
+ WSP_GGML_API int64_t wsp_gguf_get_n_tensors (const struct wsp_gguf_context * ctx);
122
+ WSP_GGML_API int64_t wsp_gguf_find_tensor (const struct wsp_gguf_context * ctx, const char * name); // returns -1 if the tensor is not found
123
+ WSP_GGML_API size_t wsp_gguf_get_tensor_offset(const struct wsp_gguf_context * ctx, int64_t tensor_id);
124
+ WSP_GGML_API const char * wsp_gguf_get_tensor_name (const struct wsp_gguf_context * ctx, int64_t tensor_id);
125
+ WSP_GGML_API enum wsp_ggml_type wsp_gguf_get_tensor_type (const struct wsp_gguf_context * ctx, int64_t tensor_id);
126
+ WSP_GGML_API size_t wsp_gguf_get_tensor_size (const struct wsp_gguf_context * ctx, int64_t tensor_id);
127
+
128
+ // removes key if it exists, returns id that the key had prior to removal (-1 if it didn't exist)
129
+ WSP_GGML_API int64_t wsp_gguf_remove_key(struct wsp_gguf_context * ctx, const char * key);
130
+
131
+ // overrides an existing KV pair or adds a new one, the new KV pair is always at the back
132
+ WSP_GGML_API void wsp_gguf_set_val_u8 (struct wsp_gguf_context * ctx, const char * key, uint8_t val);
133
+ WSP_GGML_API void wsp_gguf_set_val_i8 (struct wsp_gguf_context * ctx, const char * key, int8_t val);
134
+ WSP_GGML_API void wsp_gguf_set_val_u16 (struct wsp_gguf_context * ctx, const char * key, uint16_t val);
135
+ WSP_GGML_API void wsp_gguf_set_val_i16 (struct wsp_gguf_context * ctx, const char * key, int16_t val);
136
+ WSP_GGML_API void wsp_gguf_set_val_u32 (struct wsp_gguf_context * ctx, const char * key, uint32_t val);
137
+ WSP_GGML_API void wsp_gguf_set_val_i32 (struct wsp_gguf_context * ctx, const char * key, int32_t val);
138
+ WSP_GGML_API void wsp_gguf_set_val_f32 (struct wsp_gguf_context * ctx, const char * key, float val);
139
+ WSP_GGML_API void wsp_gguf_set_val_u64 (struct wsp_gguf_context * ctx, const char * key, uint64_t val);
140
+ WSP_GGML_API void wsp_gguf_set_val_i64 (struct wsp_gguf_context * ctx, const char * key, int64_t val);
141
+ WSP_GGML_API void wsp_gguf_set_val_f64 (struct wsp_gguf_context * ctx, const char * key, double val);
142
+ WSP_GGML_API void wsp_gguf_set_val_bool(struct wsp_gguf_context * ctx, const char * key, bool val);
143
+ WSP_GGML_API void wsp_gguf_set_val_str (struct wsp_gguf_context * ctx, const char * key, const char * val);
144
+
145
+ // creates a new array with n elements of the given type and copies the corresponding number of bytes from data
146
+ WSP_GGML_API void wsp_gguf_set_arr_data(struct wsp_gguf_context * ctx, const char * key, enum wsp_gguf_type type, const void * data, size_t n);
147
+
148
+ // creates a new array with n strings and copies the corresponding strings from data
149
+ WSP_GGML_API void wsp_gguf_set_arr_str (struct wsp_gguf_context * ctx, const char * key, const char ** data, size_t n);
150
+
151
+ // set or add KV pairs from another context
152
+ WSP_GGML_API void wsp_gguf_set_kv(struct wsp_gguf_context * ctx, const struct wsp_gguf_context * src);
153
+
154
+ // add tensor to GGUF context, tensor name must be unique
155
+ WSP_GGML_API void wsp_gguf_add_tensor(struct wsp_gguf_context * ctx, const struct wsp_ggml_tensor * tensor);
156
+
157
+ // after changing a tensor's type, the offsets of all tensors with higher indices are immediately recalculated
158
+ // in such a way that the tensor data remains as one contiguous block (except for padding)
159
+ WSP_GGML_API void wsp_gguf_set_tensor_type(struct wsp_gguf_context * ctx, const char * name, enum wsp_ggml_type type);
160
+
161
+ // assumes that at least wsp_gguf_get_tensor_size bytes can be read from data
162
+ WSP_GGML_API void wsp_gguf_set_tensor_data(struct wsp_gguf_context * ctx, const char * name, const void * data);
163
+
164
+ // writing gguf files can be done in 3 ways:
165
+ //
166
+ // - write the entire wsp_gguf_context to a binary file in a single pass:
167
+ //
168
+ // wsp_gguf_write_to_file(ctx, fname, /*only_meta =*/ false);
169
+ //
170
+ // - write only the meta data to a file, then re-open the file and append the tensor data:
171
+ //
172
+ // wsp_gguf_write_to_file(ctx, fname, /*only_meta =*/ true);
173
+ // FILE * f = fopen(fname, "ab");
174
+ // fwrite(f, ...); // write tensor data
175
+ // fclose(f);
176
+ //
177
+ // - first prepare a file with a placeholder for the meta data, write the tensor data, then write the meta data:
178
+ //
179
+ // FILE * f = fopen(fname, "wb");
180
+ // const size_t size_meta = wsp_gguf_get_meta_size(ctx);
181
+ // fseek(f, size_meta, SEEK_SET);
182
+ // fwrite(f, ...); // write tensor data
183
+ // void * data = malloc(size_meta);
184
+ // wsp_gguf_get_meta_data(ctx, data);
185
+ // rewind(f);
186
+ // fwrite(data, 1, data, f);
187
+ // free(data);
188
+ // fclose(f);
189
+ //
190
+
191
+ // write the entire context to a binary file
192
+ WSP_GGML_API bool wsp_gguf_write_to_file(const struct wsp_gguf_context * ctx, const char * fname, bool only_meta);
193
+
194
+ // get the size in bytes of the meta data (header, kv pairs, tensor info) including padding
195
+ WSP_GGML_API size_t wsp_gguf_get_meta_size(const struct wsp_gguf_context * ctx);
196
+
197
+ // writes the meta data to pointer "data"
198
+ WSP_GGML_API void wsp_gguf_get_meta_data(const struct wsp_gguf_context * ctx, void * data);
199
+
200
+ #ifdef __cplusplus
201
+ }
202
+ #endif
@@ -17,10 +17,8 @@ const char * system_info(void) {
17
17
  if (wsp_ggml_cpu_has_fma() == 1) s += "FMA ";
18
18
  if (wsp_ggml_cpu_has_neon() == 1) s += "NEON ";
19
19
  if (wsp_ggml_cpu_has_arm_fma() == 1) s += "ARM_FMA ";
20
- if (wsp_ggml_cpu_has_metal() == 1) s += "METAL ";
21
20
  if (wsp_ggml_cpu_has_f16c() == 1) s += "F16C ";
22
21
  if (wsp_ggml_cpu_has_fp16_va() == 1) s += "FP16_VA ";
23
- if (wsp_ggml_cpu_has_blas() == 1) s += "BLAS ";
24
22
  if (wsp_ggml_cpu_has_sse3() == 1) s += "SSE3 ";
25
23
  if (wsp_ggml_cpu_has_ssse3() == 1) s += "SSSE3 ";
26
24
  if (wsp_ggml_cpu_has_vsx() == 1) s += "VSX ";
@@ -85,18 +83,13 @@ std::string bench(struct whisper_context * ctx, int n_threads) {
85
83
 
86
84
  const struct whisper_timings * timings = whisper_get_timings(ctx);
87
85
 
88
- const int32_t n_encode = std::max(1, timings->n_encode);
89
- const int32_t n_decode = std::max(1, timings->n_decode);
90
- const int32_t n_batchd = std::max(1, timings->n_batchd);
91
- const int32_t n_prompt = std::max(1, timings->n_prompt);
92
-
93
86
  return std::string("[") +
94
87
  "\"" + system_info() + "\"," +
95
88
  std::to_string(n_threads) + "," +
96
- std::to_string(1e-3f * timings->t_encode_us / n_encode) + "," +
97
- std::to_string(1e-3f * timings->t_decode_us / n_decode) + "," +
98
- std::to_string(1e-3f * timings->t_batchd_us / n_batchd) + "," +
99
- std::to_string(1e-3f * timings->t_prompt_us / n_prompt) + "]";
89
+ std::to_string(timings->encode_ms) + "," +
90
+ std::to_string(timings->decode_ms) + "," +
91
+ std::to_string(timings->batchd_ms) + "," +
92
+ std::to_string(timings->prompt_ms) + "]";
100
93
  }
101
94
 
102
95
  void high_pass_filter(std::vector<float> & data, float cutoff, float sample_rate) {
@@ -0,0 +1,197 @@
1
+ #pragma once
2
+
3
+ #include "ggml.h"
4
+
5
+ #include <map>
6
+
7
+ enum asr_tensor {
8
+ ASR_TENSOR_ENC_POS_EMBD,
9
+ ASR_TENSOR_DEC_POS_EMBD,
10
+ ASR_TENSOR_DEC_TOKEN_EMBD_WEIGHT,
11
+ ASR_TENSOR_LN_WEIGHT,
12
+ ASR_TENSOR_LN_BIAS,
13
+ ASR_TENSOR_CONV1_WEIGHT,
14
+ ASR_TENSOR_CONV1_BIAS,
15
+ ASR_TENSOR_CONV2_WEIGHT,
16
+ ASR_TENSOR_CONV2_BIAS,
17
+ ASR_TENSOR_LN_POST_WEIGHT,
18
+ ASR_TENSOR_LN_POST_BIAS,
19
+ ASR_TENSOR_MLP_LN_WEIGHT,
20
+ ASR_TENSOR_MLP_LN_BIAS,
21
+ ASR_TENSOR_MLP_0_WEIGHT,
22
+ ASR_TENSOR_MLP_0_BIAS,
23
+ ASR_TENSOR_MLP_2_WEIGHT,
24
+ ASR_TENSOR_MLP_2_BIAS,
25
+ ASR_TENSOR_ATTN_LN_WEIGHT,
26
+ ASR_TENSOR_ATTN_LN_BIAS,
27
+ ASR_TENSOR_ATTN_QUERY_WEIGHT,
28
+ ASR_TENSOR_ATTN_QUERY_BIAS,
29
+ ASR_TENSOR_ATTN_KEY_WEIGHT,
30
+ ASR_TENSOR_ATTN_VALUE_WEIGHT,
31
+ ASR_TENSOR_ATTN_VALUE_BIAS,
32
+ ASR_TENSOR_ATTN_OUT_WEIGHT,
33
+ ASR_TENSOR_ATTN_OUT_BIAS,
34
+ };
35
+
36
+ enum asr_system {
37
+ ASR_SYSTEM_ENCODER,
38
+ ASR_SYSTEM_DECODER,
39
+ ASR_SYSTEM_CROSS
40
+ };
41
+
42
+ static const std::map<asr_system, std::map<asr_tensor, const char *>> ASR_TENSOR_NAMES = {
43
+ {
44
+ ASR_SYSTEM_ENCODER,
45
+ {
46
+ {ASR_TENSOR_ENC_POS_EMBD, "encoder.positional_embedding"},
47
+ {ASR_TENSOR_CONV1_WEIGHT, "encoder.conv1.weight"},
48
+ {ASR_TENSOR_CONV1_BIAS, "encoder.conv1.bias"},
49
+ {ASR_TENSOR_CONV2_WEIGHT, "encoder.conv2.weight"},
50
+ {ASR_TENSOR_CONV2_BIAS, "encoder.conv2.bias"},
51
+ {ASR_TENSOR_LN_WEIGHT, "encoder.ln_post.weight"},
52
+ {ASR_TENSOR_LN_POST_BIAS, "encoder.ln_post.bias"},
53
+ {ASR_TENSOR_MLP_LN_WEIGHT, "encoder.blocks.%d.mlp_ln.weight"},
54
+ {ASR_TENSOR_MLP_LN_BIAS, "encoder.blocks.%d.mlp_ln.bias"},
55
+ {ASR_TENSOR_MLP_0_WEIGHT, "encoder.blocks.%d.mlp.0.weight"},
56
+ {ASR_TENSOR_MLP_0_BIAS, "encoder.blocks.%d.mlp.0.bias"},
57
+ {ASR_TENSOR_MLP_2_WEIGHT, "encoder.blocks.%d.mlp.2.weight"},
58
+ {ASR_TENSOR_MLP_2_BIAS, "encoder.blocks.%d.mlp.2.bias"},
59
+ {ASR_TENSOR_ATTN_LN_WEIGHT, "encoder.blocks.%d.attn_ln.weight"},
60
+ {ASR_TENSOR_ATTN_LN_BIAS, "encoder.blocks.%d.attn_ln.bias"},
61
+ {ASR_TENSOR_ATTN_QUERY_WEIGHT, "encoder.blocks.%d.attn.query.weight"},
62
+ {ASR_TENSOR_ATTN_QUERY_BIAS, "encoder.blocks.%d.attn.query.bias"},
63
+ {ASR_TENSOR_ATTN_KEY_WEIGHT, "encoder.blocks.%d.attn.key.weight"},
64
+ {ASR_TENSOR_ATTN_VALUE_WEIGHT, "encoder.blocks.%d.attn.value.weight"},
65
+ {ASR_TENSOR_ATTN_VALUE_BIAS, "encoder.blocks.%d.attn.value.bias"},
66
+ {ASR_TENSOR_ATTN_OUT_WEIGHT, "encoder.blocks.%d.attn.out.weight"},
67
+ {ASR_TENSOR_ATTN_OUT_BIAS, "encoder.blocks.%d.attn.out.bias"},
68
+ },
69
+ },
70
+ {
71
+ ASR_SYSTEM_DECODER,
72
+ {
73
+ {ASR_TENSOR_DEC_POS_EMBD, "decoder.positional_embedding"},
74
+ {ASR_TENSOR_DEC_TOKEN_EMBD_WEIGHT, "decoder.token_embedding.weight"},
75
+ {ASR_TENSOR_LN_WEIGHT, "decoder.ln.weight"},
76
+ {ASR_TENSOR_LN_BIAS, "decoder.ln.bias"},
77
+
78
+ {ASR_TENSOR_MLP_LN_WEIGHT, "decoder.blocks.%d.mlp_ln.weight"},
79
+ {ASR_TENSOR_MLP_LN_BIAS, "decoder.blocks.%d.mlp_ln.bias"},
80
+ {ASR_TENSOR_MLP_0_WEIGHT, "decoder.blocks.%d.mlp.0.weight"},
81
+ {ASR_TENSOR_MLP_0_BIAS, "decoder.blocks.%d.mlp.0.bias"},
82
+ {ASR_TENSOR_MLP_2_WEIGHT, "decoder.blocks.%d.mlp.2.weight"},
83
+ {ASR_TENSOR_MLP_2_BIAS, "decoder.blocks.%d.mlp.2.bias"},
84
+ {ASR_TENSOR_ATTN_LN_WEIGHT, "decoder.blocks.%d.attn_ln.weight"},
85
+ {ASR_TENSOR_ATTN_LN_BIAS, "decoder.blocks.%d.attn_ln.bias"},
86
+ {ASR_TENSOR_ATTN_QUERY_WEIGHT, "decoder.blocks.%d.attn.query.weight"},
87
+ {ASR_TENSOR_ATTN_QUERY_BIAS, "decoder.blocks.%d.attn.query.bias"},
88
+ {ASR_TENSOR_ATTN_KEY_WEIGHT, "decoder.blocks.%d.attn.key.weight"},
89
+ {ASR_TENSOR_ATTN_VALUE_WEIGHT, "decoder.blocks.%d.attn.value.weight"},
90
+ {ASR_TENSOR_ATTN_VALUE_BIAS, "decoder.blocks.%d.attn.value.bias"},
91
+ {ASR_TENSOR_ATTN_OUT_WEIGHT, "decoder.blocks.%d.attn.out.weight"},
92
+ {ASR_TENSOR_ATTN_OUT_BIAS, "decoder.blocks.%d.attn.out.bias"},
93
+ },
94
+ },
95
+ {
96
+ ASR_SYSTEM_CROSS,
97
+ {
98
+ {ASR_TENSOR_ATTN_LN_WEIGHT, "decoder.blocks.%d.cross_attn_ln.weight"},
99
+ {ASR_TENSOR_ATTN_LN_BIAS, "decoder.blocks.%d.cross_attn_ln.bias"},
100
+ {ASR_TENSOR_ATTN_QUERY_WEIGHT, "decoder.blocks.%d.cross_attn.query.weight"},
101
+ {ASR_TENSOR_ATTN_QUERY_BIAS, "decoder.blocks.%d.cross_attn.query.bias"},
102
+ {ASR_TENSOR_ATTN_KEY_WEIGHT, "decoder.blocks.%d.cross_attn.key.weight"},
103
+ {ASR_TENSOR_ATTN_VALUE_WEIGHT, "decoder.blocks.%d.cross_attn.value.weight"},
104
+ {ASR_TENSOR_ATTN_VALUE_BIAS, "decoder.blocks.%d.cross_attn.value.bias"},
105
+ {ASR_TENSOR_ATTN_OUT_WEIGHT, "decoder.blocks.%d.cross_attn.out.weight"},
106
+ {ASR_TENSOR_ATTN_OUT_BIAS, "decoder.blocks.%d.cross_attn.out.bias"},
107
+ },
108
+ },
109
+ };
110
+
111
+ static const std::map<asr_tensor, wsp_ggml_op> ASR_TENSOR_INFO = {
112
+ {ASR_TENSOR_ENC_POS_EMBD, WSP_GGML_OP_ADD},
113
+ {ASR_TENSOR_DEC_POS_EMBD, WSP_GGML_OP_GET_ROWS},
114
+ // Note: ASR_TENSOR_DEC_TOKEN_EMBD_WEIGHT is also used by WSP_GGML_OP_MAT_MUL. Need to figure out a way how to handle
115
+ // weight tensors that are used by multiple different operators when extra_buffer_type implementations accelerate
116
+ // more than just WSP_GGML_OP_MUL_MAT.
117
+ {ASR_TENSOR_DEC_TOKEN_EMBD_WEIGHT, WSP_GGML_OP_GET_ROWS},
118
+ {ASR_TENSOR_LN_WEIGHT, WSP_GGML_OP_MUL},
119
+ {ASR_TENSOR_LN_BIAS, WSP_GGML_OP_ADD},
120
+ {ASR_TENSOR_CONV1_WEIGHT, WSP_GGML_OP_IM2COL},
121
+ {ASR_TENSOR_CONV1_BIAS, WSP_GGML_OP_ADD},
122
+ {ASR_TENSOR_CONV2_WEIGHT, WSP_GGML_OP_IM2COL},
123
+ {ASR_TENSOR_CONV2_BIAS, WSP_GGML_OP_ADD},
124
+ {ASR_TENSOR_LN_POST_WEIGHT, WSP_GGML_OP_MUL},
125
+ {ASR_TENSOR_LN_POST_BIAS, WSP_GGML_OP_ADD},
126
+ {ASR_TENSOR_MLP_LN_WEIGHT, WSP_GGML_OP_MUL},
127
+ {ASR_TENSOR_MLP_LN_BIAS, WSP_GGML_OP_ADD},
128
+ {ASR_TENSOR_MLP_0_WEIGHT, WSP_GGML_OP_MUL_MAT},
129
+ {ASR_TENSOR_MLP_0_BIAS, WSP_GGML_OP_ADD},
130
+ {ASR_TENSOR_MLP_2_WEIGHT, WSP_GGML_OP_MUL_MAT},
131
+ {ASR_TENSOR_MLP_2_BIAS, WSP_GGML_OP_ADD},
132
+ {ASR_TENSOR_ATTN_LN_WEIGHT, WSP_GGML_OP_MUL},
133
+ {ASR_TENSOR_ATTN_LN_BIAS, WSP_GGML_OP_ADD},
134
+ {ASR_TENSOR_ATTN_QUERY_WEIGHT, WSP_GGML_OP_MUL_MAT},
135
+ {ASR_TENSOR_ATTN_QUERY_BIAS, WSP_GGML_OP_ADD},
136
+ {ASR_TENSOR_ATTN_KEY_WEIGHT, WSP_GGML_OP_MUL_MAT},
137
+ {ASR_TENSOR_ATTN_VALUE_WEIGHT, WSP_GGML_OP_MUL_MAT},
138
+ {ASR_TENSOR_ATTN_VALUE_BIAS, WSP_GGML_OP_ADD},
139
+ {ASR_TENSOR_ATTN_OUT_WEIGHT, WSP_GGML_OP_MUL_MAT},
140
+ {ASR_TENSOR_ATTN_OUT_BIAS, WSP_GGML_OP_ADD},
141
+ };
142
+
143
+ enum vad_tensor {
144
+ VAD_TENSOR_STFT_BASIS,
145
+ VAD_TENSOR_ENC_0_WEIGHT,
146
+ VAD_TENSOR_ENC_0_BIAS,
147
+ VAD_TENSOR_ENC_1_WEIGHT,
148
+ VAD_TENSOR_ENC_1_BIAS,
149
+ VAD_TENSOR_ENC_2_WEIGHT,
150
+ VAD_TENSOR_ENC_2_BIAS,
151
+ VAD_TENSOR_ENC_3_WEIGHT,
152
+ VAD_TENSOR_ENC_3_BIAS,
153
+ VAD_TENSOR_LSTM_WEIGHT_IH,
154
+ VAD_TENSOR_LSTM_WEIGHT_HH,
155
+ VAD_TENSOR_LSTM_BIAS_IH,
156
+ VAD_TENSOR_LSTM_BIAS_HH,
157
+ VAD_TENSOR_FINAL_CONV_WEIGHT,
158
+ VAD_TENSOR_FINAL_CONV_BIAS,
159
+ };
160
+
161
+ static const std::map<vad_tensor, wsp_ggml_op> VAD_TENSOR_OPS = {
162
+ {VAD_TENSOR_STFT_BASIS, WSP_GGML_OP_IM2COL},
163
+ {VAD_TENSOR_ENC_0_WEIGHT, WSP_GGML_OP_IM2COL},
164
+ {VAD_TENSOR_ENC_0_BIAS, WSP_GGML_OP_ADD},
165
+ {VAD_TENSOR_ENC_1_WEIGHT, WSP_GGML_OP_IM2COL},
166
+ {VAD_TENSOR_ENC_1_BIAS, WSP_GGML_OP_ADD},
167
+ {VAD_TENSOR_ENC_2_WEIGHT, WSP_GGML_OP_IM2COL},
168
+ {VAD_TENSOR_ENC_2_BIAS, WSP_GGML_OP_ADD},
169
+ {VAD_TENSOR_ENC_3_WEIGHT, WSP_GGML_OP_IM2COL},
170
+ {VAD_TENSOR_ENC_3_BIAS, WSP_GGML_OP_ADD},
171
+
172
+ {VAD_TENSOR_LSTM_WEIGHT_IH, WSP_GGML_OP_MUL_MAT},
173
+ {VAD_TENSOR_LSTM_WEIGHT_HH, WSP_GGML_OP_MUL_MAT},
174
+ {VAD_TENSOR_LSTM_BIAS_IH, WSP_GGML_OP_ADD},
175
+ {VAD_TENSOR_LSTM_BIAS_HH, WSP_GGML_OP_ADD},
176
+
177
+ {VAD_TENSOR_FINAL_CONV_WEIGHT, WSP_GGML_OP_IM2COL},
178
+ {VAD_TENSOR_FINAL_CONV_BIAS, WSP_GGML_OP_ADD}
179
+ };
180
+
181
+ static const std::map<vad_tensor, const char *> VAD_TENSOR_NAMES = {
182
+ {VAD_TENSOR_STFT_BASIS, "_model.stft.forward_basis_buffer"},
183
+ {VAD_TENSOR_ENC_0_WEIGHT, "_model.encoder.0.reparam_conv.weight"},
184
+ {VAD_TENSOR_ENC_0_BIAS, "_model.encoder.0.reparam_conv.bias"},
185
+ {VAD_TENSOR_ENC_1_WEIGHT, "_model.encoder.1.reparam_conv.weight"},
186
+ {VAD_TENSOR_ENC_1_BIAS, "_model.encoder.1.reparam_conv.bias"},
187
+ {VAD_TENSOR_ENC_2_WEIGHT, "_model.encoder.2.reparam_conv.weight"},
188
+ {VAD_TENSOR_ENC_2_BIAS, "_model.encoder.2.reparam_conv.bias"},
189
+ {VAD_TENSOR_ENC_3_WEIGHT, "_model.encoder.3.reparam_conv.weight"},
190
+ {VAD_TENSOR_ENC_3_BIAS, "_model.encoder.3.reparam_conv.bias"},
191
+ {VAD_TENSOR_LSTM_WEIGHT_IH, "_model.decoder.rnn.weight_ih"},
192
+ {VAD_TENSOR_LSTM_WEIGHT_HH, "_model.decoder.rnn.weight_hh"},
193
+ {VAD_TENSOR_LSTM_BIAS_IH, "_model.decoder.rnn.bias_ih"},
194
+ {VAD_TENSOR_LSTM_BIAS_HH, "_model.decoder.rnn.bias_hh"},
195
+ {VAD_TENSOR_FINAL_CONV_WEIGHT, "_model.decoder.decoder.2.weight"},
196
+ {VAD_TENSOR_FINAL_CONV_BIAS, "_model.decoder.decoder.2.bias"}
197
+ };