Debian Codegraph @

external/whispercpp/ggml-impl.h

raw symbols SCIP
1 #cxx . . $ `<file>/external/whispercpp/ggml-impl.h`/pragma once
2
3 // GGML internal header
4
5 #include "ggml.h"cxx . . $ `<file>/external/whispercpp/ggml.h`/
6 #include "gguf.h"cxx . . $ `<file>/external/whispercpp/gguf.h`/
7
8 #include <assert.h>
9 #include <math.h>
10 #include <stdlib.h> // load `stdlib.h` before other headers to work around MinGW bug: https://sourceforge.net/p/mingw-w64/bugs/192/
11 #include <stdbool.h>
12 #include <stdint.h>
13 #include <string.h>
14
15 #ifdef __ARM_FEATURE_SVE
16 #include <arm_sve.h>
17 #endif // __ARM_FEATURE_SVE
18
19 #if defined(__ARM_NEON) && !defined(__CUDACC__) && !defined(__MUSACC__)
20 // if YCM cannot find <arm_neon.h>, make a symbolic link to it, for example:
21 //
22 // $ ln -sfn /Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include/arm_neon.h ./src/
23 //
24 #include <arm_neon.h>
25 #endif
26
27 #ifdef __cpluspluscxx . . $ `<built-in>:470:9`!
28 extern "C" {
29 #endif
30
31 void ggml_print_backtracecxx . . $ ggml_print_backtrace(49f6e7a06ebc5aa8).(void);
32
33 #ifndef MIN
34 # define MINcxx . . $ `external/whispercpp/ggml-impl.h:34:13`!(a, b) ((a) < (b) ? (a) : (b))
35 #endif
36
37 #ifndef MAX
38 # define MAXcxx . . $ `external/whispercpp/ggml-impl.h:38:13`!(a, b) ((a) > (b) ? (a) : (b))
39 #endif
40
41 // required for mmap as gguf only guarantees 32-byte alignment
42 #define TENSOR_ALIGNMENTcxx . . $ `external/whispercpp/ggml-impl.h:42:9`! 32
43
44 // static_assert should be a #define, but if it's not,
45 // fall back to the _Static_assert C11 keyword.
46 // if C99 - static_assert is noop
47 // ref: https://stackoverflow.com/a/53923785/4039976
48 #ifndef __cpluspluscxx . . $ `<built-in>:470:9`!
49 #ifndef static_assertcxx . . $ `external/whispercpp/ggml-common.h:81:9`!
50 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201100L)
51 #define static_assert(cond, msg) _Static_assert(cond, msg)
52 #else
53 #define static_assert(cond, msg) struct global_scope_noop_trick
54 #endif
55 #endif
56 #endif
57
58 static inline int ggml_up32cxx . . $ ggml_up32(7864480464b09eea).(int n) {
59 return (n + 31) & ~31;
60 }
61
62 //static inline int ggml_up64(int n) {
63 // return (n + 63) & ~63;
64 //}
65
66 static inline int ggml_upcxx . . $ ggml_up(9b79fb6aee4c0440).(int n, int m) {
67 // assert m is a power of 2
68 GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((m & (m - 1)) == 0);
69 return (n + m - 1) & ~(m - 1);
70 }
71
72 // TODO: move to ggml.h? (won't be able to inline)
73 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_are_same_layoutcxx . . $ ggml_are_same_layout(3bd891636d1661b7).(const struct ggml_tensorcxx . . $ ggml_tensor# * a, const struct ggml_tensorcxx . . $ ggml_tensor# * b) {
74 if (a->typecxx . . $ ggml_tensor#type. != b->typecxx . . $ ggml_tensor#type.) {
75 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
76 }
77 for (int i = 0; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; i++) {
78 if (a->necxx . . $ ggml_tensor#ne.[i] != b->necxx . . $ ggml_tensor#ne.[i]) {
79 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
80 }
81 if (a->nbcxx . . $ ggml_tensor#nb.[i] != b->nbcxx . . $ ggml_tensor#nb.[i]) {
82 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
83 }
84 }
85 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
86 }
87
88 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_op_is_emptycxx . . $ ggml_op_is_empty(ce38c36bc1574e7).(enum ggml_opcxx . . $ ggml_op# op) {
89 switch (op) {
90 case GGML_OP_NONEcxx . . $ GGML_OP_NONE.:
91 case GGML_OP_RESHAPEcxx . . $ GGML_OP_RESHAPE.:
92 case GGML_OP_TRANSPOSEcxx . . $ GGML_OP_TRANSPOSE.:
93 case GGML_OP_VIEWcxx . . $ GGML_OP_VIEW.:
94 case GGML_OP_PERMUTEcxx . . $ GGML_OP_PERMUTE.:
95 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
96 default:
97 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
98 }
99 }
100
101 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_impl_is_viewcxx . . $ ggml_impl_is_view(8fa73a561a000eab).(const struct ggml_tensorcxx . . $ ggml_tensor# * t) {
102 return t->view_srccxx . . $ ggml_tensor#view_src. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
103 }
104
105 static inline float ggml_compute_softplus_f32cxx . . $ ggml_compute_softplus_f32(fbcf3211dfe1bfd1).(float input) {
106 return (input > 20.0f) ? input : logf(1 + expf(input));
107 }
108 //
109 // logging
110 //
111
112 GGML_ATTRIBUTE_FORMATcxx . . $ `external/whispercpp/ggml.h:216:13`!(2, 3)
113 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! void ggml_log_internalcxx . . $ ggml_log_internal(484f38f1158c16f0). (enum ggml_log_levelcxx . . $ ggml_log_level# level, const char * format, ...);
114 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! void ggml_log_callback_defaultcxx . . $ ggml_log_callback_default(1235eb62ccdaecf6).(enum ggml_log_levelcxx . . $ ggml_log_level# level, const char * text, void * user_data);
115
116 #define GGML_LOGcxx . . $ `external/whispercpp/ggml-impl.h:116:9`!(...) ggml_log_internal(GGML_LOG_LEVEL_NONE , __VA_ARGS__)
117 #define GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!(...) ggml_log_internal(GGML_LOG_LEVEL_INFO , __VA_ARGS__)
118 #define GGML_LOG_WARNcxx . . $ `external/whispercpp/ggml-impl.h:118:9`!(...) ggml_log_internal(GGML_LOG_LEVEL_WARN , __VA_ARGS__)
119 #define GGML_LOG_ERRORcxx . . $ `external/whispercpp/ggml-impl.h:119:9`!(...) ggml_log_internal(GGML_LOG_LEVEL_ERROR, __VA_ARGS__)
120 #define GGML_LOG_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:120:9`!(...) ggml_log_internal(GGML_LOG_LEVEL_DEBUG, __VA_ARGS__)
121 #define GGML_LOG_CONTcxx . . $ `external/whispercpp/ggml-impl.h:121:9`!(...) ggml_log_internal(GGML_LOG_LEVEL_CONT , __VA_ARGS__)
122
123 #define GGML_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:123:9`! 0
124
125 #if (GGML_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:123:9`! >= 1)
126 #define GGML_PRINT_DEBUG(...) GGML_LOG_DEBUG(__VA_ARGS__)
127 #else
128 #define GGML_PRINT_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:128:9`!(...)
129 #endif
130
131 #if (GGML_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:123:9`! >= 5)
132 #define GGML_PRINT_DEBUG_5(...) GGML_LOG_DEBUG(__VA_ARGS__)
133 #else
134 #define GGML_PRINT_DEBUG_5cxx . . $ `external/whispercpp/ggml-impl.h:134:9`!(...)
135 #endif
136
137 #if (GGML_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:123:9`! >= 10)
138 #define GGML_PRINT_DEBUG_10(...) GGML_LOG_DEBUG(__VA_ARGS__)
139 #else
140 #define GGML_PRINT_DEBUG_10cxx . . $ `external/whispercpp/ggml-impl.h:140:9`!(...)
141 #endif
142
143 // tensor params
144
145 static void ggml_set_op_paramscxx . . $ ggml_set_op_params(103f3de5cd5d494f).(struct ggml_tensorcxx . . $ ggml_tensor# * tensor, const void * params, size_t params_size) {
146 GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tensor != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); // silence -Warray-bounds warnings
147 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(params_size <= GGML_MAX_OP_PARAMScxx . . $ `external/whispercpp/ggml.h:238:9`!);
148 memcpycxx . . $ memcpy(cc817cb175f282d).(tensor->op_paramscxx . . $ ggml_tensor#op_params., params, params_size);
149 }
150
151 static int32_tcxx . . $ int32_t# ggml_get_op_params_i32cxx . . $ ggml_get_op_params_i32(fa5746e90beca136).(const struct ggml_tensorcxx . . $ ggml_tensor# * tensor, uint32_tcxx . . $ uint32_t# i) {
152 assertcxx . . $ int32_t#(i < GGML_MAX_OP_PARAMScxx . . $ `external/whispercpp/ggml.h:238:9`! / sizeof(int32_t));
153 return ((const int32_tcxx . . $ int32_t# *)(tensor->op_paramscxx . . $ ggml_tensor#op_params.))[i];
154 }
155
156 static float ggml_get_op_params_f32cxx . . $ ggml_get_op_params_f32(854249c14d7ff896).(const struct ggml_tensorcxx . . $ ggml_tensor# * tensor, uint32_tcxx . . $ uint32_t# i) {
157 assertcxx . . $ `<external>/4398592474888995393/assert.h:102:11`!(i < GGML_MAX_OP_PARAMScxx . . $ `external/whispercpp/ggml.h:238:9`! / sizeof(float));
158 return ((const float *)(tensor->op_paramscxx . . $ ggml_tensor#op_params.))[i];
159 }
160
161 static void ggml_set_op_params_i32cxx . . $ ggml_set_op_params_i32(c109603419cef137).(struct ggml_tensorcxx . . $ ggml_tensor# * tensor, uint32_tcxx . . $ uint32_t# i, int32_tcxx . . $ int32_t# value) {
162 assertcxx . . $ int32_t#(i < GGML_MAX_OP_PARAMScxx . . $ `external/whispercpp/ggml.h:238:9`! / sizeof(int32_t));
163 ((int32_tcxx . . $ int32_t# *)(tensor->op_paramscxx . . $ ggml_tensor#op_params.))[i] = value;
164 }
165
166 static void ggml_set_op_params_f32cxx . . $ ggml_set_op_params_f32(b4f7af7a7398fda2).(struct ggml_tensorcxx . . $ ggml_tensor# * tensor, uint32_tcxx . . $ uint32_t# i, float value) {
167 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(i < GGML_MAX_OP_PARAMScxx . . $ `external/whispercpp/ggml.h:238:9`! / sizeof(float));
168 ((float *)(tensor->op_paramscxx . . $ ggml_tensor#op_params.))[i] = value;
169 }
170
171 struct ggml_map_custom1_op_paramscxx . . $ ggml_map_custom1_op_params# {
172 ggml_custom1_op_tcxx . . $ ggml_custom1_op_t# funcxx . . $ ggml_map_custom1_op_params#fun.;
173 int n_taskscxx . . $ ggml_map_custom1_op_params#n_tasks.;
174 void * userdatacxx . . $ ggml_map_custom1_op_params#userdata.;
175 };
176
177 struct ggml_map_custom2_op_paramscxx . . $ ggml_map_custom2_op_params# {
178 ggml_custom2_op_tcxx . . $ ggml_custom2_op_t# funcxx . . $ ggml_map_custom2_op_params#fun.;
179 int n_taskscxx . . $ ggml_map_custom2_op_params#n_tasks.;
180 void * userdatacxx . . $ ggml_map_custom2_op_params#userdata.;
181 };
182
183 struct ggml_map_custom3_op_paramscxx . . $ ggml_map_custom3_op_params# {
184 ggml_custom3_op_tcxx . . $ ggml_custom3_op_t# funcxx . . $ ggml_map_custom3_op_params#fun.;
185 int n_taskscxx . . $ ggml_map_custom3_op_params#n_tasks.;
186 void * userdatacxx . . $ ggml_map_custom3_op_params#userdata.;
187 };
188
189 struct ggml_custom_op_paramscxx . . $ ggml_custom_op_params# {
190 ggml_custom_op_tcxx . . $ ggml_custom_op_t# funcxx . . $ ggml_custom_op_params#fun.;
191 int n_taskscxx . . $ ggml_custom_op_params#n_tasks.;
192 void * userdatacxx . . $ ggml_custom_op_params#userdata.;
193 };
194
195 // bitset
196
197 typedef uint32_tcxx . . $ uint32_t# ggml_bitset_tcxx . . $ ggml_bitset_t#;
198
199 static_assertcxx . . $ `external/whispercpp/ggml-common.h:81:9`!(sizeof(ggml_bitset_t) == 4, "bitset_t constants must be updated");
200 #define BITSET_SHRcxx . . $ `external/whispercpp/ggml-impl.h:200:9`! 5 // log2(sizeof(ggml_bitset_t)*8)
201 #define BITSET_MASKcxx . . $ `external/whispercpp/ggml-impl.h:201:9`! (sizeof(ggml_bitset_t)*8 - 1)
202
203 static size_t ggml_bitset_sizecxx . . $ ggml_bitset_size(ecdaa1632f49f591).(size_t n) {
204 return (n + BITSET_MASKcxx . . $ `external/whispercpp/ggml-impl.h:201:9`!) >> BITSET_SHRcxx . . $ `external/whispercpp/ggml-impl.h:200:9`!;
205 }
206
207 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_bitset_getcxx . . $ ggml_bitset_get(9e068f82e2e3bca4).(const ggml_bitset_tcxx . . $ ggml_bitset_t# * bitset, size_t i) {
208 return !!(bitset[i >> BITSET_SHRcxx . . $ `external/whispercpp/ggml-impl.h:200:9`!] & (1u << (i & BITSET_MASKcxx . . $ `external/whispercpp/ggml-impl.h:201:9`!)));
209 }
210
211 static inline void ggml_bitset_setcxx . . $ ggml_bitset_set(2769ff323d6644d4).(ggml_bitset_tcxx . . $ ggml_bitset_t# * bitset, size_t i) {
212 bitset[i >> BITSET_SHRcxx . . $ `external/whispercpp/ggml-impl.h:200:9`!] |= (1u << (i & BITSET_MASKcxx . . $ `external/whispercpp/ggml-impl.h:201:9`!));
213 }
214
215 static inline void ggml_bitset_clearcxx . . $ ggml_bitset_clear(2769ff323d6644d4).(ggml_bitset_tcxx . . $ ggml_bitset_t# * bitset, size_t i) {
216 bitset[i >> BITSET_SHRcxx . . $ `external/whispercpp/ggml-impl.h:200:9`!] &= ~(1u << (i & BITSET_MASKcxx . . $ `external/whispercpp/ggml-impl.h:201:9`!));
217 }
218
219 // hash set
220
221 #define GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! ((size_t)-1)
222 #define GGML_HASHSET_ALREADY_EXISTScxx . . $ `external/whispercpp/ggml-impl.h:222:9`! ((size_t)-2)
223
224 struct ggml_hash_setcxx . . $ ggml_hash_set# {
225 size_t sizecxx . . $ ggml_hash_set#size.;
226 ggml_bitset_tcxx . . $ ggml_bitset_t# * usedcxx . . $ ggml_hash_set#used.; // whether or not the keys are in use i.e. set
227 struct ggml_tensorcxx . . $ ggml_tensor# ** keyscxx . . $ ggml_hash_set#keys.; // actual tensors in the set, keys[i] is only defined if ggml_bitset_get(used, i)
228 };
229
230 struct ggml_hash_setcxx . . $ ggml_hash_set# ggml_hash_set_newcxx . . $ ggml_hash_set_new(ec896db146153f54).(size_t size);
231 void ggml_hash_set_freecxx . . $ ggml_hash_set_free(3b8f2cbb4a532df6).(struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set);
232
233 // returns the minimum size for a hash set that can hold min_sz elements
234 size_t ggml_hash_sizecxx . . $ ggml_hash_size(ecdaa1632f49f591).(size_t min_sz);
235
236 // remove all elements from the hash set
237 void ggml_hash_set_resetcxx . . $ ggml_hash_set_reset(3b8f2cbb4a532df6).(struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set);
238
239 // returns true if key is in the hash set
240 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_hash_containscxx . . $ ggml_hash_contains(3679ba61290d004f).(const struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, struct ggml_tensorcxx . . $ ggml_tensor# * key);
241
242 // returns GGML_HASHSET_FULL if table is full, otherwise the current index of the key or where it should be inserted
243 static size_t ggml_hash_findcxx . . $ ggml_hash_find(57fbe5ff92757047).(const struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, const struct ggml_tensorcxx . . $ ggml_tensor# * key);
244
245 // returns GGML_HASHSET_ALREADY_EXISTS if key already exists, index otherwise, asserts if table is full
246 static size_t ggml_hash_insertcxx . . $ ggml_hash_insert(5cc5db73e825ba9a).(struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, struct ggml_tensorcxx . . $ ggml_tensor# * key);
247
248 // return index, asserts if table is full
249 static size_t ggml_hash_find_or_insertcxx . . $ ggml_hash_find_or_insert(5cc5db73e825ba9a).(struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, struct ggml_tensorcxx . . $ ggml_tensor# * key);
250
251 // hash function for ggml_tensor
252 static inline size_t ggml_hashcxx . . $ ggml_hash(7f354dd711c66cf7).(const struct ggml_tensorcxx . . $ ggml_tensor# * p) {
253 // the last 4 bits are always zero due to alignment
254 return (size_t)(uintptr_tcxx . . $ uintptr_t#)p >> 4;
255 }
256
257 static size_t ggml_hash_findcxx . . $ ggml_hash_find(57fbe5ff92757047).(const struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, const struct ggml_tensorcxx . . $ ggml_tensor# * key) {
258 size_t h = ggml_hashcxx . . $ ggml_hash(7f354dd711c66cf7).(key) % hash_set->sizecxx . . $ ggml_hash_set#size.;
259
260 // linear probing
261 size_t i = h;
262 while (ggml_bitset_getcxx . . $ ggml_bitset_get(9e068f82e2e3bca4).(hash_set->usedcxx . . $ ggml_hash_set#used., i) && hash_set->keyscxx . . $ ggml_hash_set#keys.[i] != key) {
263 i = (i + 1) % hash_set->sizecxx . . $ ggml_hash_set#size.;
264 if (i == h) {
265 // visited all hash table entries -> not found
266 return GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`!;
267 }
268 }
269 return i;
270 }
271
272 static boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_hash_containscxx . . $ ggml_hash_contains(3679ba61290d004f).(const struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, struct ggml_tensorcxx . . $ ggml_tensor# * key) {
273 size_t i = ggml_hash_findcxx . . $ ggml_hash_find(57fbe5ff92757047).(hash_set, key);
274 return i != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! && ggml_bitset_getcxx . . $ ggml_bitset_get(9e068f82e2e3bca4).(hash_set->usedcxx . . $ ggml_hash_set#used., i);
275 }
276
277 static size_t ggml_hash_insertcxx . . $ ggml_hash_insert(5cc5db73e825ba9a).(struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, struct ggml_tensorcxx . . $ ggml_tensor# * key) {
278 size_t h = ggml_hashcxx . . $ ggml_hash(7f354dd711c66cf7).(key) % hash_set->sizecxx . . $ ggml_hash_set#size.;
279
280 // linear probing
281 size_t i = h;
282 do {
283 if (!ggml_bitset_getcxx . . $ ggml_bitset_get(9e068f82e2e3bca4).(hash_set->usedcxx . . $ ggml_hash_set#used., i)) {
284 ggml_bitset_setcxx . . $ ggml_bitset_set(2769ff323d6644d4).(hash_set->usedcxx . . $ ggml_hash_set#used., i);
285 hash_set->keyscxx . . $ ggml_hash_set#keys.[i] = key;
286 return i;
287 }
288 if (hash_set->keyscxx . . $ ggml_hash_set#keys.[i] == key) {
289 return GGML_HASHSET_ALREADY_EXISTScxx . . $ `external/whispercpp/ggml-impl.h:222:9`!;
290 }
291 i = (i + 1) % hash_set->sizecxx . . $ ggml_hash_set#size.;
292 } while (i != h);
293
294 // visited all hash table entries -> not found
295 GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("fatal error");
296 }
297
298 static size_t ggml_hash_find_or_insertcxx . . $ ggml_hash_find_or_insert(5cc5db73e825ba9a).(struct ggml_hash_setcxx . . $ ggml_hash_set# * hash_set, struct ggml_tensorcxx . . $ ggml_tensor# * key) {
299 size_t h = ggml_hashcxx . . $ ggml_hash(7f354dd711c66cf7).(key) % hash_set->sizecxx . . $ ggml_hash_set#size.;
300
301 // linear probing
302 size_t i = h;
303 do {
304 if (!ggml_bitset_getcxx . . $ ggml_bitset_get(9e068f82e2e3bca4).(hash_set->usedcxx . . $ ggml_hash_set#used., i)) {
305 ggml_bitset_setcxx . . $ ggml_bitset_set(2769ff323d6644d4).(hash_set->usedcxx . . $ ggml_hash_set#used., i);
306 hash_set->keyscxx . . $ ggml_hash_set#keys.[i] = key;
307 return i;
308 }
309 if (hash_set->keyscxx . . $ ggml_hash_set#keys.[i] == key) {
310 return i;
311 }
312 i = (i + 1) % hash_set->sizecxx . . $ ggml_hash_set#size.;
313 } while (i != h);
314
315 // visited all hash table entries -> not found
316 GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("fatal error");
317 }
318
319 // computation graph
320
321 enum ggml_cgraph_eval_ordercxx . . $ ggml_cgraph_eval_order# {
322 GGML_CGRAPH_EVAL_ORDER_LEFT_TO_RIGHTcxx . . $ GGML_CGRAPH_EVAL_ORDER_LEFT_TO_RIGHT. = 0,
323 GGML_CGRAPH_EVAL_ORDER_RIGHT_TO_LEFTcxx . . $ GGML_CGRAPH_EVAL_ORDER_RIGHT_TO_LEFT.,
324 GGML_CGRAPH_EVAL_ORDER_COUNTcxx . . $ GGML_CGRAPH_EVAL_ORDER_COUNT.
325 };
326
327 struct ggml_cgraphcxx . . $ ggml_cgraph# {
328 int sizecxx . . $ ggml_cgraph#size.; // maximum number of nodes/leafs/grads/grad_accs
329 int n_nodescxx . . $ ggml_cgraph#n_nodes.; // number of nodes currently in use
330 int n_leafscxx . . $ ggml_cgraph#n_leafs.; // number of leafs currently in use
331
332 struct ggml_tensorcxx . . $ ggml_tensor# ** nodescxx . . $ ggml_cgraph#nodes.; // tensors with data that can change if the graph is evaluated
333 struct ggml_tensorcxx . . $ ggml_tensor# ** gradscxx . . $ ggml_cgraph#grads.; // the outputs of these tensors are the gradients of the nodes
334 struct ggml_tensorcxx . . $ ggml_tensor# ** grad_accscxx . . $ ggml_cgraph#grad_accs.; // accumulators for node gradients
335 struct ggml_tensorcxx . . $ ggml_tensor# ** leafscxx . . $ ggml_cgraph#leafs.; // tensors with constant data
336 int32_tcxx . . $ int32_t# * use_countscxx . . $ ggml_cgraph#use_counts.;// number of uses of each tensor, indexed by hash table slot
337
338 struct ggml_hash_setcxx . . $ ggml_hash_set# visited_hash_setcxx . . $ ggml_cgraph#visited_hash_set.;
339
340 enum ggml_cgraph_eval_ordercxx . . $ ggml_cgraph_eval_order# ordercxx . . $ ggml_cgraph#order.;
341 };
342
343 // returns a slice of cgraph with nodes [i0, i1)
344 // the slice does not have leafs or gradients
345 // if you need the gradients, get them from the original graph
346 struct ggml_cgraphcxx . . $ ggml_cgraph# ggml_graph_viewcxx . . $ ggml_graph_view(10d4528099c9716e).(struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph, int i0, int i1);
347
348 // ggml-alloc.c: true if the operation can reuse memory from its sources
349 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_op_can_inplacecxx . . $ ggml_op_can_inplace(ce38c36bc1574e7).(enum ggml_opcxx . . $ ggml_op# op);
350
351
352 // Memory allocation
353
354 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! void * ggml_aligned_malloccxx . . $ ggml_aligned_malloc(bfcfa4d6b7f7ef64).(size_t size);
355 #ifdef __cpluspluscxx . . $ `<built-in>:470:9`!
356 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! void ggml_aligned_free(void * ptr, size_t size, bool toRemoveFromPool = true);
357 #else
358 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! void ggml_aligned_freecxx . . $ ggml_aligned_free(3aa184a1f7b8f66e).(void * ptr, size_t size, boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! toRemoveFromPool);
359 #endif
360
361
362 // FP16 <-> FP32
363 // ref: https://github.com/Maratyszcza/FP16
364
365 static inline float fp32_from_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).(uint32_tcxx . . $ uint32_t# w) {
366 unioncxx . . $ fp32_from_bits(df5a737eaec60ebb).$anonymous_type_0# {
367 uint32_tcxx . . $ uint32_t# as_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).$anonymous_type_0#as_bits.;
368 float as_valuecxx . . $ fp32_from_bits(df5a737eaec60ebb).$anonymous_type_0#as_value.;
369 } fp32;
370 fp32.as_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).$anonymous_type_0#as_bits. = w;
371 return fp32.as_valuecxx . . $ fp32_from_bits(df5a737eaec60ebb).$anonymous_type_0#as_value.;
372 }
373
374 static inline uint32_tcxx . . $ uint32_t# fp32_to_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).(float f) {
375 unioncxx . . $ fp32_to_bits(126a58af4772d7ea).$anonymous_type_1# {
376 float as_valuecxx . . $ fp32_to_bits(126a58af4772d7ea).$anonymous_type_1#as_value.;
377 uint32_tcxx . . $ uint32_t# as_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).$anonymous_type_1#as_bits.;
378 } fp32;
379 fp32.as_valuecxx . . $ fp32_to_bits(126a58af4772d7ea).$anonymous_type_1#as_value. = f;
380 return fp32.as_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).$anonymous_type_1#as_bits.;
381 }
382
383 static inline float ggml_compute_fp16_to_fp32cxx . . $ ggml_compute_fp16_to_fp32(9a38df040a81ca35).(ggml_fp16_tcxx . . $ ggml_fp16_t# h) {
384 const uint32_tcxx . . $ uint32_t# w = (uint32_tcxx . . $ uint32_t#) h << 16;
385 const uint32_tcxx . . $ uint32_t# sign = w & UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x80000000);
386 const uint32_tcxx . . $ uint32_t# two_w = w + w;
387
388 const uint32_tcxx . . $ uint32_t# exp_offset = UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0xE0) << 23;
389 #if (defined(__STDC_VERSION__cxx . . $ `<built-in>:406:9`!) && (__STDC_VERSION__cxx . . $ `<built-in>:406:9`! >= 199901L) || defined(__GNUC__cxx . . $ `<built-in>:8:9`!) && !defined(__STRICT_ANSI__cxx . . $ `<built-in>:42:9`!)) && (!defined(__cpluspluscxx . . $ `<built-in>:470:9`!) || __cpluspluscxx . . $ `<built-in>:470:9`! >= 201703L)
390 const float exp_scale = 0x1.0p-112f;
391 #else
392 const float exp_scale = fp32_from_bits(UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x7800000));
393 #endif
394 const float normalized_value = fp32_from_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).((two_w >> 4) + exp_offset) * exp_scale;
395
396 const uint32_tcxx . . $ uint32_t# magic_mask = UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(126) << 23;
397 const float magic_bias = 0.5f;
398 const float denormalized_value = fp32_from_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).((two_w >> 17) | magic_mask) - magic_bias;
399
400 const uint32_tcxx . . $ uint32_t# denormalized_cutoff = UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(1) << 27;
401 const uint32_tcxx . . $ uint32_t# result = sign |
402 (two_w < denormalized_cutoff ? fp32_to_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).(denormalized_value) : fp32_to_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).(normalized_value));
403 return fp32_from_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).(result);
404 }
405
406 static inline ggml_fp16_tcxx . . $ ggml_fp16_t# ggml_compute_fp32_to_fp16cxx . . $ ggml_compute_fp32_to_fp16(a7602afe0c5a7a59).(float f) {
407 #if (defined(__STDC_VERSION__cxx . . $ `<built-in>:406:9`!) && (__STDC_VERSION__cxx . . $ `<built-in>:406:9`! >= 199901L) || defined(__GNUC__cxx . . $ `<built-in>:8:9`!) && !defined(__STRICT_ANSI__cxx . . $ `<built-in>:42:9`!)) && (!defined(__cpluspluscxx . . $ `<built-in>:470:9`!) || __cpluspluscxx . . $ `<built-in>:470:9`! >= 201703L)
408 const float scale_to_inf = 0x1.0p+112f;
409 const float scale_to_zero = 0x1.0p-110f;
410 #else
411 const float scale_to_inf = fp32_from_bits(UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x77800000));
412 const float scale_to_zero = fp32_from_bits(UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x08800000));
413 #endif
414 float base = (fabsf(f) * scale_to_inf) * scale_to_zero;
415
416 const uint32_tcxx . . $ uint32_t# w = fp32_to_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).(f);
417 const uint32_tcxx . . $ uint32_t# shl1_w = w + w;
418 const uint32_tcxx . . $ uint32_t# sign = w & UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x80000000);
419 uint32_tcxx . . $ uint32_t# bias = shl1_w & UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0xFF000000);
420 if (bias < UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x71000000)) {
421 bias = UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x71000000);
422 }
423
424 base = fp32_from_bitscxx . . $ fp32_from_bits(df5a737eaec60ebb).((bias >> 1) + UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x07800000)) + base;
425 const uint32_tcxx . . $ uint32_t# bits = fp32_to_bitscxx . . $ fp32_to_bits(126a58af4772d7ea).(base);
426 const uint32_tcxx . . $ uint32_t# exp_bits = (bits >> 13) & UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x00007C00);
427 const uint32_tcxx . . $ uint32_t# mantissa_bits = bits & UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0x00000FFF);
428 const uint32_tcxx . . $ uint32_t# nonsign = exp_bits + mantissa_bits;
429 return (sign >> 16) | (shl1_w > UINT32_Ccxx . . $ `<external>/3415975807581488833/stdint.h:249:10`!(0xFF000000) ? UINT16_Ccxx . . $ `<external>/3415975807581488833/stdint.h:248:10`!(0x7E00) : nonsign);
430 }
431
432 #define GGML_COMPUTE_FP16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:432:9`!(x) ggml_compute_fp16_to_fp32(x)
433 #define GGML_COMPUTE_FP32_TO_FP16cxx . . $ `external/whispercpp/ggml-impl.h:433:9`!(x) ggml_compute_fp32_to_fp16(x)
434
435 #define GGML_FP16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:435:9`!(x) GGML_COMPUTE_FP16_TO_FP32(x)
436 #define GGML_FP32_TO_FP16cxx . . $ `external/whispercpp/ggml-impl.h:436:9`!(x) GGML_COMPUTE_FP32_TO_FP16(x)
437
438 static inline float ggml_e8m0_to_fp32cxx . . $ ggml_e8m0_to_fp32(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# x) {
439 uint32_tcxx . . $ uint32_t# bits; // Stores the raw bit representation of the float
440
441 // Handle special case for minimum exponent (denormalized float)
442 if (x == 0) {
443 // Bit pattern for 2^(-127):
444 // - Sign bit: 0 (positive)
445 // - Exponent: 0 (denormalized number)
446 // - Mantissa: 0x400000 (0.5 in fractional form)
447 // Value = 0.5 * 2^(-126) = 2^(-127)
448 bits = 0x00400000;
449 }
450 // note: disabled as we don't need to handle NaNs
451 //// Handle special case for NaN (all bits set)
452 //else if (x == 0xFF) {
453 // // Standard quiet NaN pattern:
454 // // - Sign bit: 0
455 // // - Exponent: all 1s (0xFF)
456 // // - Mantissa: 0x400000 (quiet NaN flag)
457 // bits = 0x7FC00000;
458 //}
459 // Normalized values (most common case)
460 else {
461 // Construct normalized float by shifting exponent into position:
462 // - Exponent field: 8 bits (positions 30-23)
463 // - Mantissa: 0 (implicit leading 1)
464 // Value = 2^(x - 127)
465 bits = (uint32_tcxx . . $ uint32_t#) x << 23;
466 }
467
468 float result; // Final float value
469 // Safely reinterpret bit pattern as float without type-punning issues
470 memcpycxx . . $ memcpy(cc817cb175f282d).(&result, &bits, sizeof(float));
471 return result;
472 }
473
474 // Equal to ggml_e8m0_to_fp32/2
475 // Useful with MXFP4 quantization since the E0M2 values are doubled
476 static inline float ggml_e8m0_to_fp32_halfcxx . . $ ggml_e8m0_to_fp32_half(ef46aeb7cc924ea7).(uint8_tcxx . . $ uint8_t# x) {
477 uint32_tcxx . . $ uint32_t# bits;
478
479 // For x < 2: use precomputed denormal patterns
480 if (x < 2) {
481 // 0x00200000 = 2^(-128), 0x00400000 = 2^(-127)
482 bits = 0x00200000 << x;
483 }
484 // For x >= 2: normalized exponent adjustment
485 else {
486 // 0.5 * 2^(x-127) = 2^(x-128) = normalized with exponent (x-1)
487 bits = (uint32_tcxx . . $ uint32_t#)(x - 1) << 23;
488 }
489 // Note: NaNs are not handled here
490
491 float result;
492 memcpycxx . . $ memcpy(cc817cb175f282d).(&result, &bits, sizeof(float));
493 return result;
494 }
495
496 #define GGML_E8M0_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:496:9`!(x) ggml_e8m0_to_fp32(x)
497 #define GGML_E8M0_TO_FP32_HALFcxx . . $ `external/whispercpp/ggml-impl.h:497:9`!(x) ggml_e8m0_to_fp32_half(x)
498
499 /**
500 * Converts brain16 to float32.
501 *
502 * The bfloat16 floating point format has the following structure:
503 *
504 * ┌sign
505 * │
506 * │ ┌exponent
507 * │ │
508 * │ │ ┌mantissa
509 * │ │ │
510 * │┌──┴───┐┌─┴───┐
511 * 0b0000000000000000 brain16
512 *
513 * Since bf16 has the same number of exponent bits as a 32bit float,
514 * encoding and decoding numbers becomes relatively straightforward.
515 *
516 * ┌sign
517 * │
518 * │ ┌exponent
519 * │ │
520 * │ │ ┌mantissa
521 * │ │ │
522 * │┌──┴───┐┌─┴───────────────────┐
523 * 0b00000000000000000000000000000000 IEEE binary32
524 *
525 * For comparison, the standard fp16 format has fewer exponent bits.
526 *
527 * ┌sign
528 * │
529 * │ ┌exponent
530 * │ │
531 * │ │ ┌mantissa
532 * │ │ │
533 * │┌─┴─┐┌─┴──────┐
534 * 0b0000000000000000 IEEE binary16
535 *
536 * @see IEEE 754-2008
537 */
538 static inline float ggml_compute_bf16_to_fp32cxx . . $ ggml_compute_bf16_to_fp32(19100f69e776d75a).(ggml_bf16_tcxx . . $ ggml_bf16_t# h) {
539 unioncxx . . $ ggml_compute_bf16_to_fp32(19100f69e776d75a).$anonymous_type_2# {
540 float fcxx . . $ ggml_compute_bf16_to_fp32(19100f69e776d75a).$anonymous_type_2#f.;
541 uint32_tcxx . . $ uint32_t# icxx . . $ ggml_compute_bf16_to_fp32(19100f69e776d75a).$anonymous_type_2#i.;
542 } u;
543 u.icxx . . $ ggml_compute_bf16_to_fp32(19100f69e776d75a).$anonymous_type_2#i. = (uint32_tcxx . . $ uint32_t#)h.bitscxx . . $ $anonymous_type_f34158416f7ac4c4_0#bits. << 16;
544 return u.fcxx . . $ ggml_compute_bf16_to_fp32(19100f69e776d75a).$anonymous_type_2#f.;
545 }
546
547 /**
548 * Converts float32 to brain16.
549 *
550 * This is binary identical with Google Brain float conversion.
551 * Floats shall round to nearest even, and NANs shall be quiet.
552 * Subnormals aren't flushed to zero, except perhaps when used.
553 * This code should vectorize nicely if using modern compilers.
554 */
555 static inline ggml_bf16_tcxx . . $ ggml_bf16_t# ggml_compute_fp32_to_bf16cxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).(float s) {
556 ggml_bf16_tcxx . . $ ggml_bf16_t# h;
557 unioncxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3# {
558 float fcxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#f.;
559 uint32_tcxx . . $ uint32_t# icxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#i.;
560 } u;
561 u.fcxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#f. = s;
562 if ((u.icxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#i. & 0x7fffffff) > 0x7f800000) { /* nan */
563 h.bitscxx . . $ $anonymous_type_f34158416f7ac4c4_0#bits. = (u.icxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#i. >> 16) | 64; /* force to quiet */
564 return h;
565 }
566 h.bitscxx . . $ $anonymous_type_f34158416f7ac4c4_0#bits. = (u.icxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#i. + (0x7fff + ((u.icxx . . $ ggml_compute_fp32_to_bf16(4b9b7da6982f80a2).$anonymous_type_3#i. >> 16) & 1))) >> 16;
567 return h;
568 }
569
570 #define GGML_FP32_TO_BF16cxx . . $ `external/whispercpp/ggml-impl.h:570:9`!(x) ggml_compute_fp32_to_bf16(x)
571 #define GGML_BF16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:571:9`!(x) ggml_compute_bf16_to_fp32(x)
572
573 static inline int32_tcxx . . $ int32_t# ggml_node_get_use_countcxx . . $ ggml_node_get_use_count(c95d257d84d84b6d).(const struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph, int node_idx) {
574 const struct ggml_tensorcxx . . $ ggml_tensor# * node = cgraph->nodescxx . . $ ggml_cgraph#nodes.[node_idx];
575
576 size_t hash_pos = ggml_hash_findcxx . . $ ggml_hash_find(57fbe5ff92757047).(&cgraph->visited_hash_setcxx . . $ ggml_cgraph#visited_hash_set., node);
577 if (!ggml_bitset_getcxx . . $ ggml_bitset_get(9e068f82e2e3bca4).(cgraph->visited_hash_setcxx . . $ ggml_cgraph#visited_hash_set..usedcxx . . $ ggml_hash_set#used., hash_pos)) {
578 return 0;
579 }
580 return cgraph->use_countscxx . . $ ggml_cgraph#use_counts.[hash_pos];
581 }
582
583 // return true if the node's results are only used by N other nodes
584 // and can be fused into their calculations.
585 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_node_has_n_usescxx . . $ ggml_node_has_n_uses(e408d95e302ee4af).(const struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph, int node_idx, int32_tcxx . . $ int32_t# n_uses) {
586 const struct ggml_tensorcxx . . $ ggml_tensor# * node = cgraph->nodescxx . . $ ggml_cgraph#nodes.[node_idx];
587
588 // check the use count against how many we're replacing
589 if (ggml_node_get_use_countcxx . . $ ggml_node_get_use_count(c95d257d84d84b6d).(cgraph, node_idx) != n_uses) {
590 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
591 }
592
593 // if node is a view, some other node might be using the intermediate result
594 // via the view source.
595 if (node->view_srccxx . . $ ggml_tensor#view_src.) {
596 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
597 }
598
599 // If the user requested output for the node, can't fuse
600 if (node->flagscxx . . $ ggml_tensor#flags. & GGML_TENSOR_FLAG_OUTPUTcxx . . $ GGML_TENSOR_FLAG_OUTPUT.) {
601 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
602 }
603
604 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
605 }
606
607 // Returns true if nodes with indices { node_idxs } are the sequence of ggml_ops in ops[]
608 // and are fusable. Nodes are considered fusable according to this function if:
609 // - all nodes except the last have only one use and are not views/outputs (see ggml_node_has_N_uses).
610 // - all nodes except the last are a src of the following node.
611 // - all nodes are the same shape.
612 // TODO: Consider allowing GGML_OP_NONE nodes in between
613 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_can_fuse_extcxx . . $ ggml_can_fuse_ext(905bb227d03e0fc2).(const struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph, const int * node_idxs, const enum ggml_opcxx . . $ ggml_op# * ops, int num_ops) {
614 for (int i = 0; i < num_ops; ++i) {
615 if (node_idxs[i] >= cgraph->n_nodescxx . . $ ggml_cgraph#n_nodes.) {
616 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
617 }
618
619 struct ggml_tensorcxx . . $ ggml_tensor# * node = cgraph->nodescxx . . $ ggml_cgraph#nodes.[node_idxs[i]];
620 if (node->opcxx . . $ ggml_tensor#op. != ops[i]) {
621 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
622 }
623 if ((node->flagscxx . . $ ggml_tensor#flags. & GGML_TENSOR_FLAG_COMPUTEcxx . . $ GGML_TENSOR_FLAG_COMPUTE.) == 0) {
624 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
625 }
626 if (i < num_ops - 1 && !ggml_node_has_n_usescxx . . $ ggml_node_has_n_uses(e408d95e302ee4af).(cgraph, node_idxs[i], 1)) {
627 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
628 }
629 if (i > 0) {
630 struct ggml_tensorcxx . . $ ggml_tensor# * prev = cgraph->nodescxx . . $ ggml_cgraph#nodes.[node_idxs[i - 1]];
631 if (node->srccxx . . $ ggml_tensor#src.[0] != prev && node->srccxx . . $ ggml_tensor#src.[1] != prev) {
632 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
633 }
634 if (!ggml_are_same_shapecxx . . $ ggml_are_same_shape(3bd891636d1661b7).(node, prev)) {
635 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
636 }
637 }
638 }
639 return truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!;
640 }
641
642 // same as above, for sequential indices starting at node_idx
643 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_can_fusecxx . . $ ggml_can_fuse(75e10109bb253b0d).(const struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph, int node_idx, const enum ggml_opcxx . . $ ggml_op# * ops, int num_ops) {
644 assertcxx . . $ `<external>/4398592474888995393/assert.h:118:11`!(num_ops < 32);
645
646 if (node_idx + num_ops > cgraph->n_nodescxx . . $ ggml_cgraph#n_nodes.) {
647 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
648 }
649
650 int idxs[32];
651 for (int i = 0; i < num_ops; ++i) {
652 idxs[i] = node_idx + i;
653 }
654
655 return ggml_can_fuse_extcxx . . $ ggml_can_fuse_ext(905bb227d03e0fc2).(cgraph, idxs, ops, num_ops);
656 }
657
658 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_can_fuse_subgraph_extcxx . . $ ggml_can_fuse_subgraph_ext(2931c63e51fb5b9f).(const struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph,
659 const int * node_idxs,
660 int count,
661 const enum ggml_opcxx . . $ ggml_op# * ops,
662 const int * outputs,
663 int num_outputs);
664
665 // Returns true if the subgraph formed by {node_idxs} can be fused
666 // checks whethers all nodes which are not part of outputs can be elided
667 // by checking if their num_uses are confined to the subgraph
668 static inline boolcxx . . $ `<external>/14268322491693841775/stdbool.h:36:9`! ggml_can_fuse_subgraphcxx . . $ ggml_can_fuse_subgraph(814cd68bef091a95).(const struct ggml_cgraphcxx . . $ ggml_cgraph# * cgraph,
669 int node_idx,
670 int count,
671 const enum ggml_opcxx . . $ ggml_op# * ops,
672 const int * outputs,
673 int num_outputs) {
674 GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(count < 32);
675 if (node_idx + count > cgraph->n_nodescxx . . $ ggml_cgraph#n_nodes.) {
676 return falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!;
677 }
678
679 int idxs[32];
680
681 for (int i = 0; i < count; ++i) {
682 idxs[i] = node_idx + i;
683 }
684
685 return ggml_can_fuse_subgraph_extcxx . . $ ggml_can_fuse_subgraph_ext(2931c63e51fb5b9f).(cgraph, idxs, count, ops, outputs, num_outputs);
686 }
687
688 #ifdef __cpluspluscxx . . $ `<built-in>:470:9`!
689 }
690 #endif
691
692 #ifdef __cpluspluscxx . . $ `<built-in>:470:9`!
693 #include <array>
694 #include <initializer_list>
695 #include <vector>
696
697 // nicer C++ syntax for ggml_can_fuse
698 inline bool ggml_can_fusecxx . . $ ggml_can_fuse(82692576128275dc).(const struct ggml_cgraph * cgraph, int node_idx, stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<enum ggml_op> ops) {
699 return ggml_can_fuse(cgraph, node_idx, ops.begincxx . . $ std/initializer_list#begin(8e614c7de0b1573e).(), (int)ops.sizecxx . . $ std/initializer_list#size(c9b1e749b64d5edc).());
700 }
701
702 inline bool ggml_can_fuse_subgraphcxx . . $ ggml_can_fuse_subgraph(10d8c9d8d7b93433).(const struct ggml_cgraph * cgraph,
703 int start_idx,
704 stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<enum ggml_op> ops,
705 stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<int> outputs =cxx . . $ std/initializer_list#initializer_list(ced63f7c635d850d). {}) {
706 return ggml_can_fuse_subgraph(cgraph, start_idx, ops.sizecxx . . $ std/initializer_list#size(c9b1e749b64d5edc).(), ops.begincxx . . $ std/initializer_list#begin(8e614c7de0b1573e).(), outputs.begincxx . . $ std/initializer_list#begin(8e614c7de0b1573e).(), outputs.sizecxx . . $ std/initializer_list#size(c9b1e749b64d5edc).());
707 }
708
709 // Return true if the edges in the graph match expectations.
710 inline bool ggml_check_edgescxx . . $ ggml_check_edges(fcc11479b18c3b4e).(const struct ggml_cgraph * cgraph,
711 int start_idx,
712 stdcxx . . $ std/::initializer_listcxx . . $ std/initializer_list#<stdcxx . . $ std/::arraycxx . . $ std/array#<int, 3>> edges) {
713 for (const auto & edge : edges) {
714 int dst_node = edge[cxx . . $ std/array#`operator[]`(c65000e556194d6f).0];
715 int src_idx = edge[cxx . . $ std/array#`operator[]`(c65000e556194d6f).1];
716 int src_node = edge[cxx . . $ std/array#`operator[]`(c65000e556194d6f).2];
717 if (cgraph->nodes[start_idx + dst_node]->src[src_idx] != cgraph->nodes[start_idx + src_node]) {
718 return false;
719 }
720 }
721 return true;
722 }
723
724 // expose GGUF internals for test code
725 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! size_t gguf_type_sizecxx . . $ gguf_type_size(74e49fb658a3f85).(enum gguf_type type);
726 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! struct gguf_context * gguf_init_from_file_implcxx . . $ gguf_init_from_file_impl(f1ea5011fe406ea7).(FILE * file, struct gguf_init_params params);
727 GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! void gguf_write_to_bufcxx . . $ gguf_write_to_buf(3e95cd772aa7cbf0).(const struct gguf_context * ctx, stdcxx . . $ std/::vectorcxx . . $ std/vector#<int8_tcxx . . $ int8_t#> & buf, bool only_meta);
728 #endif // __cplusplus