whispercpp 1.2.0.2 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/LICENSE +1 -1
- data/README.md +165 -434
- data/Rakefile +46 -86
- data/ext/.gitignore +13 -0
- data/ext/cpu.mk +9 -0
- data/ext/{dr_wav.h → examples/dr_wav.h} +3560 -1179
- data/ext/extconf.rb +185 -7
- data/ext/ggml/include/ggml-alloc.h +76 -0
- data/ext/ggml/include/ggml-backend.h +352 -0
- data/ext/ggml/include/ggml-blas.h +25 -0
- data/ext/ggml/include/ggml-cann.h +123 -0
- data/ext/ggml/include/ggml-cpp.h +38 -0
- data/ext/ggml/include/ggml-cpu.h +135 -0
- data/ext/ggml/include/ggml-cuda.h +47 -0
- data/ext/ggml/include/ggml-kompute.h +50 -0
- data/ext/ggml/include/ggml-metal.h +66 -0
- data/ext/ggml/include/ggml-opencl.h +26 -0
- data/ext/ggml/include/ggml-opt.h +216 -0
- data/ext/ggml/include/ggml-rpc.h +28 -0
- data/ext/ggml/include/ggml-sycl.h +49 -0
- data/ext/ggml/include/ggml-vulkan.h +31 -0
- data/ext/ggml/include/ggml.h +2285 -0
- data/ext/ggml/src/ggml-alloc.c +1037 -0
- data/ext/ggml/src/ggml-amx/common.h +94 -0
- data/ext/ggml/src/ggml-amx/ggml-amx.cpp +446 -0
- data/ext/ggml/src/ggml-amx/mmq.cpp +2510 -0
- data/ext/ggml/src/ggml-amx/mmq.h +17 -0
- data/ext/ggml/src/ggml-backend-impl.h +256 -0
- data/ext/ggml/src/ggml-backend-reg.cpp +552 -0
- data/ext/ggml/src/ggml-backend.cpp +1999 -0
- data/ext/ggml/src/ggml-blas/ggml-blas.cpp +517 -0
- data/ext/ggml/src/ggml-cann/acl_tensor.cpp +175 -0
- data/ext/ggml/src/ggml-cann/acl_tensor.h +258 -0
- data/ext/ggml/src/ggml-cann/aclnn_ops.cpp +3427 -0
- data/ext/ggml/src/ggml-cann/aclnn_ops.h +592 -0
- data/ext/ggml/src/ggml-cann/common.h +286 -0
- data/ext/ggml/src/ggml-cann/ggml-cann.cpp +2188 -0
- data/ext/ggml/src/ggml-cann/kernels/ascendc_kernels.h +19 -0
- data/ext/ggml/src/ggml-cann/kernels/dup.cpp +236 -0
- data/ext/ggml/src/ggml-cann/kernels/get_row_f16.cpp +197 -0
- data/ext/ggml/src/ggml-cann/kernels/get_row_f32.cpp +190 -0
- data/ext/ggml/src/ggml-cann/kernels/get_row_q4_0.cpp +204 -0
- data/ext/ggml/src/ggml-cann/kernels/get_row_q8_0.cpp +191 -0
- data/ext/ggml/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +218 -0
- data/ext/ggml/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +216 -0
- data/ext/ggml/src/ggml-cann/kernels/quantize_float_to_q4_0.cpp +295 -0
- data/ext/ggml/src/ggml-common.h +1853 -0
- data/ext/ggml/src/ggml-cpu/amx/amx.cpp +220 -0
- data/ext/ggml/src/ggml-cpu/amx/amx.h +8 -0
- data/ext/ggml/src/ggml-cpu/amx/common.h +91 -0
- data/ext/ggml/src/ggml-cpu/amx/mmq.cpp +2511 -0
- data/ext/ggml/src/ggml-cpu/amx/mmq.h +10 -0
- data/ext/ggml/src/ggml-cpu/cpu-feats-x86.cpp +323 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +4262 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-aarch64.h +8 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-hbm.cpp +55 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-hbm.h +8 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-impl.h +386 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-quants.c +10835 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-quants.h +63 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-traits.cpp +36 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu-traits.h +38 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu.c +14123 -0
- data/ext/ggml/src/ggml-cpu/ggml-cpu.cpp +622 -0
- data/ext/ggml/src/ggml-cpu/llamafile/sgemm.cpp +1884 -0
- data/ext/ggml/src/ggml-cpu/llamafile/sgemm.h +14 -0
- data/ext/ggml/src/ggml-cuda/vendors/cuda.h +14 -0
- data/ext/ggml/src/ggml-cuda/vendors/hip.h +186 -0
- data/ext/ggml/src/ggml-cuda/vendors/musa.h +134 -0
- data/ext/ggml/src/ggml-impl.h +556 -0
- data/ext/ggml/src/ggml-kompute/ggml-kompute.cpp +2251 -0
- data/ext/ggml/src/ggml-metal/ggml-metal-impl.h +288 -0
- data/ext/ggml/src/ggml-metal/ggml-metal.m +4884 -0
- data/ext/ggml/src/ggml-metal/ggml-metal.metal +6732 -0
- data/ext/ggml/src/ggml-opt.cpp +854 -0
- data/ext/ggml/src/ggml-quants.c +5238 -0
- data/ext/ggml/src/ggml-quants.h +100 -0
- data/ext/ggml/src/ggml-rpc/ggml-rpc.cpp +1406 -0
- data/ext/ggml/src/ggml-sycl/common.cpp +95 -0
- data/ext/ggml/src/ggml-sycl/concat.cpp +196 -0
- data/ext/ggml/src/ggml-sycl/conv.cpp +99 -0
- data/ext/ggml/src/ggml-sycl/convert.cpp +547 -0
- data/ext/ggml/src/ggml-sycl/dmmv.cpp +1023 -0
- data/ext/ggml/src/ggml-sycl/element_wise.cpp +1030 -0
- data/ext/ggml/src/ggml-sycl/ggml-sycl.cpp +4729 -0
- data/ext/ggml/src/ggml-sycl/im2col.cpp +126 -0
- data/ext/ggml/src/ggml-sycl/mmq.cpp +3031 -0
- data/ext/ggml/src/ggml-sycl/mmvq.cpp +1015 -0
- data/ext/ggml/src/ggml-sycl/norm.cpp +378 -0
- data/ext/ggml/src/ggml-sycl/outprod.cpp +56 -0
- data/ext/ggml/src/ggml-sycl/rope.cpp +276 -0
- data/ext/ggml/src/ggml-sycl/softmax.cpp +251 -0
- data/ext/ggml/src/ggml-sycl/tsembd.cpp +72 -0
- data/ext/ggml/src/ggml-sycl/wkv6.cpp +141 -0
- data/ext/ggml/src/ggml-threading.cpp +12 -0
- data/ext/ggml/src/ggml-threading.h +14 -0
- data/ext/ggml/src/ggml-vulkan/ggml-vulkan.cpp +8657 -0
- data/ext/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +593 -0
- data/ext/ggml/src/ggml.c +7694 -0
- data/ext/include/whisper.h +672 -0
- data/ext/metal-embed.mk +17 -0
- data/ext/metal.mk +6 -0
- data/ext/ruby_whisper.cpp +1608 -159
- data/ext/ruby_whisper.h +10 -0
- data/ext/scripts/get-flags.mk +38 -0
- data/ext/src/coreml/whisper-decoder-impl.h +146 -0
- data/ext/src/coreml/whisper-decoder-impl.m +201 -0
- data/ext/src/coreml/whisper-encoder-impl.h +142 -0
- data/ext/src/coreml/whisper-encoder-impl.m +197 -0
- data/ext/src/coreml/whisper-encoder.h +26 -0
- data/ext/src/openvino/whisper-openvino-encoder.cpp +108 -0
- data/ext/src/openvino/whisper-openvino-encoder.h +31 -0
- data/ext/src/whisper.cpp +7393 -0
- data/extsources.rb +6 -0
- data/lib/whisper/model/uri.rb +157 -0
- data/lib/whisper.rb +2 -0
- data/tests/helper.rb +7 -0
- data/tests/jfk_reader/.gitignore +5 -0
- data/tests/jfk_reader/extconf.rb +3 -0
- data/tests/jfk_reader/jfk_reader.c +68 -0
- data/tests/test_callback.rb +160 -0
- data/tests/test_error.rb +20 -0
- data/tests/test_model.rb +71 -0
- data/tests/test_package.rb +31 -0
- data/tests/test_params.rb +160 -0
- data/tests/test_segment.rb +83 -0
- data/tests/test_whisper.rb +211 -123
- data/whispercpp.gemspec +36 -0
- metadata +137 -11
- data/ext/ggml.c +0 -8616
- data/ext/ggml.h +0 -748
- data/ext/whisper.cpp +0 -4829
- data/ext/whisper.h +0 -402
@@ -0,0 +1,288 @@
|
|
1
|
+
#ifndef GGML_METAL_IMPL
|
2
|
+
#define GGML_METAL_IMPL
|
3
|
+
|
4
|
+
// kernel argument structs
|
5
|
+
//
|
6
|
+
// - element counters (e.g. ne00) typically use int32_t to reduce register usage
|
7
|
+
// however, be careful from int overflows when using those in the kernel implementation
|
8
|
+
//
|
9
|
+
// - strides (e.g. nb00) use uint64_t
|
10
|
+
|
11
|
+
typedef struct {
|
12
|
+
int32_t ne00;
|
13
|
+
int32_t ne01;
|
14
|
+
int32_t ne02;
|
15
|
+
int32_t ne03;
|
16
|
+
uint64_t nb00;
|
17
|
+
uint64_t nb01;
|
18
|
+
uint64_t nb02;
|
19
|
+
uint64_t nb03;
|
20
|
+
int32_t ne10;
|
21
|
+
int32_t ne11;
|
22
|
+
int32_t ne12;
|
23
|
+
int32_t ne13;
|
24
|
+
uint64_t nb10;
|
25
|
+
uint64_t nb11;
|
26
|
+
uint64_t nb12;
|
27
|
+
uint64_t nb13;
|
28
|
+
int32_t ne0;
|
29
|
+
int32_t ne1;
|
30
|
+
int32_t ne2;
|
31
|
+
int32_t ne3;
|
32
|
+
uint64_t nb0;
|
33
|
+
uint64_t nb1;
|
34
|
+
uint64_t nb2;
|
35
|
+
uint64_t nb3;
|
36
|
+
int32_t dim;
|
37
|
+
} ggml_metal_kargs_concat;
|
38
|
+
|
39
|
+
typedef struct {
|
40
|
+
int32_t ne00;
|
41
|
+
int32_t ne01;
|
42
|
+
int32_t ne02;
|
43
|
+
int32_t ne03;
|
44
|
+
uint64_t nb00;
|
45
|
+
uint64_t nb01;
|
46
|
+
uint64_t nb02;
|
47
|
+
uint64_t nb03;
|
48
|
+
int32_t ne10;
|
49
|
+
int32_t ne11;
|
50
|
+
int32_t ne12;
|
51
|
+
int32_t ne13;
|
52
|
+
uint64_t nb10;
|
53
|
+
uint64_t nb11;
|
54
|
+
uint64_t nb12;
|
55
|
+
uint64_t nb13;
|
56
|
+
int32_t ne0;
|
57
|
+
int32_t ne1;
|
58
|
+
int32_t ne2;
|
59
|
+
int32_t ne3;
|
60
|
+
uint64_t nb0;
|
61
|
+
uint64_t nb1;
|
62
|
+
uint64_t nb2;
|
63
|
+
uint64_t nb3;
|
64
|
+
uint64_t offs;
|
65
|
+
} ggml_metal_kargs_bin;
|
66
|
+
|
67
|
+
typedef struct {
|
68
|
+
int32_t ne00;
|
69
|
+
int32_t ne01;
|
70
|
+
int32_t ne02;
|
71
|
+
int32_t ne03;
|
72
|
+
uint64_t nb00;
|
73
|
+
uint64_t nb01;
|
74
|
+
uint64_t nb02;
|
75
|
+
uint64_t nb03;
|
76
|
+
int32_t ne0;
|
77
|
+
int32_t ne1;
|
78
|
+
int32_t ne2;
|
79
|
+
int32_t ne3;
|
80
|
+
uint64_t nb0;
|
81
|
+
uint64_t nb1;
|
82
|
+
uint64_t nb2;
|
83
|
+
uint64_t nb3;
|
84
|
+
} ggml_metal_kargs_repeat;
|
85
|
+
|
86
|
+
typedef struct {
|
87
|
+
int64_t ne00;
|
88
|
+
int64_t ne01;
|
89
|
+
int64_t ne02;
|
90
|
+
int64_t ne03;
|
91
|
+
uint64_t nb00;
|
92
|
+
uint64_t nb01;
|
93
|
+
uint64_t nb02;
|
94
|
+
uint64_t nb03;
|
95
|
+
int64_t ne0;
|
96
|
+
int64_t ne1;
|
97
|
+
int64_t ne2;
|
98
|
+
int64_t ne3;
|
99
|
+
uint64_t nb0;
|
100
|
+
uint64_t nb1;
|
101
|
+
uint64_t nb2;
|
102
|
+
uint64_t nb3;
|
103
|
+
} ggml_metal_kargs_cpy;
|
104
|
+
|
105
|
+
typedef struct {
|
106
|
+
int64_t ne10;
|
107
|
+
int64_t ne11;
|
108
|
+
int64_t ne12;
|
109
|
+
uint64_t nb10;
|
110
|
+
uint64_t nb11;
|
111
|
+
uint64_t nb12;
|
112
|
+
uint64_t nb13;
|
113
|
+
uint64_t nb1;
|
114
|
+
uint64_t nb2;
|
115
|
+
uint64_t nb3;
|
116
|
+
uint64_t offs;
|
117
|
+
bool inplace;
|
118
|
+
} ggml_metal_kargs_set;
|
119
|
+
|
120
|
+
typedef struct {
|
121
|
+
int32_t ne00;
|
122
|
+
int32_t ne01;
|
123
|
+
int32_t ne02;
|
124
|
+
int32_t ne03;
|
125
|
+
uint64_t nb00;
|
126
|
+
uint64_t nb01;
|
127
|
+
uint64_t nb02;
|
128
|
+
uint64_t nb03;
|
129
|
+
int32_t ne0;
|
130
|
+
int32_t ne1;
|
131
|
+
int32_t ne2;
|
132
|
+
int32_t ne3;
|
133
|
+
uint64_t nb0;
|
134
|
+
uint64_t nb1;
|
135
|
+
uint64_t nb2;
|
136
|
+
uint64_t nb3;
|
137
|
+
int32_t n_past;
|
138
|
+
int32_t n_dims;
|
139
|
+
int32_t n_ctx_orig;
|
140
|
+
float freq_base;
|
141
|
+
float freq_scale;
|
142
|
+
float ext_factor;
|
143
|
+
float attn_factor;
|
144
|
+
float beta_fast;
|
145
|
+
float beta_slow;
|
146
|
+
} ggml_metal_kargs_rope;
|
147
|
+
|
148
|
+
typedef struct {
|
149
|
+
int32_t ne01;
|
150
|
+
int32_t ne02;
|
151
|
+
int32_t ne03;
|
152
|
+
uint64_t nb01;
|
153
|
+
uint64_t nb02;
|
154
|
+
uint64_t nb03;
|
155
|
+
int32_t ne11;
|
156
|
+
int32_t ne_12_2; // assume K and V are same shape
|
157
|
+
int32_t ne_12_3;
|
158
|
+
uint64_t nb_12_1;
|
159
|
+
uint64_t nb_12_2;
|
160
|
+
uint64_t nb_12_3;
|
161
|
+
uint64_t nb31;
|
162
|
+
int32_t ne1;
|
163
|
+
int32_t ne2;
|
164
|
+
float scale;
|
165
|
+
float max_bias;
|
166
|
+
float m0;
|
167
|
+
float m1;
|
168
|
+
uint16_t n_head_log2;
|
169
|
+
float logit_softcap;
|
170
|
+
} ggml_metal_kargs_flash_attn_ext;
|
171
|
+
|
172
|
+
typedef struct {
|
173
|
+
int32_t ne00;
|
174
|
+
int32_t ne02;
|
175
|
+
uint64_t nb01;
|
176
|
+
uint64_t nb02;
|
177
|
+
uint64_t nb03;
|
178
|
+
int32_t ne12;
|
179
|
+
uint64_t nb10;
|
180
|
+
uint64_t nb11;
|
181
|
+
uint64_t nb12;
|
182
|
+
uint64_t nb13;
|
183
|
+
int32_t ne0;
|
184
|
+
int32_t ne1;
|
185
|
+
int16_t r2;
|
186
|
+
int16_t r3;
|
187
|
+
} ggml_metal_kargs_mul_mm;
|
188
|
+
|
189
|
+
typedef struct {
|
190
|
+
int32_t ne00;
|
191
|
+
int32_t ne01;
|
192
|
+
int32_t ne02;
|
193
|
+
uint64_t nb00;
|
194
|
+
uint64_t nb01;
|
195
|
+
uint64_t nb02;
|
196
|
+
uint64_t nb03;
|
197
|
+
int32_t ne10;
|
198
|
+
int32_t ne11;
|
199
|
+
int32_t ne12;
|
200
|
+
uint64_t nb10;
|
201
|
+
uint64_t nb11;
|
202
|
+
uint64_t nb12;
|
203
|
+
uint64_t nb13;
|
204
|
+
int32_t ne0;
|
205
|
+
int32_t ne1;
|
206
|
+
int16_t r2;
|
207
|
+
int16_t r3;
|
208
|
+
} ggml_metal_kargs_mul_mv;
|
209
|
+
|
210
|
+
typedef struct {
|
211
|
+
int32_t ne00;
|
212
|
+
int32_t ne01;
|
213
|
+
int32_t ne02;
|
214
|
+
uint64_t nb00;
|
215
|
+
uint64_t nb01;
|
216
|
+
uint64_t nb02;
|
217
|
+
uint64_t nb03;
|
218
|
+
int32_t ne10;
|
219
|
+
int32_t ne11;
|
220
|
+
int32_t ne12;
|
221
|
+
uint64_t nb10;
|
222
|
+
uint64_t nb11;
|
223
|
+
uint64_t nb12;
|
224
|
+
uint64_t nb13;
|
225
|
+
int32_t ne0;
|
226
|
+
int32_t ne1;
|
227
|
+
int16_t r2;
|
228
|
+
int16_t r3;
|
229
|
+
int16_t nsg;
|
230
|
+
int16_t nxpsg;
|
231
|
+
int16_t r1ptg;
|
232
|
+
} ggml_metal_kargs_mul_mv_ext;
|
233
|
+
|
234
|
+
typedef struct {
|
235
|
+
int32_t nei0;
|
236
|
+
int32_t nei1;
|
237
|
+
uint64_t nbi1;
|
238
|
+
int32_t ne00;
|
239
|
+
int32_t ne02;
|
240
|
+
uint64_t nb01;
|
241
|
+
uint64_t nb02;
|
242
|
+
int32_t ne11;
|
243
|
+
int32_t ne12;
|
244
|
+
int32_t ne13;
|
245
|
+
uint64_t nb10;
|
246
|
+
uint64_t nb11;
|
247
|
+
uint64_t nb12;
|
248
|
+
int32_t ne0;
|
249
|
+
int32_t ne1;
|
250
|
+
} ggml_metal_kargs_mul_mm_id;
|
251
|
+
|
252
|
+
typedef struct {
|
253
|
+
int32_t nei0;
|
254
|
+
int32_t nei1;
|
255
|
+
uint64_t nbi1;
|
256
|
+
int32_t ne00;
|
257
|
+
int32_t ne01;
|
258
|
+
int32_t ne02;
|
259
|
+
uint64_t nb00;
|
260
|
+
uint64_t nb01;
|
261
|
+
uint64_t nb02;
|
262
|
+
int32_t ne10;
|
263
|
+
int32_t ne11;
|
264
|
+
int32_t ne12;
|
265
|
+
int32_t ne13;
|
266
|
+
uint64_t nb10;
|
267
|
+
uint64_t nb11;
|
268
|
+
uint64_t nb12;
|
269
|
+
int32_t ne0;
|
270
|
+
int32_t ne1;
|
271
|
+
uint64_t nb1;
|
272
|
+
} ggml_metal_kargs_mul_mv_id;
|
273
|
+
|
274
|
+
typedef struct {
|
275
|
+
int32_t ne00;
|
276
|
+
int32_t ne00_4;
|
277
|
+
uint64_t nb01;
|
278
|
+
float eps;
|
279
|
+
} ggml_metal_kargs_norm;
|
280
|
+
|
281
|
+
typedef struct {
|
282
|
+
int32_t ne00;
|
283
|
+
int32_t ne00_4;
|
284
|
+
uint64_t nb01;
|
285
|
+
float eps;
|
286
|
+
} ggml_metal_kargs_rms_norm;
|
287
|
+
|
288
|
+
#endif // GGML_METAL_IMPL
|