| 1 | #cxx . . $ `<file>/external/whispercpp/ggml.cpp`/define _CRT_SECURE_NO_DEPRECATEcxx . . $ `external/whispercpp/ggml.cpp:1:9`! // Disables "unsafe" warnings on Windows |
| 2 | #define _USE_MATH_DEFINEScxx . . $ `external/whispercpp/ggml.cpp:2:9`! // For M_PI on MSVC |
| 3 | |
| 4 | #include "ggml-backend.h"cxx . . $ `<file>/external/whispercpp/ggml-backend.h`/ |
| 5 | #include "ggml-impl.h"cxx . . $ `<file>/external/whispercpp/ggml-impl.h`/ |
| 6 | #include "ggml-threading.h"cxx . . $ `<file>/external/whispercpp/ggml-threading.h`/ |
| 7 | #include "ggml-cpu.h"cxx . . $ `<file>/external/whispercpp/ggml-cpu.h`/ |
| 8 | #include "ggml.h"cxx . . $ `<file>/external/whispercpp/ggml.h`/ |
| 9 | |
| 10 | #include "melder.h"cxx . . $ `<file>/melder/melder.h`/ |
| 11 | #include "ggml-memory-pool.h"cxx . . $ `<file>/external/whispercpp/ggml-memory-pool.h`/ |
| 12 | |
| 13 | // FIXME: required here for quantization functions |
| 14 | #include "ggml-quants.h"cxx . . $ `<file>/external/whispercpp/ggml-quants.h`/ |
| 15 | |
| 16 | #ifdef GGML_USE_CPU_HBM |
| 17 | #include <hbwmalloc.h> |
| 18 | #endif |
| 19 | |
| 20 | #if defined(_MSC_VER) || defined(__MINGW32__) |
| 21 | #include <malloc.h> // using malloc.h with MSC/MINGW |
| 22 | #elif !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) |
| 23 | #include <alloca.h> |
| 24 | #endif |
| 25 | |
| 26 | #include <assert.h> |
| 27 | #include <errno.h> |
| 28 | #include <time.h> |
| 29 | #include <math.h> |
| 30 | #include <stdlib.h> |
| 31 | #include <string.h> |
| 32 | #include <stdint.h> |
| 33 | #include <inttypes.h> |
| 34 | #include <stdio.h> |
| 35 | #include <float.h> |
| 36 | #include <limits.h> |
| 37 | #include <stdarg.h> |
| 38 | #include <signal.h> |
| 39 | #if defined(__gnu_linux__cxx . . $ `<built-in>:464:9`!) |
| 40 | #include <syscall.h> |
| 41 | #endif |
| 42 | |
| 43 | #if defined(__APPLE__) |
| 44 | #include <unistd.h> |
| 45 | #include <mach/mach.h> |
| 46 | #include <TargetConditionals.h> |
| 47 | #endif |
| 48 | |
| 49 | #if defined(_WIN32) |
| 50 | #define WIN32_LEAN_AND_MEAN |
| 51 | #ifndef NOMINMAX |
| 52 | #define NOMINMAX |
| 53 | #endif |
| 54 | #include <windows.h> |
| 55 | #endif |
| 56 | |
| 57 | #define UNUSEDcxx . . $ `external/whispercpp/ggml.cpp:57:9`! GGML_UNUSEDcxx . . $ `external/whispercpp/ggml.h:270:9`! |
| 58 | |
| 59 | // Needed for ggml_fp32_to_bf16_row() |
| 60 | #if defined(__AVX512BF16__) |
| 61 | #if defined(_MSC_VER) |
| 62 | #define m512i(p) p |
| 63 | #else |
| 64 | #include <immintrin.h> |
| 65 | #define m512i(p) (__m512i)(p) |
| 66 | #endif // defined(_MSC_VER) |
| 67 | #endif // defined(__AVX512BF16__) |
| 68 | |
| 69 | #if defined(__linux__cxx . . $ `<built-in>:463:9`!) || \ |
| 70 | defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ |
| 71 | (defined(__APPLE__) && !TARGET_OS_TV && !TARGET_OS_WATCH) |
| 72 | |
| 73 | #include <unistd.h> |
| 74 | #include <sys/types.h> |
| 75 | #include <sys/stat.h> |
| 76 | #include <sys/wait.h> |
| 77 | #if defined(__linux__cxx . . $ `<built-in>:463:9`!) |
| 78 | #include <sys/prctl.h> |
| 79 | #endif |
| 80 | |
| 81 | #if defined(__ANDROID__) |
| 82 | #include <unwind.h> |
| 83 | #include <dlfcn.h> |
| 84 | #include <stdio.h> |
| 85 | |
| 86 | struct backtrace_state { |
| 87 | void ** current; |
| 88 | void ** end; |
| 89 | }; |
| 90 | |
| 91 | static _Unwind_Reason_Code unwind_callback(struct _Unwind_Context* context, void* arg) { |
| 92 | struct backtrace_state * state = (struct backtrace_state *)arg; |
| 93 | uintptr_t pc = _Unwind_GetIP(context); |
| 94 | if (pc) { |
| 95 | if (state->current == state->end) { |
| 96 | return _URC_END_OF_STACK; |
| 97 | } else { |
| 98 | *state->current++ = (void*)pc; |
| 99 | } |
| 100 | } |
| 101 | return _URC_NO_REASON; |
| 102 | } |
| 103 | |
| 104 | static void ggml_print_backtrace_symbols(void) { |
| 105 | const int max = 100; |
| 106 | void* buffer[max]; |
| 107 | |
| 108 | struct backtrace_state state = {buffer, buffer + max}; |
| 109 | _Unwind_Backtrace(unwind_callback, &state); |
| 110 | |
| 111 | int count = state.current - buffer; |
| 112 | |
| 113 | for (int idx = 0; idx < count; ++idx) { |
| 114 | const void * addr = buffer[idx]; |
| 115 | const char * symbol = ""; |
| 116 | |
| 117 | Dl_info info; |
| 118 | if (dladdr(addr, &info) && info.dli_sname) { |
| 119 | symbol = info.dli_sname; |
| 120 | } |
| 121 | |
| 122 | fprintf(stderr, "%d: %p %s\n", idx, addr, symbol); |
| 123 | } |
| 124 | } |
| 125 | #elif defined(__linux__cxx . . $ `<built-in>:463:9`!) && defined(__GLIBC__cxx . . $ `<external>/18206667465210621810/features.h:514:9`!) |
| 126 | #include <execinfo.h> |
| 127 | static void ggml_print_backtrace_symbolscxx . . $ ggml_print_backtrace_symbols(49f6e7a06ebc5aa8).(void) { |
| 128 | void * trace[100]; |
| 129 | int nptrs = backtrace(trace, sizeof(trace)/sizeof(trace[0])); |
| 130 | backtrace_symbols_fd(trace, nptrs, STDERR_FILENOcxx . . $ `<external>/12628407106812493757/unistd.h:212:9`!); |
| 131 | } |
| 132 | #elif defined(__APPLE__) |
| 133 | #include <execinfo.h> |
| 134 | static void ggml_print_backtrace_symbols(void) { |
| 135 | void * trace[100]; |
| 136 | int nptrs = backtrace(trace, sizeof(trace)/sizeof(trace[0])); |
| 137 | backtrace_symbols_fd(trace, nptrs, STDERR_FILENO); |
| 138 | } |
| 139 | #else |
| 140 | static void ggml_print_backtrace_symbols(void) { |
| 141 | // platform not supported |
| 142 | } |
| 143 | #endif |
| 144 | |
| 145 | void ggml_print_backtracecxx . . $ ggml_print_backtrace(49f6e7a06ebc5aa8).(void) { |
| 146 | const char * GGML_NO_BACKTRACE = getenvcxx . . $ getenv(c63359b659779399).("GGML_NO_BACKTRACE"); |
| 147 | if (GGML_NO_BACKTRACE) { |
| 148 | return; |
| 149 | } |
| 150 | #if defined(__APPLE__) |
| 151 | // On macOS, fork+debugger attachment is problematic due to: |
| 152 | // 1. libdispatch "poisons" forked child processes |
| 153 | // 2. lldb has issues attaching to parent from forked child |
| 154 | // Use simple backtrace() instead to avoid Terminal.app crashes |
| 155 | const char * GGML_BACKTRACE_LLDB = getenv("GGML_BACKTRACE_LLDB"); |
| 156 | if (!GGML_BACKTRACE_LLDB) { |
| 157 | fprintf(stderr, "WARNING: Using native backtrace. Set GGML_BACKTRACE_LLDB for more info.\n"); |
| 158 | fprintf(stderr, "WARNING: GGML_BACKTRACE_LLDB may cause native MacOS Terminal.app to crash.\n"); |
| 159 | fprintf(stderr, "See: https://github.com/ggml-org/llama.cpp/pull/17869\n"); |
| 160 | ggml_print_backtrace_symbols(); |
| 161 | return; |
| 162 | } |
| 163 | #endif |
| 164 | #if defined(__linux__cxx . . $ `<built-in>:463:9`!) |
| 165 | FILE * f = fopen("/proc/self/status", "r"); |
| 166 | size_t size = 0; |
| 167 | char * line = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 168 | ssize_t length = 0; |
| 169 | while ((length = getline(&line, &size, f)) > 0) { |
| 170 | if (!strncmp(line, "TracerPid:", sizeof("TracerPid:") - 1) && |
| 171 | (length != sizeof("TracerPid:\t0\n") - 1 || line[length - 2] != '0')) { |
| 172 | // Already being debugged, and the breakpoint is the later abort() |
| 173 | freecxx . . $ free(bd21765a0afc8e3c).(line); |
| 174 | fclose(f); |
| 175 | return; |
| 176 | } |
| 177 | } |
| 178 | freecxx . . $ free(bd21765a0afc8e3c).(line); |
| 179 | fclose(f); |
| 180 | int lock[2] = { -1, -1 }; |
| 181 | (void) !pipe(lock); // Don't start gdb until after PR_SET_PTRACER |
| 182 | #endif |
| 183 | const int parent_pid = getpid(); |
| 184 | const int child_pid = fork(); |
| 185 | if (child_pid < 0) { // error |
| 186 | #if defined(__linux__cxx . . $ `<built-in>:463:9`!) |
| 187 | close(lock[1]); |
| 188 | close(lock[0]); |
| 189 | #endif |
| 190 | return; |
| 191 | } else if (child_pid == 0) { // child |
| 192 | char attach[32]; |
| 193 | snprintf(attach, sizeof(attach), "attach %d", parent_pid); |
| 194 | #if defined(__linux__cxx . . $ `<built-in>:463:9`!) |
| 195 | close(lock[1]); |
| 196 | (void) !read(lock[0], lock, 1); |
| 197 | close(lock[0]); |
| 198 | #endif |
| 199 | // try gdb |
| 200 | execlp("gdb", "gdb", "--batch", |
| 201 | "-ex", "set style enabled on", |
| 202 | "-ex", attach, |
| 203 | "-ex", "bt -frame-info source-and-location", |
| 204 | "-ex", "detach", |
| 205 | "-ex", "quit", |
| 206 | (char *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 207 | // try lldb |
| 208 | execlp("lldb", "lldb", "--batch", |
| 209 | "-o", "bt", |
| 210 | "-o", "quit", |
| 211 | "-p", &attach[sizeof("attach ") - 1], |
| 212 | (char *) NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 213 | // gdb failed, fallback to backtrace_symbols |
| 214 | ggml_print_backtrace_symbolscxx . . $ ggml_print_backtrace_symbols(49f6e7a06ebc5aa8).(); |
| 215 | _Exitcxx . . $ _Exit(44ed87f96534fad7).(0); |
| 216 | } else { // parent |
| 217 | #if defined(__linux__cxx . . $ `<built-in>:463:9`!) |
| 218 | prctl(PR_SET_PTRACERcxx . . $ `<external>/9872755456582759113/prctl.h:155:9`!, child_pid); |
| 219 | close(lock[1]); |
| 220 | close(lock[0]); |
| 221 | #endif |
| 222 | waitpid(child_pid, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0); |
| 223 | } |
| 224 | } |
| 225 | #else |
| 226 | void ggml_print_backtrace(void) { |
| 227 | // platform not supported |
| 228 | } |
| 229 | #endif |
| 230 | |
| 231 | static ggml_abort_callback_t g_abort_callbackcxx . . $ g_abort_callback. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 232 | |
| 233 | // Set the abort callback (passing null will restore original abort functionality: printing a message to stdout) |
| 234 | GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! ggml_abort_callback_t ggml_set_abort_callbackcxx . . $ ggml_set_abort_callback(a0aa52dc0a87bb46).(ggml_abort_callback_t callback) { |
| 235 | ggml_abort_callback_t ret_val = g_abort_callbackcxx . . $ g_abort_callback.; |
| 236 | g_abort_callbackcxx . . $ g_abort_callback. = callback; |
| 237 | return ret_val; |
| 238 | } |
| 239 | |
| 240 | void ggml_abortcxx . . $ ggml_abort(b8982657348efbf7).(const char * file, int line, const char * fmt, ...) { |
| 241 | fflush(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!); |
| 242 | |
| 243 | char message[2048]; |
| 244 | int offset = snprintf(message, sizeof(message), "%s:%d: ", file, line); |
| 245 | |
| 246 | va_list args; |
| 247 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 248 | vsnprintf(message + offset, sizeof(message) - offset, fmt, args); |
| 249 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 250 | |
| 251 | if (g_abort_callbackcxx . . $ g_abort_callback.) { |
| 252 | g_abort_callbackcxx . . $ g_abort_callback.(message); |
| 253 | } else { |
| 254 | // default: print error and backtrace to stderr |
| 255 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s\n", message); |
| 256 | ggml_print_backtracecxx . . $ ggml_print_backtrace(49f6e7a06ebc5aa8).(); |
| 257 | } |
| 258 | |
| 259 | Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (Melder_peek8to32_u (message)); |
| 260 | } |
| 261 | |
| 262 | #define GGML_MALLOCcxx . . $ `external/whispercpp/ggml.cpp:262:9`!(size) ggml_malloc(size) |
| 263 | #define GGML_CALLOCcxx . . $ `external/whispercpp/ggml.cpp:263:9`!(num, size) ggml_calloc(num, size) |
| 264 | #define GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(ptr) ggml_raw_free(ptr) |
| 265 | |
| 266 | // ggml_print_backtrace is registered with std::set_terminate by ggml.cpp |
| 267 | |
| 268 | // |
| 269 | // logging |
| 270 | // |
| 271 | |
| 272 | struct ggml_logger_statecxx . . $ ggml_logger_state# { |
| 273 | ggml_log_callback log_callbackcxx . . $ ggml_logger_state#log_callback.; |
| 274 | void * log_callback_user_datacxx . . $ ggml_logger_state#log_callback_user_data.; |
| 275 | }; |
| 276 | static struct ggml_logger_statecxx . . $ ggml_logger_state# g_logger_statecxx . . $ g_logger_state. = {ggml_log_callback_default, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!}; |
| 277 | |
| 278 | static void ggml_log_internal_vcxx . . $ ggml_log_internal_v(973c7dcab788c31f).(enum ggml_log_level level, const char * format, va_list args) { |
| 279 | if (format == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 280 | return; |
| 281 | } |
| 282 | va_list args_copy; |
| 283 | va_copycxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:56:9`!(args_copy, args); |
| 284 | char buffer[128]; |
| 285 | int len = vsnprintf(buffer, 128, format, args); |
| 286 | if (len < 128) { |
| 287 | g_logger_statecxx . . $ g_logger_state..log_callbackcxx . . $ ggml_logger_state#log_callback.(level, buffer, g_logger_statecxx . . $ g_logger_state..log_callback_user_datacxx . . $ ggml_logger_state#log_callback_user_data.); |
| 288 | } else { |
| 289 | char * buffer2 = (char *) GGML_CALLOCcxx . . $ `external/whispercpp/ggml.cpp:263:9`!(len + 1, sizeof(char)); |
| 290 | vsnprintf(buffer2, len + 1, format, args_copy); |
| 291 | buffer2[len] = 0; |
| 292 | g_logger_statecxx . . $ g_logger_state..log_callbackcxx . . $ ggml_logger_state#log_callback.(level, buffer2, g_logger_statecxx . . $ g_logger_state..log_callback_user_datacxx . . $ ggml_logger_state#log_callback_user_data.); |
| 293 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(buffer2); |
| 294 | } |
| 295 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args_copy); |
| 296 | } |
| 297 | |
| 298 | void ggml_log_internalcxx . . $ ggml_log_internal(484f38f1158c16f0).(enum ggml_log_level level, const char * format, ...) { |
| 299 | va_list args; |
| 300 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, format); |
| 301 | ggml_log_internal_vcxx . . $ ggml_log_internal_v(973c7dcab788c31f).(level, format, args); |
| 302 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 303 | } |
| 304 | |
| 305 | void ggml_log_callback_defaultcxx . . $ ggml_log_callback_default(1235eb62ccdaecf6).(enum ggml_log_level level, const char * text, void * user_data) { |
| 306 | (void) level; |
| 307 | (void) user_data; |
| 308 | fputs(text, stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 309 | fflush(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); |
| 310 | } |
| 311 | |
| 312 | // |
| 313 | // end of logging block |
| 314 | // |
| 315 | |
| 316 | #ifdef GGML_USE_ACCELERATE |
| 317 | // uncomment to use vDSP for soft max computation |
| 318 | // note: not sure if it is actually faster |
| 319 | //#define GGML_SOFT_MAX_ACCELERATE |
| 320 | #endif |
| 321 | |
| 322 | |
| 323 | void * ggml_aligned_malloccxx . . $ ggml_aligned_malloc(bfcfa4d6b7f7ef64).(size_t size) { |
| 324 | //TRACE |
| 325 | tracecxx . . $ `melder/melder_debug.h:60:10`!(size); |
| 326 | if (size == 0) |
| 327 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("Behavior may be unexpected when allocating 0 bytes for ggml_aligned_malloc!\n"); |
| 328 | |
| 329 | #if defined(__s390x__) |
| 330 | const int alignment = 256; |
| 331 | #else |
| 332 | const int alignment = 64; |
| 333 | #endif |
| 334 | |
| 335 | void *aligned_memory = nullptr; |
| 336 | |
| 337 | #if defined(_MSC_VER) || defined(__MINGW32__) |
| 338 | aligned_memory = _aligned_malloc(size, alignment); |
| 339 | #else |
| 340 | #ifdef GGML_USE_CPU_HBM |
| 341 | int result = hbw_posix_memalign(&aligned_memory, alignment, size); |
| 342 | #elif TARGET_OS_OSX |
| 343 | GGML_UNUSED(alignment); |
| 344 | kern_return_t alloc_status = vm_allocate((vm_map_t) mach_task_self(), (vm_address_t *) &aligned_memory, size, VM_FLAGS_ANYWHERE); |
| 345 | int result = EFAULT; |
| 346 | switch (alloc_status) { |
| 347 | case KERN_SUCCESS: |
| 348 | result = 0; |
| 349 | break; |
| 350 | case KERN_INVALID_ADDRESS: |
| 351 | result = EINVAL; |
| 352 | break; |
| 353 | case KERN_NO_SPACE: |
| 354 | result = ENOMEM; |
| 355 | break; |
| 356 | default: |
| 357 | result = EFAULT; |
| 358 | break; |
| 359 | } |
| 360 | #else |
| 361 | int result = posix_memalign(&aligned_memory, alignment, size); |
| 362 | #endif |
| 363 | if (result != 0) { |
| 364 | // Handle allocation failure |
| 365 | const char *error_desc = "unknown allocation error"; |
| 366 | switch (result) { |
| 367 | case EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!: |
| 368 | error_desc = "invalid alignment value"; |
| 369 | break; |
| 370 | case ENOMEMcxx . . $ `<external>/8987895939074593727/errno-base.h:16:9`!: |
| 371 | error_desc = "insufficient memory"; |
| 372 | break; |
| 373 | } |
| 374 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("%s: %s (attempted to allocate %6.2f MB)\n", __func__, error_desc, size/(1024.0*1024.0)); |
| 375 | } |
| 376 | #endif |
| 377 | |
| 378 | /* |
| 379 | Single exit point: throw an exception if memory not allocated, trace, and register allocation in theGgmlMemoryPool. |
| 380 | */ |
| 381 | if (! aligned_memory) |
| 382 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`! ("Failed to allocate %6.2f MB\n", size/(1024.0*1024.0)); |
| 383 | |
| 384 | theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..addcxx . . $ GgmlMemoryPool#add(3aa184a1f7b8f66e). (aligned_memory, size, true); |
| 385 | return aligned_memory; |
| 386 | } |
| 387 | |
| 388 | void ggml_aligned_freecxx . . $ ggml_aligned_free(3aa184a1f7b8f66e).(void * ptr, size_t size, bool toRemoveFromPool) { |
| 389 | bool removedFromPool = false; |
| 390 | if (toRemoveFromPool) |
| 391 | removedFromPool = theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..removecxx . . $ GgmlMemoryPool#remove(ba504f6f2e89cb92). (ptr, size); |
| 392 | if (! toRemoveFromPool || removedFromPool) { |
| 393 | GGML_UNUSEDcxx . . $ `external/whispercpp/ggml.h:270:9`!(size); |
| 394 | #if defined(_MSC_VER) || defined(__MINGW32__) |
| 395 | _aligned_free(ptr); |
| 396 | #elif GGML_USE_CPU_HBM |
| 397 | if (ptr != NULL) { |
| 398 | hbw_free(ptr); |
| 399 | } |
| 400 | #elif TARGET_OS_OSX |
| 401 | if (ptr != NULL) { |
| 402 | vm_deallocate((vm_map_t)mach_task_self(), (vm_address_t)ptr, size); |
| 403 | } |
| 404 | #else |
| 405 | freecxx . . $ free(bd21765a0afc8e3c).(ptr); |
| 406 | #endif |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | void * ggml_malloccxx . . $ ggml_malloc(bfcfa4d6b7f7ef64).(size_t size) { |
| 411 | //TRACE |
| 412 | tracecxx . . $ `melder/melder_debug.h:60:10`!(size); |
| 413 | |
| 414 | if (size == 0) |
| 415 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("Behavior may be unexpected when allocating 0 bytes for ggml_malloc!\n"); |
| 416 | |
| 417 | void * result = malloccxx . . $ malloc(9f008b2a9698428b).(size); |
| 418 | if (! result) |
| 419 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("%s: failed to allocate %6.2f MB\n", __func__, size/(1024.0*1024.0)); |
| 420 | |
| 421 | theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..addcxx . . $ GgmlMemoryPool#add(3aa184a1f7b8f66e). (result, size, false); |
| 422 | return result; |
| 423 | } |
| 424 | |
| 425 | // calloc - allowing to return NULL |
| 426 | void * ggml_calloccxx . . $ ggml_calloc(63a7bf2941bfcd7a).(size_t num, size_t size) { |
| 427 | if (num == 0 || size == 0) { |
| 428 | GGML_LOG_WARNcxx . . $ `external/whispercpp/ggml-impl.h:118:9`!("Behavior may be unexpected when allocating 0 bytes for ggml_calloc!\n"); |
| 429 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 430 | } |
| 431 | void * result = calloccxx . . $ calloc(95acc9b79bb49189).(num, size); |
| 432 | if (! result) |
| 433 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("%s: failed to allocate %6.2f MB\n", __func__, num * size/(1024.0*1024.0)); |
| 434 | |
| 435 | theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..addcxx . . $ GgmlMemoryPool#add(3aa184a1f7b8f66e). (result, num * size, false); |
| 436 | return result; |
| 437 | } |
| 438 | |
| 439 | void * ggml_realloccxx . . $ ggml_realloc(417ab160f6baadc6).(void * ptr, size_t size) { |
| 440 | if (size == 0) |
| 441 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("Behavior may be unexpected when allocating 0 bytes for ggml_malloc!\n"); |
| 442 | |
| 443 | void * result = realloccxx . . $ realloc(42b2a9dd8f084bf2).(ptr, size); |
| 444 | if (! result) |
| 445 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("%s: failed to reallocate %6.2f MB\n", __func__, size/(1024.0*1024.0)); |
| 446 | |
| 447 | theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..removecxx . . $ GgmlMemoryPool#remove(db00c6a08f501612). (ptr); |
| 448 | theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..addcxx . . $ GgmlMemoryPool#add(3aa184a1f7b8f66e). (result, size, false); |
| 449 | return result; |
| 450 | } |
| 451 | |
| 452 | void ggml_raw_freecxx . . $ ggml_raw_free(b81e5e1865225ade).(void *ptr, bool toRemoveFromPool) { |
| 453 | bool removedFromPool = false; |
| 454 | if (toRemoveFromPool) |
| 455 | removedFromPool = theGgmlMemoryPoolcxx . . $ theGgmlMemoryPool..removecxx . . $ GgmlMemoryPool#remove(db00c6a08f501612). (ptr); |
| 456 | if (! toRemoveFromPool || removedFromPool) |
| 457 | freecxx . . $ free(bd21765a0afc8e3c). (ptr); |
| 458 | } |
| 459 | |
| 460 | const char * ggml_status_to_stringcxx . . $ ggml_status_to_string(839868cd072ecf2f).(enum ggml_status status) { |
| 461 | switch (status) { |
| 462 | case GGML_STATUS_ALLOC_FAILED: return "GGML status: error (failed to allocate memory)"; |
| 463 | case GGML_STATUS_FAILED: return "GGML status: error (operation failed)"; |
| 464 | case GGML_STATUS_SUCCESS: return "GGML status: success"; |
| 465 | case GGML_STATUS_ABORTED: return "GGML status: warning (operation aborted)"; |
| 466 | } |
| 467 | |
| 468 | return "GGML status: unknown"; |
| 469 | } |
| 470 | |
| 471 | float ggml_fp16_to_fp32cxx . . $ ggml_fp16_to_fp32(9a38df040a81ca35).(ggml_fp16_t x) { |
| 472 | #define ggml_fp16_to_fp32cxx . . $ `external/whispercpp/ggml.cpp:472:9`! do_not_use__ggml_fp16_to_fp32__in_ggml |
| 473 | return GGML_FP16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:435:9`!(x); |
| 474 | } |
| 475 | |
| 476 | ggml_fp16_t ggml_fp32_to_fp16cxx . . $ ggml_fp32_to_fp16(a7602afe0c5a7a59).(float x) { |
| 477 | #define ggml_fp32_to_fp16cxx . . $ `external/whispercpp/ggml.cpp:477:9`! do_not_use__ggml_fp32_to_fp16__in_ggml |
| 478 | return GGML_FP32_TO_FP16cxx . . $ `external/whispercpp/ggml-impl.h:436:9`!(x); |
| 479 | } |
| 480 | |
| 481 | float ggml_bf16_to_fp32cxx . . $ ggml_bf16_to_fp32(19100f69e776d75a).(ggml_bf16_t x) { |
| 482 | #define ggml_bf16_to_fp32cxx . . $ `external/whispercpp/ggml.cpp:482:9`! do_not_use__ggml_bf16_to_fp32__in_ggml |
| 483 | return GGML_BF16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:571:9`!(x); // it just left shifts |
| 484 | } |
| 485 | |
| 486 | ggml_bf16_t ggml_fp32_to_bf16cxx . . $ ggml_fp32_to_bf16(4b9b7da6982f80a2).(float x) { |
| 487 | #define ggml_fp32_to_bf16cxx . . $ `external/whispercpp/ggml.cpp:487:9`! do_not_use__ggml_fp32_to_bf16__in_ggml |
| 488 | return GGML_FP32_TO_BF16cxx . . $ `external/whispercpp/ggml-impl.h:570:9`!(x); |
| 489 | } |
| 490 | |
| 491 | void ggml_fp16_to_fp32_rowcxx . . $ ggml_fp16_to_fp32_row(3f92e3d779c5f78e).(const ggml_fp16_t * x, float * y, int64_tcxx . . $ int64_t# n) { |
| 492 | for (int64_tcxx . . $ int64_t# i = 0; i < n; i++) { |
| 493 | y[i] = GGML_FP16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:435:9`!(x[i]); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | void ggml_fp32_to_fp16_rowcxx . . $ ggml_fp32_to_fp16_row(d0bddba7da29e34c).(const float * x, ggml_fp16_t * y, int64_tcxx . . $ int64_t# n) { |
| 498 | int i = 0; |
| 499 | for (; i < n; ++i) { |
| 500 | y[i] = GGML_FP32_TO_FP16cxx . . $ `external/whispercpp/ggml-impl.h:436:9`!(x[i]); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | void ggml_bf16_to_fp32_rowcxx . . $ ggml_bf16_to_fp32_row(2809a1300879b1ba).(const ggml_bf16_t * x, float * y, int64_tcxx . . $ int64_t# n) { |
| 505 | int i = 0; |
| 506 | for (; i < n; ++i) { |
| 507 | y[i] = GGML_BF16_TO_FP32cxx . . $ `external/whispercpp/ggml-impl.h:571:9`!(x[i]); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | void ggml_fp32_to_bf16_row_refcxx . . $ ggml_fp32_to_bf16_row_ref(391ac1fe44da9fcc).(const float * x, ggml_bf16_t * y, int64_tcxx . . $ int64_t# n) { |
| 512 | for (int i = 0; i < n; i++) { |
| 513 | y[i] = ggml_compute_fp32_to_bf16(x[i]); |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | void ggml_fp32_to_bf16_rowcxx . . $ ggml_fp32_to_bf16_row(391ac1fe44da9fcc).(const float * x, ggml_bf16_t * y, int64_tcxx . . $ int64_t# n) { |
| 518 | int i = 0; |
| 519 | #if defined(__AVX512BF16__) |
| 520 | // subnormals are flushed to zero on this platform |
| 521 | for (; i + 32 <= n; i += 32) { |
| 522 | _mm512_storeu_si512( |
| 523 | (__m512i *)(y + i), |
| 524 | m512i(_mm512_cvtne2ps_pbh(_mm512_loadu_ps(x + i + 16), |
| 525 | _mm512_loadu_ps(x + i)))); |
| 526 | } |
| 527 | #endif |
| 528 | for (; i < n; i++) { |
| 529 | y[i] = GGML_FP32_TO_BF16cxx . . $ `external/whispercpp/ggml-impl.h:570:9`!(x[i]); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | bool ggml_guid_matchescxx . . $ ggml_guid_matches(5f89f6dfb64bbaf).(ggml_guid_t guid_a, ggml_guid_t guid_b) { |
| 534 | return memcmp(guid_a, guid_b, sizeof(ggml_guid)) == 0; |
| 535 | } |
| 536 | |
| 537 | const char * ggml_versioncxx . . $ ggml_version(33a1f659e94feb42).(void) { |
| 538 | return GGML_VERSIONcxx . . $ `external/whispercpp/ggml.h:7:9`!; |
| 539 | } |
| 540 | |
| 541 | const char * ggml_commitcxx . . $ ggml_commit(33a1f659e94feb42).(void) { |
| 542 | return GGML_COMMITcxx . . $ `external/whispercpp/ggml.h:8:9`!; |
| 543 | } |
| 544 | |
| 545 | // |
| 546 | // timing |
| 547 | // |
| 548 | |
| 549 | #if defined(_MSC_VER) || defined(__MINGW32__) |
| 550 | static int64_t timer_freq, timer_start; |
| 551 | void ggml_time_init(void) { |
| 552 | LARGE_INTEGER t; |
| 553 | QueryPerformanceFrequency(&t); |
| 554 | timer_freq = t.QuadPart; |
| 555 | |
| 556 | // The multiplication by 1000 or 1000000 below can cause an overflow if timer_freq |
| 557 | // and the uptime is high enough. |
| 558 | // We subtract the program start time to reduce the likelihood of that happening. |
| 559 | QueryPerformanceCounter(&t); |
| 560 | timer_start = t.QuadPart; |
| 561 | } |
| 562 | int64_t ggml_time_ms(void) { |
| 563 | LARGE_INTEGER t; |
| 564 | QueryPerformanceCounter(&t); |
| 565 | return ((t.QuadPart-timer_start) * 1000) / timer_freq; |
| 566 | } |
| 567 | int64_t ggml_time_us(void) { |
| 568 | LARGE_INTEGER t; |
| 569 | QueryPerformanceCounter(&t); |
| 570 | return ((t.QuadPart-timer_start) * 1000000) / timer_freq; |
| 571 | } |
| 572 | #else |
| 573 | void ggml_time_initcxx . . $ ggml_time_init(49f6e7a06ebc5aa8).(void) {} |
| 574 | int64_tcxx . . $ int64_t# ggml_time_mscxx . . $ ggml_time_ms(da6335ded91d79c2).(void) { |
| 575 | struct timespec ts; |
| 576 | clock_gettime(CLOCK_MONOTONICcxx . . $ `<external>/89459239771508533/time.h:48:10`!, &ts); |
| 577 | return (int64_tcxx . . $ int64_t#)ts.tv_sec*1000 + (int64_tcxx . . $ int64_t#)ts.tv_nsec/1000000; |
| 578 | } |
| 579 | |
| 580 | int64_tcxx . . $ int64_t# ggml_time_uscxx . . $ ggml_time_us(da6335ded91d79c2).(void) { |
| 581 | struct timespec ts; |
| 582 | clock_gettime(CLOCK_MONOTONICcxx . . $ `<external>/89459239771508533/time.h:48:10`!, &ts); |
| 583 | return (int64_tcxx . . $ int64_t#)ts.tv_sec*1000000 + (int64_tcxx . . $ int64_t#)ts.tv_nsec/1000; |
| 584 | } |
| 585 | #endif |
| 586 | |
| 587 | int64_tcxx . . $ int64_t# ggml_cyclescxx . . $ ggml_cycles(da6335ded91d79c2).(void) { |
| 588 | return clock(); |
| 589 | } |
| 590 | |
| 591 | int64_tcxx . . $ int64_t# ggml_cycles_per_mscxx . . $ ggml_cycles_per_ms(da6335ded91d79c2).(void) { |
| 592 | return CLOCKS_PER_SECcxx . . $ `<external>/89459239771508533/time.h:34:9`!/1000; |
| 593 | } |
| 594 | |
| 595 | // |
| 596 | // cross-platform UTF-8 file paths |
| 597 | // |
| 598 | |
| 599 | #ifdef _WIN32 |
| 600 | static wchar_t * ggml_mbstowcs(const char * mbs) { |
| 601 | int wlen = MultiByteToWideChar(CP_UTF8, 0, mbs, -1, NULL, 0); |
| 602 | if (!wlen) { |
| 603 | errno = EINVAL; |
| 604 | return NULL; |
| 605 | } |
| 606 | |
| 607 | wchar_t * wbuf = (wchar_t *) GGML_MALLOC(wlen * sizeof(wchar_t)); |
| 608 | wlen = MultiByteToWideChar(CP_UTF8, 0, mbs, -1, wbuf, wlen); |
| 609 | if (!wlen) { |
| 610 | GGML_FREE(wbuf); |
| 611 | errno = EINVAL; |
| 612 | return NULL; |
| 613 | } |
| 614 | |
| 615 | return wbuf; |
| 616 | } |
| 617 | #endif |
| 618 | |
| 619 | FILE * ggml_fopencxx . . $ ggml_fopen(82ec0787cd37e0a3).(const char * fname, const char * mode) { |
| 620 | #ifdef _WIN32 |
| 621 | FILE * file = NULL; |
| 622 | |
| 623 | // convert fname (UTF-8) |
| 624 | wchar_t * wfname = ggml_mbstowcs(fname); |
| 625 | if (wfname) { |
| 626 | // convert mode (ANSI) |
| 627 | wchar_t * wmode = (wchar_t *) GGML_MALLOC((strlen(mode) + 1) * sizeof(wchar_t)); |
| 628 | wchar_t * wmode_p = wmode; |
| 629 | do { |
| 630 | *wmode_p++ = (wchar_t)*mode; |
| 631 | } while (*mode++); |
| 632 | |
| 633 | // open file |
| 634 | file = _wfopen(wfname, wmode); |
| 635 | |
| 636 | GGML_FREE(wfname); |
| 637 | GGML_FREE(wmode); |
| 638 | } |
| 639 | |
| 640 | return file; |
| 641 | #else |
| 642 | return fopen(fname, mode); |
| 643 | #endif |
| 644 | |
| 645 | } |
| 646 | |
| 647 | extern const struct ggml_type_traits type_traitscxx . . $ type_traits.[GGML_TYPE_COUNT]; |
| 648 | |
| 649 | const struct ggml_type_traits * ggml_get_type_traitscxx . . $ ggml_get_type_traits(4fdea2f83f100047).(enum ggml_type type) { |
| 650 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type >= 0); |
| 651 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type < GGML_TYPE_COUNT); |
| 652 | return &type_traitscxx . . $ type_traits.[type]; |
| 653 | } |
| 654 | |
| 655 | // |
| 656 | // ggml object |
| 657 | // |
| 658 | |
| 659 | struct ggml_objectcxx . . $ ggml_object# { |
| 660 | size_t offscxx . . $ ggml_object#offs.; |
| 661 | size_t sizecxx . . $ ggml_object#size.; |
| 662 | |
| 663 | struct ggml_objectcxx . . $ ggml_object# * nextcxx . . $ ggml_object#next.; |
| 664 | |
| 665 | enum ggml_object_type typecxx . . $ ggml_object#type.; |
| 666 | |
| 667 | char paddingcxx . . $ ggml_object#padding.[4]; |
| 668 | }; |
| 669 | |
| 670 | static const size_t GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE. = sizeof(struct ggml_objectcxx . . $ ggml_object#); |
| 671 | |
| 672 | // |
| 673 | // ggml context |
| 674 | // |
| 675 | |
| 676 | struct ggml_contextcxx . . $ ggml_context# { |
| 677 | size_t mem_sizecxx . . $ ggml_context#mem_size.; |
| 678 | void * mem_buffercxx . . $ ggml_context#mem_buffer.; |
| 679 | bool mem_buffer_ownedcxx . . $ ggml_context#mem_buffer_owned.; |
| 680 | bool no_alloccxx . . $ ggml_context#no_alloc.; |
| 681 | |
| 682 | int n_objectscxx . . $ ggml_context#n_objects.; |
| 683 | |
| 684 | struct ggml_objectcxx . . $ ggml_object# * objects_begincxx . . $ ggml_context#objects_begin.; |
| 685 | struct ggml_objectcxx . . $ ggml_object# * objects_endcxx . . $ ggml_context#objects_end.; |
| 686 | }; |
| 687 | |
| 688 | // |
| 689 | // data types |
| 690 | // |
| 691 | |
| 692 | static const char * GGML_OP_NAMEcxx . . $ GGML_OP_NAME.[GGML_OP_COUNT] = { |
| 693 | "NONE", |
| 694 | |
| 695 | "DUP", |
| 696 | "ADD", |
| 697 | "ADD_ID", |
| 698 | "ADD1", |
| 699 | "ACC", |
| 700 | "SUB", |
| 701 | "MUL", |
| 702 | "DIV", |
| 703 | "SQR", |
| 704 | "SQRT", |
| 705 | "LOG", |
| 706 | "SIN", |
| 707 | "COS", |
| 708 | "SUM", |
| 709 | "SUM_ROWS", |
| 710 | "CUMSUM", |
| 711 | "MEAN", |
| 712 | "ARGMAX", |
| 713 | "COUNT_EQUAL", |
| 714 | "REPEAT", |
| 715 | "REPEAT_BACK", |
| 716 | "CONCAT", |
| 717 | "SILU_BACK", |
| 718 | "NORM", |
| 719 | "RMS_NORM", |
| 720 | "RMS_NORM_BACK", |
| 721 | "GROUP_NORM", |
| 722 | "L2_NORM", |
| 723 | |
| 724 | "MUL_MAT", |
| 725 | "MUL_MAT_ID", |
| 726 | "OUT_PROD", |
| 727 | |
| 728 | "SCALE", |
| 729 | "SET", |
| 730 | "CPY", |
| 731 | "CONT", |
| 732 | "RESHAPE", |
| 733 | "VIEW", |
| 734 | "PERMUTE", |
| 735 | "TRANSPOSE", |
| 736 | "GET_ROWS", |
| 737 | "GET_ROWS_BACK", |
| 738 | "SET_ROWS", |
| 739 | "DIAG", |
| 740 | "DIAG_MASK_INF", |
| 741 | "DIAG_MASK_ZERO", |
| 742 | "SOFT_MAX", |
| 743 | "SOFT_MAX_BACK", |
| 744 | "ROPE", |
| 745 | "ROPE_BACK", |
| 746 | "CLAMP", |
| 747 | "CONV_TRANSPOSE_1D", |
| 748 | "IM2COL", |
| 749 | "IM2COL_BACK", |
| 750 | "IM2COL_3D", |
| 751 | "CONV_2D", |
| 752 | "CONV_3D", |
| 753 | "CONV_2D_DW", |
| 754 | "CONV_TRANSPOSE_2D", |
| 755 | "POOL_1D", |
| 756 | "POOL_2D", |
| 757 | "POOL_2D_BACK", |
| 758 | "UPSCALE", |
| 759 | "PAD", |
| 760 | "PAD_REFLECT_1D", |
| 761 | "ROLL", |
| 762 | "ARANGE", |
| 763 | "TIMESTEP_EMBEDDING", |
| 764 | "ARGSORT", |
| 765 | "TOP_K", |
| 766 | "LEAKY_RELU", |
| 767 | "TRI", |
| 768 | "FILL", |
| 769 | |
| 770 | "FLASH_ATTN_EXT", |
| 771 | "FLASH_ATTN_BACK", |
| 772 | "SSM_CONV", |
| 773 | "SSM_SCAN", |
| 774 | "WIN_PART", |
| 775 | "WIN_UNPART", |
| 776 | "GET_REL_POS", |
| 777 | "ADD_REL_POS", |
| 778 | "RWKV_WKV6", |
| 779 | "GATED_LINEAR_ATTN", |
| 780 | "RWKV_WKV7", |
| 781 | "SOLVE_TRI", |
| 782 | |
| 783 | "UNARY", |
| 784 | |
| 785 | "MAP_CUSTOM1", |
| 786 | "MAP_CUSTOM2", |
| 787 | "MAP_CUSTOM3", |
| 788 | |
| 789 | "CUSTOM", |
| 790 | |
| 791 | "CROSS_ENTROPY_LOSS", |
| 792 | "CROSS_ENTROPY_LOSS_BACK", |
| 793 | "OPT_STEP_ADAMW", |
| 794 | "OPT_STEP_SGD", |
| 795 | |
| 796 | "GLU", |
| 797 | }; |
| 798 | |
| 799 | static_assert(GGML_OP_COUNT == 95, "GGML_OP_COUNT != 95"); |
| 800 | |
| 801 | static const char * GGML_OP_SYMBOLcxx . . $ GGML_OP_SYMBOL.[GGML_OP_COUNT] = { |
| 802 | "none", |
| 803 | |
| 804 | "x", |
| 805 | "x+y", |
| 806 | "x[i]+y", |
| 807 | "x+y", |
| 808 | "view(x,nb,offset)+=y->x", |
| 809 | "x-y", |
| 810 | "x*y", |
| 811 | "x/y", |
| 812 | "x^2", |
| 813 | "√x", |
| 814 | "log(x)", |
| 815 | "sin(x)", |
| 816 | "cos(x)", |
| 817 | "Σx", |
| 818 | "Σx_k", |
| 819 | "cumsum(x)", |
| 820 | "Σx/n", |
| 821 | "argmax(x)", |
| 822 | "count_equal(x)", |
| 823 | "repeat(x)", |
| 824 | "repeat_back(x)", |
| 825 | "concat(x, y)", |
| 826 | "silu_back(x)", |
| 827 | "norm(x)", |
| 828 | "rms_norm(x)", |
| 829 | "rms_norm_back(x)", |
| 830 | "group_norm(x)", |
| 831 | "l2_norm(x)", |
| 832 | |
| 833 | "X*Y", |
| 834 | "X[i]*Y", |
| 835 | "X*Y", |
| 836 | |
| 837 | "x*v", |
| 838 | "y-\\>view(x)", |
| 839 | "x-\\>y", |
| 840 | "cont(x)", |
| 841 | "reshape(x)", |
| 842 | "view(x)", |
| 843 | "permute(x)", |
| 844 | "transpose(x)", |
| 845 | "get_rows(x)", |
| 846 | "get_rows_back(x)", |
| 847 | "set_rows(x)", |
| 848 | "diag(x)", |
| 849 | "diag_mask_inf(x)", |
| 850 | "diag_mask_zero(x)", |
| 851 | "soft_max(x)", |
| 852 | "soft_max_back(x)", |
| 853 | "rope(x)", |
| 854 | "rope_back(x)", |
| 855 | "clamp(x)", |
| 856 | "conv_transpose_1d(x)", |
| 857 | "im2col(x)", |
| 858 | "im2col_back(x)", |
| 859 | "im2col_3d(x)", |
| 860 | "conv_2d(x)", |
| 861 | "conv_3d(x)", |
| 862 | "conv_2d_dw(x)", |
| 863 | "conv_transpose_2d(x)", |
| 864 | "pool_1d(x)", |
| 865 | "pool_2d(x)", |
| 866 | "pool_2d_back(x)", |
| 867 | "upscale(x)", |
| 868 | "pad(x)", |
| 869 | "pad_reflect_1d(x)", |
| 870 | "roll(x)", |
| 871 | "arange(start, stop, step)", |
| 872 | "timestep_embedding(timesteps, dim, max_period)", |
| 873 | "argsort(x)", |
| 874 | "top_k(x)", |
| 875 | "leaky_relu(x)", |
| 876 | "tri(x)", |
| 877 | "fill(x, c)", |
| 878 | |
| 879 | "flash_attn_ext(x)", |
| 880 | "flash_attn_back(x)", |
| 881 | "ssm_conv(x)", |
| 882 | "ssm_scan(x)", |
| 883 | "win_part(x)", |
| 884 | "win_unpart(x)", |
| 885 | "get_rel_pos(x)", |
| 886 | "add_rel_pos(x)", |
| 887 | "rwkv_wkv6(k, v, r, tf, td, s)", |
| 888 | "gated_linear_attn(k, v, q, gate, s)", |
| 889 | "rwkv_wkv7(r, w, k, v, a, b, s)", |
| 890 | "A X = B, A triangular, solve X", |
| 891 | |
| 892 | "unary(x)", |
| 893 | |
| 894 | "map_custom(x)", |
| 895 | "map_custom(x,y)", |
| 896 | "map_custom(x,y,z)", |
| 897 | |
| 898 | "custom(x)", |
| 899 | |
| 900 | "cross_entropy_loss(x,y)", |
| 901 | "cross_entropy_loss_back(x,y)", |
| 902 | "adamw(x)", |
| 903 | "sgd(x)", |
| 904 | |
| 905 | "glu(x)", |
| 906 | }; |
| 907 | |
| 908 | static_assert(GGML_OP_COUNT == 95, "GGML_OP_COUNT != 95"); |
| 909 | |
| 910 | static_assert(GGML_OP_POOL_COUNT == 2, "GGML_OP_POOL_COUNT != 2"); |
| 911 | |
| 912 | static const char * GGML_UNARY_OP_NAMEcxx . . $ GGML_UNARY_OP_NAME.[GGML_UNARY_OP_COUNT] = { |
| 913 | "ABS", |
| 914 | "SGN", |
| 915 | "NEG", |
| 916 | "STEP", |
| 917 | "TANH", |
| 918 | "ELU", |
| 919 | "RELU", |
| 920 | "SIGMOID", |
| 921 | "GELU", |
| 922 | "GELU_QUICK", |
| 923 | "SILU", |
| 924 | "HARDSWISH", |
| 925 | "HARDSIGMOID", |
| 926 | "EXP", |
| 927 | "EXPM1", |
| 928 | "SOFTPLUS", |
| 929 | "GELU_ERF", |
| 930 | "XIELU", |
| 931 | "FLOOR", |
| 932 | "CEIL", |
| 933 | "ROUND", |
| 934 | "TRUNC", |
| 935 | }; |
| 936 | |
| 937 | static_assert(GGML_UNARY_OP_COUNT == 22, "GGML_UNARY_OP_COUNT != 22"); |
| 938 | |
| 939 | static const char * GGML_GLU_OP_NAMEcxx . . $ GGML_GLU_OP_NAME.[GGML_GLU_OP_COUNT] = { |
| 940 | "REGLU", |
| 941 | "GEGLU", |
| 942 | "SWIGLU", |
| 943 | "SWIGLU_OAI", |
| 944 | "GEGLU_ERF", |
| 945 | "GEGLU_QUICK", |
| 946 | }; |
| 947 | |
| 948 | static_assert(GGML_GLU_OP_COUNT == 6, "GGML_GLU_OP_COUNT != 6"); |
| 949 | |
| 950 | |
| 951 | static_assert(sizeof(struct ggml_objectcxx . . $ ggml_object#)%GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`! == 0, "ggml_object size must be a multiple of GGML_MEM_ALIGN"); |
| 952 | static_assert(sizeof(struct ggml_tensor)%GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`! == 0, "ggml_tensor size must be a multiple of GGML_MEM_ALIGN"); |
| 953 | |
| 954 | |
| 955 | //////////////////////////////////////////////////////////////////////////////// |
| 956 | |
| 957 | void ggml_print_objectcxx . . $ ggml_print_object(a43ce3dc61ab81bb).(const struct ggml_objectcxx . . $ ggml_object# * obj) { |
| 958 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!(" - ggml_object: type = %d, offset = %zu, size = %zu, next = %p\n", |
| 959 | obj->type, obj->offs, obj->size, (const void *) obj->next); |
| 960 | } |
| 961 | |
| 962 | void ggml_print_objectscxx . . $ ggml_print_objects(aaebf4ad2a404de1).(const struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 963 | struct ggml_objectcxx . . $ ggml_object# * obj = ctx->objects_begincxx . . $ ggml_context#objects_begin.; |
| 964 | |
| 965 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("%s: objects in context %p:\n", __func__, (const void *) ctx); |
| 966 | |
| 967 | while (obj != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 968 | ggml_print_objectcxx . . $ ggml_print_object(a43ce3dc61ab81bb).(obj); |
| 969 | obj = obj->nextcxx . . $ ggml_object#next.; |
| 970 | } |
| 971 | |
| 972 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("%s: --- end ---\n", __func__); |
| 973 | } |
| 974 | |
| 975 | int64_tcxx . . $ int64_t# ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(const struct ggml_tensor * tensor) { |
| 976 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 977 | |
| 978 | return tensor->ne[0]*tensor->ne[1]*tensor->ne[2]*tensor->ne[3]; |
| 979 | } |
| 980 | |
| 981 | int64_tcxx . . $ int64_t# ggml_nrowscxx . . $ ggml_nrows(1c1d1f12eaca9937).(const struct ggml_tensor * tensor) { |
| 982 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 983 | |
| 984 | return tensor->ne[1]*tensor->ne[2]*tensor->ne[3]; |
| 985 | } |
| 986 | |
| 987 | size_t ggml_nbytescxx . . $ ggml_nbytes(7f354dd711c66cf7).(const struct ggml_tensor * tensor) { |
| 988 | for (int i = 0; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; ++i) { |
| 989 | if (tensor->ne[i] <= 0) { |
| 990 | return 0; |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | size_t nbytes; |
| 995 | const size_t blck_size = ggml_blck_size(tensor->type); |
| 996 | if (blck_size == 1) { |
| 997 | nbytes = ggml_type_size(tensor->type); |
| 998 | for (int i = 0; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; ++i) { |
| 999 | nbytes += (tensor->ne[i] - 1)*tensor->nb[i]; |
| 1000 | } |
| 1001 | } |
| 1002 | else { |
| 1003 | nbytes = tensor->ne[0]*tensor->nb[0]/blck_size; |
| 1004 | for (int i = 1; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; ++i) { |
| 1005 | nbytes += (tensor->ne[i] - 1)*tensor->nb[i]; |
| 1006 | } |
| 1007 | } |
| 1008 | |
| 1009 | return nbytes; |
| 1010 | } |
| 1011 | |
| 1012 | size_t ggml_nbytes_padcxx . . $ ggml_nbytes_pad(7f354dd711c66cf7).(const struct ggml_tensor * tensor) { |
| 1013 | return GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(ggml_nbytes(tensor), GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 1014 | } |
| 1015 | |
| 1016 | int64_tcxx . . $ int64_t# ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(enum ggml_type type) { |
| 1017 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type >= 0); |
| 1018 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type < GGML_TYPE_COUNT); |
| 1019 | return type_traitscxx . . $ type_traits.[type].blck_size; |
| 1020 | } |
| 1021 | |
| 1022 | size_t ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(enum ggml_type type) { |
| 1023 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type >= 0); |
| 1024 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type < GGML_TYPE_COUNT); |
| 1025 | return type_traitscxx . . $ type_traits.[type].type_size; |
| 1026 | } |
| 1027 | |
| 1028 | size_t ggml_row_sizecxx . . $ ggml_row_size(cd72edd651ca704e).(enum ggml_type type, int64_tcxx . . $ int64_t# ne) { |
| 1029 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type >= 0); |
| 1030 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type < GGML_TYPE_COUNT); |
| 1031 | assertcxx . . $ `/usr/include/assert.h:102:11`!(ne % ggml_blck_size(type) == 0); |
| 1032 | return ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(type)*ne/ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(type); |
| 1033 | } |
| 1034 | |
| 1035 | const char * ggml_type_namecxx . . $ ggml_type_name(46969943c907d743).(enum ggml_type type) { |
| 1036 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type >= 0); |
| 1037 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type < GGML_TYPE_COUNT); |
| 1038 | return type_traitscxx . . $ type_traits.[type].type_name; |
| 1039 | } |
| 1040 | |
| 1041 | bool ggml_is_quantizedcxx . . $ ggml_is_quantized(f198bb166f543519).(enum ggml_type type) { |
| 1042 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type >= 0); |
| 1043 | assertcxx . . $ `/usr/include/assert.h:102:11`!(type < GGML_TYPE_COUNT); |
| 1044 | return type_traitscxx . . $ type_traits.[type].is_quantized; |
| 1045 | } |
| 1046 | |
| 1047 | const char * ggml_op_namecxx . . $ ggml_op_name(5dcde7e02b3cf41e).(enum ggml_op op) { |
| 1048 | return GGML_OP_NAMEcxx . . $ GGML_OP_NAME.[op]; |
| 1049 | } |
| 1050 | |
| 1051 | const char * ggml_op_symbolcxx . . $ ggml_op_symbol(5dcde7e02b3cf41e).(enum ggml_op op) { |
| 1052 | return GGML_OP_SYMBOLcxx . . $ GGML_OP_SYMBOL.[op]; |
| 1053 | } |
| 1054 | |
| 1055 | const char * ggml_unary_op_namecxx . . $ ggml_unary_op_name(6193ecfe3adce77e).(enum ggml_unary_op op) { |
| 1056 | return GGML_UNARY_OP_NAMEcxx . . $ GGML_UNARY_OP_NAME.[op]; |
| 1057 | } |
| 1058 | |
| 1059 | const char * ggml_glu_op_namecxx . . $ ggml_glu_op_name(db6d793c36c79333).(enum ggml_glu_op op) { |
| 1060 | return GGML_GLU_OP_NAMEcxx . . $ GGML_GLU_OP_NAME.[op]; |
| 1061 | } |
| 1062 | |
| 1063 | const char * ggml_op_desccxx . . $ ggml_op_desc(6edc679ae4777cf0).(const struct ggml_tensor * t) { |
| 1064 | if (t->op == GGML_OP_UNARY) { |
| 1065 | enum ggml_unary_op uop = ggml_get_unary_op(t); |
| 1066 | return ggml_unary_op_namecxx . . $ ggml_unary_op_name(6193ecfe3adce77e).(uop); |
| 1067 | } |
| 1068 | if (t->op == GGML_OP_GLU) { |
| 1069 | enum ggml_glu_op gop = ggml_get_glu_op(t); |
| 1070 | return ggml_glu_op_namecxx . . $ ggml_glu_op_name(db6d793c36c79333).(gop); |
| 1071 | } |
| 1072 | return ggml_op_namecxx . . $ ggml_op_name(5dcde7e02b3cf41e).(t->op); |
| 1073 | } |
| 1074 | |
| 1075 | size_t ggml_element_sizecxx . . $ ggml_element_size(7f354dd711c66cf7).(const struct ggml_tensor * tensor) { |
| 1076 | return ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(tensor->type); |
| 1077 | } |
| 1078 | |
| 1079 | bool ggml_is_scalarcxx . . $ ggml_is_scalar(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1080 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1081 | |
| 1082 | return tensor->ne[0] == 1 && tensor->ne[1] == 1 && tensor->ne[2] == 1 && tensor->ne[3] == 1; |
| 1083 | } |
| 1084 | |
| 1085 | bool ggml_is_vectorcxx . . $ ggml_is_vector(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1086 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1087 | |
| 1088 | return tensor->ne[1] == 1 && tensor->ne[2] == 1 && tensor->ne[3] == 1; |
| 1089 | } |
| 1090 | |
| 1091 | bool ggml_is_matrixcxx . . $ ggml_is_matrix(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1092 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1093 | |
| 1094 | return tensor->ne[2] == 1 && tensor->ne[3] == 1; |
| 1095 | } |
| 1096 | |
| 1097 | bool ggml_is_3dcxx . . $ ggml_is_3d(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1098 | return tensor->ne[3] == 1; |
| 1099 | } |
| 1100 | |
| 1101 | int ggml_n_dimscxx . . $ ggml_n_dims(620093f67738bec3).(const struct ggml_tensor * tensor) { |
| 1102 | for (int i = GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! - 1; i >= 1; --i) { |
| 1103 | if (tensor->ne[i] > 1) { |
| 1104 | return i + 1; |
| 1105 | } |
| 1106 | } |
| 1107 | return 1; |
| 1108 | } |
| 1109 | |
| 1110 | enum ggml_type ggml_ftype_to_ggml_typecxx . . $ ggml_ftype_to_ggml_type(d6b02358ec310ec6).(enum ggml_ftype ftype) { |
| 1111 | enum ggml_type wtype = GGML_TYPE_COUNT; |
| 1112 | |
| 1113 | switch (ftype) { |
| 1114 | case GGML_FTYPE_ALL_F32: wtype = GGML_TYPE_F32; break; |
| 1115 | case GGML_FTYPE_MOSTLY_F16: wtype = GGML_TYPE_F16; break; |
| 1116 | case GGML_FTYPE_MOSTLY_BF16: wtype = GGML_TYPE_BF16; break; |
| 1117 | case GGML_FTYPE_MOSTLY_Q4_0: wtype = GGML_TYPE_Q4_0; break; |
| 1118 | case GGML_FTYPE_MOSTLY_Q4_1: wtype = GGML_TYPE_Q4_1; break; |
| 1119 | case GGML_FTYPE_MOSTLY_Q5_0: wtype = GGML_TYPE_Q5_0; break; |
| 1120 | case GGML_FTYPE_MOSTLY_Q5_1: wtype = GGML_TYPE_Q5_1; break; |
| 1121 | case GGML_FTYPE_MOSTLY_Q8_0: wtype = GGML_TYPE_Q8_0; break; |
| 1122 | case GGML_FTYPE_MOSTLY_MXFP4: wtype = GGML_TYPE_MXFP4; break; |
| 1123 | case GGML_FTYPE_MOSTLY_Q2_K: wtype = GGML_TYPE_Q2_K; break; |
| 1124 | case GGML_FTYPE_MOSTLY_Q3_K: wtype = GGML_TYPE_Q3_K; break; |
| 1125 | case GGML_FTYPE_MOSTLY_Q4_K: wtype = GGML_TYPE_Q4_K; break; |
| 1126 | case GGML_FTYPE_MOSTLY_Q5_K: wtype = GGML_TYPE_Q5_K; break; |
| 1127 | case GGML_FTYPE_MOSTLY_Q6_K: wtype = GGML_TYPE_Q6_K; break; |
| 1128 | case GGML_FTYPE_MOSTLY_IQ2_XXS: wtype = GGML_TYPE_IQ2_XXS; break; |
| 1129 | case GGML_FTYPE_MOSTLY_IQ2_XS: wtype = GGML_TYPE_IQ2_XS; break; |
| 1130 | case GGML_FTYPE_MOSTLY_IQ3_XXS: wtype = GGML_TYPE_IQ3_XXS; break; |
| 1131 | case GGML_FTYPE_MOSTLY_IQ1_S: wtype = GGML_TYPE_IQ1_S; break; |
| 1132 | case GGML_FTYPE_MOSTLY_IQ1_M: wtype = GGML_TYPE_IQ1_M; break; |
| 1133 | case GGML_FTYPE_MOSTLY_IQ4_NL: wtype = GGML_TYPE_IQ4_NL; break; |
| 1134 | case GGML_FTYPE_MOSTLY_IQ4_XS: wtype = GGML_TYPE_IQ4_XS; break; |
| 1135 | case GGML_FTYPE_MOSTLY_IQ3_S: wtype = GGML_TYPE_IQ3_S; break; |
| 1136 | case GGML_FTYPE_MOSTLY_IQ2_S: wtype = GGML_TYPE_IQ2_S; break; |
| 1137 | case GGML_FTYPE_UNKNOWN: wtype = GGML_TYPE_COUNT; break; |
| 1138 | case GGML_FTYPE_MOSTLY_Q4_1_SOME_F16: wtype = GGML_TYPE_COUNT; break; |
| 1139 | } |
| 1140 | |
| 1141 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(wtype != GGML_TYPE_COUNT); |
| 1142 | |
| 1143 | return wtype; |
| 1144 | } |
| 1145 | |
| 1146 | size_t ggml_tensor_overheadcxx . . $ ggml_tensor_overhead(f708dce9a8856c70).(void) { |
| 1147 | return GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE. + GGML_TENSOR_SIZE; |
| 1148 | } |
| 1149 | |
| 1150 | bool ggml_is_transposedcxx . . $ ggml_is_transposed(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1151 | return tensor->nb[0] > tensor->nb[1]; |
| 1152 | } |
| 1153 | |
| 1154 | static bool ggml_is_contiguous_ncxx . . $ ggml_is_contiguous_n(49cbcb6d415fad33).(const struct ggml_tensor * tensor, int n) { |
| 1155 | size_t next_nb = ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(tensor->type); |
| 1156 | if (tensor->ne[0] != ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(tensor->type) && tensor->nb[0] != next_nb) { |
| 1157 | return false; |
| 1158 | } |
| 1159 | next_nb *= tensor->ne[0]/ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(tensor->type); |
| 1160 | for (int i = 1; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; i++) { |
| 1161 | if (tensor->ne[i] != 1) { |
| 1162 | if (i > n) { |
| 1163 | if (tensor->nb[i] != next_nb) { |
| 1164 | return false; |
| 1165 | } |
| 1166 | next_nb *= tensor->ne[i]; |
| 1167 | } else { |
| 1168 | // this dimension does not need to be contiguous |
| 1169 | next_nb = tensor->ne[i]*tensor->nb[i]; |
| 1170 | } |
| 1171 | } |
| 1172 | } |
| 1173 | return true; |
| 1174 | } |
| 1175 | |
| 1176 | bool ggml_is_contiguouscxx . . $ ggml_is_contiguous(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1177 | return ggml_is_contiguous_0(tensor); |
| 1178 | } |
| 1179 | |
| 1180 | bool ggml_is_contiguous_0cxx . . $ ggml_is_contiguous_0(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1181 | return ggml_is_contiguous_ncxx . . $ ggml_is_contiguous_n(49cbcb6d415fad33).(tensor, 0); |
| 1182 | } |
| 1183 | |
| 1184 | bool ggml_is_contiguous_1cxx . . $ ggml_is_contiguous_1(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1185 | return ggml_is_contiguous_ncxx . . $ ggml_is_contiguous_n(49cbcb6d415fad33).(tensor, 1); |
| 1186 | } |
| 1187 | |
| 1188 | bool ggml_is_contiguous_2cxx . . $ ggml_is_contiguous_2(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1189 | return ggml_is_contiguous_ncxx . . $ ggml_is_contiguous_n(49cbcb6d415fad33).(tensor, 2); |
| 1190 | } |
| 1191 | |
| 1192 | bool ggml_is_contiguously_allocatedcxx . . $ ggml_is_contiguously_allocated(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1193 | return ggml_nbytescxx . . $ ggml_nbytes(7f354dd711c66cf7).(tensor) == ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(tensor) * ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(tensor->type)/ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(tensor->type); |
| 1194 | } |
| 1195 | |
| 1196 | bool ggml_is_permutedcxx . . $ ggml_is_permuted(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1197 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1198 | |
| 1199 | return tensor->nb[0] > tensor->nb[1] || tensor->nb[1] > tensor->nb[2] || tensor->nb[2] > tensor->nb[3]; |
| 1200 | } |
| 1201 | |
| 1202 | bool ggml_is_contiguous_channelscxx . . $ ggml_is_contiguous_channels(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1203 | return |
| 1204 | tensor->nb[0] > tensor->nb[2] && |
| 1205 | tensor->nb[1] > tensor->nb[0] && |
| 1206 | tensor->nb[2] == ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(tensor->type); |
| 1207 | } |
| 1208 | |
| 1209 | bool ggml_is_contiguous_rowscxx . . $ ggml_is_contiguous_rows(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1210 | return |
| 1211 | tensor->ne[0] == ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(tensor->type) || |
| 1212 | tensor->nb[0] == ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(tensor->type); |
| 1213 | } |
| 1214 | |
| 1215 | static inline bool ggml_is_padded_1dcxx . . $ ggml_is_padded_1d(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1216 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1217 | |
| 1218 | return |
| 1219 | tensor->nb[0] == ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(tensor->type) && |
| 1220 | tensor->nb[2] == tensor->nb[1]*tensor->ne[1] && |
| 1221 | tensor->nb[3] == tensor->nb[2]*tensor->ne[2]; |
| 1222 | } |
| 1223 | |
| 1224 | bool ggml_is_emptycxx . . $ ggml_is_empty(8fa73a561a000eab).(const struct ggml_tensor * tensor) { |
| 1225 | for (int i = 0; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; ++i) { |
| 1226 | if (tensor->ne[i] == 0) { |
| 1227 | // empty if any dimension has no elements |
| 1228 | return true; |
| 1229 | } |
| 1230 | } |
| 1231 | return false; |
| 1232 | } |
| 1233 | |
| 1234 | bool ggml_are_same_shapecxx . . $ ggml_are_same_shape(3bd891636d1661b7).(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { |
| 1235 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1236 | |
| 1237 | return |
| 1238 | (t0->ne[0] == t1->ne[0]) && |
| 1239 | (t0->ne[1] == t1->ne[1]) && |
| 1240 | (t0->ne[2] == t1->ne[2]) && |
| 1241 | (t0->ne[3] == t1->ne[3]); |
| 1242 | } |
| 1243 | |
| 1244 | bool ggml_are_same_stridecxx . . $ ggml_are_same_stride(3bd891636d1661b7).(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { |
| 1245 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1246 | |
| 1247 | return |
| 1248 | (t0->nb[0] == t1->nb[0]) && |
| 1249 | (t0->nb[1] == t1->nb[1]) && |
| 1250 | (t0->nb[2] == t1->nb[2]) && |
| 1251 | (t0->nb[3] == t1->nb[3]); |
| 1252 | } |
| 1253 | |
| 1254 | bool ggml_is_viewcxx . . $ ggml_is_view(8fa73a561a000eab).(const struct ggml_tensor * t) { |
| 1255 | return ggml_impl_is_view(t); |
| 1256 | } |
| 1257 | |
| 1258 | // check if t1 can be represented as a repetition of t0 |
| 1259 | bool ggml_can_repeatcxx . . $ ggml_can_repeat(3bd891636d1661b7).(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { |
| 1260 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1261 | |
| 1262 | return ggml_is_emptycxx . . $ ggml_is_empty(8fa73a561a000eab).(t0) ? ggml_is_emptycxx . . $ ggml_is_empty(8fa73a561a000eab).(t1) : |
| 1263 | (t1->ne[0]%t0->ne[0] == 0) && |
| 1264 | (t1->ne[1]%t0->ne[1] == 0) && |
| 1265 | (t1->ne[2]%t0->ne[2] == 0) && |
| 1266 | (t1->ne[3]%t0->ne[3] == 0); |
| 1267 | } |
| 1268 | |
| 1269 | static inline bool ggml_can_repeat_rowscxx . . $ ggml_can_repeat_rows(3bd891636d1661b7).(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { |
| 1270 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 1271 | |
| 1272 | return (t0->ne[0] == t1->ne[0]) && ggml_can_repeatcxx . . $ ggml_can_repeat(3bd891636d1661b7).(t0, t1); |
| 1273 | } |
| 1274 | |
| 1275 | // assert that pointer is aligned to GGML_MEM_ALIGN |
| 1276 | #define GGML_ASSERT_ALIGNEDcxx . . $ `external/whispercpp/ggml.cpp:1276:9`!(ptr) \ |
| 1277 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(((uintptr_t) (ptr))%GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`! == 0) |
| 1278 | |
| 1279 | //////////////////////////////////////////////////////////////////////////////// |
| 1280 | |
| 1281 | struct ggml_contextcxx . . $ ggml_context# * ggml_initcxx . . $ ggml_init(c69185400233f506).(struct ggml_init_params params) { |
| 1282 | static bool is_first_call = true; |
| 1283 | |
| 1284 | ggml_critical_section_start(); |
| 1285 | |
| 1286 | if (is_first_call) { |
| 1287 | // initialize time system (required on Windows) |
| 1288 | ggml_time_initcxx . . $ ggml_time_init(49f6e7a06ebc5aa8).(); |
| 1289 | |
| 1290 | is_first_call = false; |
| 1291 | } |
| 1292 | |
| 1293 | ggml_critical_section_end(); |
| 1294 | |
| 1295 | struct ggml_contextcxx . . $ ggml_context# * ctx = (struct ggml_contextcxx . . $ ggml_context# *) GGML_MALLOCcxx . . $ `external/whispercpp/ggml.cpp:262:9`!(sizeof(struct ggml_context)); |
| 1296 | |
| 1297 | // allow to call ggml_init with 0 size |
| 1298 | if (params.mem_size == 0) { |
| 1299 | params.mem_size = GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!; |
| 1300 | } |
| 1301 | |
| 1302 | const size_t mem_size = params.mem_buffer ? params.mem_size : GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(params.mem_size, GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 1303 | |
| 1304 | *ctx =cxx . . $ ggml_context#`operator=`(613a9650cb01dfaf). (struct ggml_contextcxx . . $ ggml_context#) { |
| 1305 | /*.mem_size =*/ mem_size, |
| 1306 | /*.mem_buffer =*/ params.mem_buffer ? params.mem_buffer : ggml_aligned_malloccxx . . $ ggml_aligned_malloc(bfcfa4d6b7f7ef64).(mem_size), |
| 1307 | /*.mem_buffer_owned =*/ params.mem_buffer ? false : true, |
| 1308 | /*.no_alloc =*/ params.no_alloc, |
| 1309 | /*.n_objects =*/ 0, |
| 1310 | /*.objects_begin =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 1311 | /*.objects_end =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 1312 | }; |
| 1313 | |
| 1314 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ctx->mem_buffer != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 1315 | |
| 1316 | GGML_ASSERT_ALIGNEDcxx . . $ `external/whispercpp/ggml.cpp:1276:9`!(ctx->mem_buffer); |
| 1317 | |
| 1318 | GGML_PRINT_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:128:9`!("%s: context initialized\n", __func__); |
| 1319 | |
| 1320 | return ctx; |
| 1321 | } |
| 1322 | |
| 1323 | void ggml_resetcxx . . $ ggml_reset(5a09f1b59149e1f7).(struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1324 | if (ctx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1325 | return; |
| 1326 | } |
| 1327 | |
| 1328 | ctx->n_objectscxx . . $ ggml_context#n_objects. = 0; |
| 1329 | ctx->objects_begincxx . . $ ggml_context#objects_begin. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1330 | ctx->objects_endcxx . . $ ggml_context#objects_end. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1331 | } |
| 1332 | |
| 1333 | void ggml_freecxx . . $ ggml_free(5a09f1b59149e1f7).(struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1334 | if (ctx == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1335 | return; |
| 1336 | } |
| 1337 | |
| 1338 | if (ctx->mem_buffer_ownedcxx . . $ ggml_context#mem_buffer_owned.) { |
| 1339 | ggml_aligned_freecxx . . $ ggml_aligned_free(3aa184a1f7b8f66e).(ctx->mem_buffercxx . . $ ggml_context#mem_buffer., ctx->mem_sizecxx . . $ ggml_context#mem_size.); |
| 1340 | } |
| 1341 | |
| 1342 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(ctx); |
| 1343 | } |
| 1344 | |
| 1345 | size_t ggml_used_memcxx . . $ ggml_used_mem(cf45f3c2e60f3ae2).(const struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1346 | return ctx->objects_endcxx . . $ ggml_context#objects_end. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? 0 : ctx->objects_endcxx . . $ ggml_context#objects_end.->offscxx . . $ ggml_object#offs. + ctx->objects_endcxx . . $ ggml_context#objects_end.->sizecxx . . $ ggml_object#size.; |
| 1347 | } |
| 1348 | |
| 1349 | bool ggml_get_no_alloccxx . . $ ggml_get_no_alloc(8d9d1870007dc71a).(struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1350 | return ctx->no_alloccxx . . $ ggml_context#no_alloc.; |
| 1351 | } |
| 1352 | |
| 1353 | void ggml_set_no_alloccxx . . $ ggml_set_no_alloc(4ad088854917e8d5).(struct ggml_contextcxx . . $ ggml_context# * ctx, bool no_alloc) { |
| 1354 | ctx->no_alloccxx . . $ ggml_context#no_alloc. = no_alloc; |
| 1355 | } |
| 1356 | |
| 1357 | void * ggml_get_mem_buffercxx . . $ ggml_get_mem_buffer(38188ff5ee8544ae).(const struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1358 | return ctx->mem_buffercxx . . $ ggml_context#mem_buffer.; |
| 1359 | } |
| 1360 | |
| 1361 | size_t ggml_get_mem_sizecxx . . $ ggml_get_mem_size(cf45f3c2e60f3ae2).(const struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1362 | return ctx->mem_sizecxx . . $ ggml_context#mem_size.; |
| 1363 | } |
| 1364 | |
| 1365 | size_t ggml_get_max_tensor_sizecxx . . $ ggml_get_max_tensor_size(cf45f3c2e60f3ae2).(const struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1366 | size_t max_size = 0; |
| 1367 | |
| 1368 | for (struct ggml_tensor * tensor = ggml_get_first_tensor(ctx); tensor != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; tensor = ggml_get_next_tensor(ctx, tensor)) { |
| 1369 | size_t bytes = ggml_nbytescxx . . $ ggml_nbytes(7f354dd711c66cf7).(tensor); |
| 1370 | max_size = MAXcxx . . $ `external/whispercpp/ggml-impl.h:38:13`!(max_size, bytes); |
| 1371 | } |
| 1372 | |
| 1373 | return max_size; |
| 1374 | } |
| 1375 | |
| 1376 | //////////////////////////////////////////////////////////////////////////////// |
| 1377 | |
| 1378 | static struct ggml_objectcxx . . $ ggml_object# * ggml_new_objectcxx . . $ ggml_new_object(bf5a29193a5c97c).(struct ggml_contextcxx . . $ ggml_context# * ctx, enum ggml_object_type type, size_t size) { |
| 1379 | // always insert objects at the end of the context's memory pool |
| 1380 | struct ggml_objectcxx . . $ ggml_object# * obj_cur = ctx->objects_endcxx . . $ ggml_context#objects_end.; |
| 1381 | |
| 1382 | const size_t cur_offs = obj_cur == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? 0 : obj_cur->offscxx . . $ ggml_object#offs.; |
| 1383 | const size_t cur_size = obj_cur == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? 0 : obj_cur->sizecxx . . $ ggml_object#size.; |
| 1384 | const size_t cur_end = cur_offs + cur_size; |
| 1385 | |
| 1386 | // align to GGML_MEM_ALIGN |
| 1387 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(size <= SIZE_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:216:11`! - (GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`! - 1)); |
| 1388 | size_t size_needed = GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(size, GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 1389 | |
| 1390 | char * const mem_buffer = (char *) ctx->mem_buffercxx . . $ ggml_context#mem_buffer.; |
| 1391 | struct ggml_objectcxx . . $ ggml_object# * const obj_new = (struct ggml_objectcxx . . $ ggml_object# *)(mem_buffer + cur_end); |
| 1392 | |
| 1393 | // integer overflow checks |
| 1394 | if (cur_end > SIZE_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:216:11`! - size_needed) { |
| 1395 | GGML_LOG_WARNcxx . . $ `external/whispercpp/ggml-impl.h:118:9`!("%s: overflow detected in cur_end (%zu) + size_needed (%zu)\n", __func__, cur_end, size_needed); |
| 1396 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1397 | } |
| 1398 | if (cur_end + size_needed > SIZE_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:216:11`! - GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE.) { |
| 1399 | GGML_LOG_WARNcxx . . $ `external/whispercpp/ggml-impl.h:118:9`!("%s: overflow detected in cur_end (%zu) + size_needed (%zu) + GGML_OBJECT_SIZE (%zu)\n", __func__, |
| 1400 | cur_end, size_needed, (size_t) GGML_OBJECT_SIZE); |
| 1401 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1402 | } |
| 1403 | |
| 1404 | if (cur_end + size_needed + GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE. > ctx->mem_sizecxx . . $ ggml_context#mem_size.) { |
| 1405 | GGML_LOG_WARNcxx . . $ `external/whispercpp/ggml-impl.h:118:9`!("%s: not enough space in the context's memory pool (needed %zu, available %zu)\n", |
| 1406 | __func__, cur_end + size_needed + GGML_OBJECT_SIZE, ctx->mem_size); |
| 1407 | #ifndef NDEBUG |
| 1408 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("not enough space in the context's memory pool"); |
| 1409 | #endif |
| 1410 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1411 | } |
| 1412 | |
| 1413 | *obj_new =cxx . . $ ggml_object#`operator=`(1192badbc025eb60). (struct ggml_objectcxx . . $ ggml_object#) { |
| 1414 | .offs = cur_end + GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE., |
| 1415 | .size = size_needed, |
| 1416 | .next = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 1417 | .type = type, |
| 1418 | }; |
| 1419 | |
| 1420 | GGML_ASSERT_ALIGNEDcxx . . $ `external/whispercpp/ggml.cpp:1276:9`!(mem_buffer + obj_new->offs); |
| 1421 | |
| 1422 | if (obj_cur != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1423 | obj_cur->nextcxx . . $ ggml_object#next. = obj_new; |
| 1424 | } else { |
| 1425 | // this is the first object in this context |
| 1426 | ctx->objects_begincxx . . $ ggml_context#objects_begin. = obj_new; |
| 1427 | } |
| 1428 | |
| 1429 | ctx->objects_endcxx . . $ ggml_context#objects_end. = obj_new; |
| 1430 | |
| 1431 | //printf("%s: inserted new object at %zu, size = %zu\n", __func__, cur_end, obj_new->size); |
| 1432 | |
| 1433 | return obj_new; |
| 1434 | } |
| 1435 | |
| 1436 | static struct ggml_tensor * ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).( |
| 1437 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1438 | enum ggml_type type, |
| 1439 | int n_dims, |
| 1440 | const int64_tcxx . . $ int64_t# * ne, |
| 1441 | struct ggml_tensor * view_src, |
| 1442 | size_t view_offs) { |
| 1443 | |
| 1444 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(type >= 0 && type < GGML_TYPE_COUNT); |
| 1445 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_dims >= 1 && n_dims <= GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!); |
| 1446 | |
| 1447 | // find the base tensor and absolute offset |
| 1448 | if (view_src != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && view_src->view_src != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1449 | view_offs += view_src->view_offs; |
| 1450 | view_src = view_src->view_src; |
| 1451 | } |
| 1452 | |
| 1453 | size_t data_size = ggml_row_sizecxx . . $ ggml_row_size(cd72edd651ca704e).(type, ne[0]); |
| 1454 | for (int i = 1; i < n_dims; i++) { |
| 1455 | data_size *= ne[i]; |
| 1456 | } |
| 1457 | |
| 1458 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(view_src == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! || data_size == 0 || data_size + view_offs <= ggml_nbytes(view_src)); |
| 1459 | |
| 1460 | void * data = view_src != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ? view_src->data : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1461 | if (data != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1462 | data = (char *) data + view_offs; |
| 1463 | } |
| 1464 | |
| 1465 | size_t obj_alloc_size = 0; |
| 1466 | |
| 1467 | if (view_src == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && !ctx->no_alloccxx . . $ ggml_context#no_alloc.) { |
| 1468 | // allocate tensor data in the context's memory pool |
| 1469 | obj_alloc_size = data_size; |
| 1470 | } |
| 1471 | |
| 1472 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(GGML_TENSOR_SIZE <= SIZE_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:216:11`! - obj_alloc_size); |
| 1473 | |
| 1474 | struct ggml_objectcxx . . $ ggml_object# * const obj_new = ggml_new_objectcxx . . $ ggml_new_object(bf5a29193a5c97c).(ctx, GGML_OBJECT_TYPE_TENSOR, GGML_TENSOR_SIZE + obj_alloc_size); |
| 1475 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(obj_new); |
| 1476 | |
| 1477 | struct ggml_tensor * const result = (struct ggml_tensor *)((char *)ctx->mem_buffercxx . . $ ggml_context#mem_buffer. + obj_new->offscxx . . $ ggml_object#offs.); |
| 1478 | |
| 1479 | *result = (struct ggml_tensor) { |
| 1480 | /*.type =*/ type, |
| 1481 | /*.buffer =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 1482 | /*.ne =*/ { 1, 1, 1, 1 }, |
| 1483 | /*.nb =*/ { 0, 0, 0, 0 }, |
| 1484 | /*.op =*/ GGML_OP_NONE, |
| 1485 | /*.op_params =*/ { 0 }, |
| 1486 | /*.flags =*/ 0, |
| 1487 | /*.src =*/ { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! }, |
| 1488 | /*.view_src =*/ view_src, |
| 1489 | /*.view_offs =*/ view_offs, |
| 1490 | /*.data =*/ obj_alloc_size > 0 ? (void *)(result + 1) : data, |
| 1491 | /*.name =*/ { 0 }, |
| 1492 | /*.extra =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 1493 | /*.padding =*/ { 0 }, |
| 1494 | }; |
| 1495 | |
| 1496 | // TODO: this should not be needed as long as we don't rely on aligned SIMD loads |
| 1497 | //GGML_ASSERT_ALIGNED(result->data); |
| 1498 | |
| 1499 | for (int i = 0; i < n_dims; i++) { |
| 1500 | result->ne[i] = ne[i]; |
| 1501 | } |
| 1502 | |
| 1503 | result->nb[0] = ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(type); |
| 1504 | result->nb[1] = result->nb[0]*(result->ne[0]/ggml_blck_sizecxx . . $ ggml_blck_size(942dd68820303f67).(type)); |
| 1505 | for (int i = 2; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; i++) { |
| 1506 | result->nb[i] = result->nb[i - 1]*result->ne[i - 1]; |
| 1507 | } |
| 1508 | |
| 1509 | ctx->n_objectscxx . . $ ggml_context#n_objects.++; |
| 1510 | |
| 1511 | return result; |
| 1512 | } |
| 1513 | |
| 1514 | struct ggml_tensor * ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).( |
| 1515 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1516 | enum ggml_type type, |
| 1517 | int n_dims, |
| 1518 | const int64_tcxx . . $ int64_t# * ne) { |
| 1519 | return ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, type, n_dims, ne, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0); |
| 1520 | } |
| 1521 | |
| 1522 | struct ggml_tensor * ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).( |
| 1523 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1524 | enum ggml_type type, |
| 1525 | int64_tcxx . . $ int64_t# ne0) { |
| 1526 | return ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, type, 1, &ne0); |
| 1527 | } |
| 1528 | |
| 1529 | struct ggml_tensor * ggml_new_tensor_2dcxx . . $ ggml_new_tensor_2d(7610aad4b808d570).( |
| 1530 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1531 | enum ggml_type type, |
| 1532 | int64_tcxx . . $ int64_t# ne0, |
| 1533 | int64_tcxx . . $ int64_t# ne1) { |
| 1534 | const int64_tcxx . . $ int64_t# ne[2] = { ne0, ne1 }; |
| 1535 | return ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, type, 2, ne); |
| 1536 | } |
| 1537 | |
| 1538 | struct ggml_tensor * ggml_new_tensor_3dcxx . . $ ggml_new_tensor_3d(14b991d064ecb53f).( |
| 1539 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1540 | enum ggml_type type, |
| 1541 | int64_tcxx . . $ int64_t# ne0, |
| 1542 | int64_tcxx . . $ int64_t# ne1, |
| 1543 | int64_tcxx . . $ int64_t# ne2) { |
| 1544 | const int64_tcxx . . $ int64_t# ne[3] = { ne0, ne1, ne2 }; |
| 1545 | return ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, type, 3, ne); |
| 1546 | } |
| 1547 | |
| 1548 | struct ggml_tensor * ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).( |
| 1549 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1550 | enum ggml_type type, |
| 1551 | int64_tcxx . . $ int64_t# ne0, |
| 1552 | int64_tcxx . . $ int64_t# ne1, |
| 1553 | int64_tcxx . . $ int64_t# ne2, |
| 1554 | int64_tcxx . . $ int64_t# ne3) { |
| 1555 | const int64_tcxx . . $ int64_t# ne[4] = { ne0, ne1, ne2, ne3 }; |
| 1556 | return ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, type, 4, ne); |
| 1557 | } |
| 1558 | |
| 1559 | void * ggml_new_buffercxx . . $ ggml_new_buffer(aa8fcea6b86d81b1).(struct ggml_contextcxx . . $ ggml_context# * ctx, size_t nbytes) { |
| 1560 | struct ggml_objectcxx . . $ ggml_object# * obj = ggml_new_objectcxx . . $ ggml_new_object(bf5a29193a5c97c).(ctx, GGML_OBJECT_TYPE_WORK_BUFFER, nbytes); |
| 1561 | |
| 1562 | return (uint8_tcxx . . $ uint8_t# *)ctx->mem_buffercxx . . $ ggml_context#mem_buffer. + obj->offscxx . . $ ggml_object#offs.; |
| 1563 | } |
| 1564 | |
| 1565 | struct ggml_tensor * ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(struct ggml_contextcxx . . $ ggml_context# * ctx, const struct ggml_tensor * src) { |
| 1566 | return ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, src->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, src->ne); |
| 1567 | } |
| 1568 | |
| 1569 | void ggml_unravel_indexcxx . . $ ggml_unravel_index(806b76e8379b8e0c).(const struct ggml_tensor * tensor, int64_tcxx . . $ int64_t# i, int64_tcxx . . $ int64_t# * i0, int64_tcxx . . $ int64_t# * i1, int64_tcxx . . $ int64_t# * i2, int64_tcxx . . $ int64_t# * i3) { |
| 1570 | const int64_tcxx . . $ int64_t# ne2 = tensor->ne[2]; |
| 1571 | const int64_tcxx . . $ int64_t# ne1 = tensor->ne[1]; |
| 1572 | const int64_tcxx . . $ int64_t# ne0 = tensor->ne[0]; |
| 1573 | |
| 1574 | const int64_tcxx . . $ int64_t# i3_ = (i/(ne2*ne1*ne0)); |
| 1575 | const int64_tcxx . . $ int64_t# i2_ = (i - i3_*ne2*ne1*ne0)/(ne1*ne0); |
| 1576 | const int64_tcxx . . $ int64_t# i1_ = (i - i3_*ne2*ne1*ne0 - i2_*ne1*ne0)/ne0; |
| 1577 | const int64_tcxx . . $ int64_t# i0_ = (i - i3_*ne2*ne1*ne0 - i2_*ne1*ne0 - i1_*ne0); |
| 1578 | |
| 1579 | if (i0) { |
| 1580 | * i0 = i0_; |
| 1581 | } |
| 1582 | if (i1) { |
| 1583 | * i1 = i1_; |
| 1584 | } |
| 1585 | if (i2) { |
| 1586 | * i2 = i2_; |
| 1587 | } |
| 1588 | if (i3) { |
| 1589 | * i3 = i3_; |
| 1590 | } |
| 1591 | } |
| 1592 | |
| 1593 | void * ggml_get_datacxx . . $ ggml_get_data(e138a982a3905cfa).(const struct ggml_tensor * tensor) { |
| 1594 | return tensor->data; |
| 1595 | } |
| 1596 | |
| 1597 | float * ggml_get_data_f32cxx . . $ ggml_get_data_f32(70383c885c5413d4).(const struct ggml_tensor * tensor) { |
| 1598 | assertcxx . . $ `/usr/include/assert.h:102:11`!(tensor->type == GGML_TYPE_F32); |
| 1599 | return (float *)(tensor->data); |
| 1600 | } |
| 1601 | |
| 1602 | enum ggml_unary_op ggml_get_unary_opcxx . . $ ggml_get_unary_op(cb5a4dbbb5018590).(const struct ggml_tensor * tensor) { |
| 1603 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tensor->op == GGML_OP_UNARY); |
| 1604 | return (enum ggml_unary_op) ggml_get_op_params_i32(tensor, 0); |
| 1605 | } |
| 1606 | |
| 1607 | enum ggml_glu_op ggml_get_glu_opcxx . . $ ggml_get_glu_op(cad6722f31ecc9b4).(const struct ggml_tensor * tensor) { |
| 1608 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tensor->op == GGML_OP_GLU); |
| 1609 | return (enum ggml_glu_op) ggml_get_op_params_i32(tensor, 0); |
| 1610 | } |
| 1611 | |
| 1612 | const char * ggml_get_namecxx . . $ ggml_get_name(6edc679ae4777cf0).(const struct ggml_tensor * tensor) { |
| 1613 | return tensor->name; |
| 1614 | } |
| 1615 | |
| 1616 | struct ggml_tensor * ggml_set_namecxx . . $ ggml_set_name(f4d15c887765c568).(struct ggml_tensor * tensor, const char * name) { |
| 1617 | size_t i; |
| 1618 | for (i = 0; i < sizeof(tensor->name) - 1 && name[i] != '\0'; i++) { |
| 1619 | tensor->name[i] = name[i]; |
| 1620 | } |
| 1621 | tensor->name[i] = '\0'; |
| 1622 | return tensor; |
| 1623 | } |
| 1624 | |
| 1625 | struct ggml_tensor * ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(struct ggml_tensor * tensor, const char * fmt, ...) { |
| 1626 | va_list args; |
| 1627 | va_startcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:50:9`!(args, fmt); |
| 1628 | vsnprintf(tensor->name, sizeof(tensor->name), fmt, args); |
| 1629 | va_endcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stdarg.h:52:9`!(args); |
| 1630 | return tensor; |
| 1631 | } |
| 1632 | |
| 1633 | struct ggml_tensor * ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).( |
| 1634 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1635 | struct ggml_tensor * src) { |
| 1636 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, src->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, src->ne, src, 0); |
| 1637 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (view)", src->name); |
| 1638 | |
| 1639 | for (int i = 0; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; i++) { |
| 1640 | result->nb[i] = src->nb[i]; |
| 1641 | } |
| 1642 | |
| 1643 | return result; |
| 1644 | } |
| 1645 | |
| 1646 | struct ggml_tensor * ggml_get_first_tensorcxx . . $ ggml_get_first_tensor(bf404b116a4d22d1).(const struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 1647 | struct ggml_objectcxx . . $ ggml_object# * obj = ctx->objects_begincxx . . $ ggml_context#objects_begin.; |
| 1648 | |
| 1649 | char * const mem_buffer = (char *) ctx->mem_buffercxx . . $ ggml_context#mem_buffer.; |
| 1650 | |
| 1651 | while (obj != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1652 | if (obj->typecxx . . $ ggml_object#type. == GGML_OBJECT_TYPE_TENSOR) { |
| 1653 | return (struct ggml_tensor *)(mem_buffer + obj->offscxx . . $ ggml_object#offs.); |
| 1654 | } |
| 1655 | |
| 1656 | obj = obj->nextcxx . . $ ggml_object#next.; |
| 1657 | } |
| 1658 | |
| 1659 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1660 | } |
| 1661 | |
| 1662 | struct ggml_tensor * ggml_get_next_tensorcxx . . $ ggml_get_next_tensor(7ca6a4da0169f19f).(const struct ggml_contextcxx . . $ ggml_context# * ctx, struct ggml_tensor * tensor) { |
| 1663 | struct ggml_objectcxx . . $ ggml_object# * obj = (struct ggml_objectcxx . . $ ggml_object# *) ((char *)tensor - GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE.); |
| 1664 | obj = obj->nextcxx . . $ ggml_object#next.; |
| 1665 | |
| 1666 | char * const mem_buffer = (char *) ctx->mem_buffercxx . . $ ggml_context#mem_buffer.; |
| 1667 | |
| 1668 | while (obj != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1669 | if (obj->typecxx . . $ ggml_object#type. == GGML_OBJECT_TYPE_TENSOR) { |
| 1670 | return (struct ggml_tensor *)(mem_buffer + obj->offscxx . . $ ggml_object#offs.); |
| 1671 | } |
| 1672 | |
| 1673 | obj = obj->nextcxx . . $ ggml_object#next.; |
| 1674 | } |
| 1675 | |
| 1676 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1677 | } |
| 1678 | |
| 1679 | struct ggml_tensor * ggml_get_tensorcxx . . $ ggml_get_tensor(298fc1951661aadf).(struct ggml_contextcxx . . $ ggml_context# * ctx, const char * name) { |
| 1680 | struct ggml_objectcxx . . $ ggml_object# * obj = ctx->objects_begincxx . . $ ggml_context#objects_begin.; |
| 1681 | |
| 1682 | char * const mem_buffer = (char *) ctx->mem_buffercxx . . $ ggml_context#mem_buffer.; |
| 1683 | |
| 1684 | while (obj != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 1685 | if (obj->typecxx . . $ ggml_object#type. == GGML_OBJECT_TYPE_TENSOR) { |
| 1686 | struct ggml_tensor * cur = (struct ggml_tensor *)(mem_buffer + obj->offscxx . . $ ggml_object#offs.); |
| 1687 | if (strcmp(cur->name, name) == 0) { |
| 1688 | return cur; |
| 1689 | } |
| 1690 | } |
| 1691 | |
| 1692 | obj = obj->nextcxx . . $ ggml_object#next.; |
| 1693 | } |
| 1694 | |
| 1695 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 1696 | } |
| 1697 | |
| 1698 | //////////////////////////////////////////////////////////////////////////////// |
| 1699 | |
| 1700 | // ggml_dup |
| 1701 | |
| 1702 | static struct ggml_tensor * ggml_dup_implcxx . . $ ggml_dup_impl(cb9053aa8fa7848).( |
| 1703 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1704 | struct ggml_tensor * a, |
| 1705 | bool inplace) { |
| 1706 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1707 | |
| 1708 | result->op = GGML_OP_DUP; |
| 1709 | result->src[0] = a; |
| 1710 | |
| 1711 | return result; |
| 1712 | } |
| 1713 | |
| 1714 | struct ggml_tensor * ggml_dupcxx . . $ ggml_dup(71a7fa2ddee25242).( |
| 1715 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1716 | struct ggml_tensor * a) { |
| 1717 | return ggml_dup_implcxx . . $ ggml_dup_impl(cb9053aa8fa7848).(ctx, a, false); |
| 1718 | } |
| 1719 | |
| 1720 | struct ggml_tensor * ggml_dup_inplacecxx . . $ ggml_dup_inplace(71a7fa2ddee25242).( |
| 1721 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1722 | struct ggml_tensor * a) { |
| 1723 | return ggml_dup_implcxx . . $ ggml_dup_impl(cb9053aa8fa7848).(ctx, a, true); |
| 1724 | } |
| 1725 | |
| 1726 | // ggml_add |
| 1727 | |
| 1728 | static struct ggml_tensor * ggml_add_implcxx . . $ ggml_add_impl(68ee738007d49a26).( |
| 1729 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1730 | struct ggml_tensor * a, |
| 1731 | struct ggml_tensor * b, |
| 1732 | bool inplace) { |
| 1733 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat(b, a)); |
| 1734 | |
| 1735 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1736 | |
| 1737 | result->op = GGML_OP_ADD; |
| 1738 | result->src[0] = a; |
| 1739 | result->src[1] = b; |
| 1740 | |
| 1741 | return result; |
| 1742 | } |
| 1743 | |
| 1744 | struct ggml_tensor * ggml_addcxx . . $ ggml_add(590e8193bb8aebeb).( |
| 1745 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1746 | struct ggml_tensor * a, |
| 1747 | struct ggml_tensor * b) { |
| 1748 | return ggml_add_implcxx . . $ ggml_add_impl(68ee738007d49a26).(ctx, a, b, false); |
| 1749 | } |
| 1750 | |
| 1751 | struct ggml_tensor * ggml_add_inplacecxx . . $ ggml_add_inplace(590e8193bb8aebeb).( |
| 1752 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1753 | struct ggml_tensor * a, |
| 1754 | struct ggml_tensor * b) { |
| 1755 | return ggml_add_implcxx . . $ ggml_add_impl(68ee738007d49a26).(ctx, a, b, true); |
| 1756 | } |
| 1757 | |
| 1758 | // ggml_add_cast |
| 1759 | |
| 1760 | static struct ggml_tensor * ggml_add_cast_implcxx . . $ ggml_add_cast_impl(1aaf54b503783154).( |
| 1761 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1762 | struct ggml_tensor * a, |
| 1763 | struct ggml_tensor * b, |
| 1764 | enum ggml_type type) { |
| 1765 | // TODO: support less-strict constraint |
| 1766 | // GGML_ASSERT(ggml_can_repeat(b, a)); |
| 1767 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat_rows(b, a)); |
| 1768 | |
| 1769 | // currently only supported for quantized input and f16 |
| 1770 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_quantized(a->type) || |
| 1771 | a->type == GGML_TYPE_F16 || |
| 1772 | a->type == GGML_TYPE_BF16); |
| 1773 | |
| 1774 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, a->ne); |
| 1775 | |
| 1776 | result->op = GGML_OP_ADD; |
| 1777 | result->src[0] = a; |
| 1778 | result->src[1] = b; |
| 1779 | |
| 1780 | return result; |
| 1781 | } |
| 1782 | |
| 1783 | struct ggml_tensor * ggml_add_castcxx . . $ ggml_add_cast(1aaf54b503783154).( |
| 1784 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1785 | struct ggml_tensor * a, |
| 1786 | struct ggml_tensor * b, |
| 1787 | enum ggml_type type) { |
| 1788 | return ggml_add_cast_implcxx . . $ ggml_add_cast_impl(1aaf54b503783154).(ctx, a, b, type); |
| 1789 | } |
| 1790 | |
| 1791 | struct ggml_tensor * ggml_add_idcxx . . $ ggml_add_id(28fd2ad14bf2989).( |
| 1792 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1793 | struct ggml_tensor * a, |
| 1794 | struct ggml_tensor * b, |
| 1795 | struct ggml_tensor * ids) { |
| 1796 | |
| 1797 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] == b->ne[0]); |
| 1798 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[1] == ids->ne[0]); |
| 1799 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == ids->ne[1]); |
| 1800 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->type == GGML_TYPE_I32); |
| 1801 | |
| 1802 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1803 | |
| 1804 | result->op = GGML_OP_ADD_ID; |
| 1805 | result->src[0] = a; |
| 1806 | result->src[1] = b; |
| 1807 | result->src[2] = ids; |
| 1808 | |
| 1809 | return result; |
| 1810 | } |
| 1811 | |
| 1812 | // ggml_add1 |
| 1813 | |
| 1814 | static struct ggml_tensor * ggml_add1_implcxx . . $ ggml_add1_impl(68ee738007d49a26).( |
| 1815 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1816 | struct ggml_tensor * a, |
| 1817 | struct ggml_tensor * b, |
| 1818 | bool inplace) { |
| 1819 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_scalar(b)); |
| 1820 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_padded_1d(a)); |
| 1821 | |
| 1822 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1823 | |
| 1824 | result->op = GGML_OP_ADD1; |
| 1825 | result->src[0] = a; |
| 1826 | result->src[1] = b; |
| 1827 | |
| 1828 | return result; |
| 1829 | } |
| 1830 | |
| 1831 | struct ggml_tensor * ggml_add1cxx . . $ ggml_add1(590e8193bb8aebeb).( |
| 1832 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1833 | struct ggml_tensor * a, |
| 1834 | struct ggml_tensor * b) { |
| 1835 | return ggml_add1_implcxx . . $ ggml_add1_impl(68ee738007d49a26).(ctx, a, b, false); |
| 1836 | } |
| 1837 | |
| 1838 | struct ggml_tensor * ggml_add1_inplacecxx . . $ ggml_add1_inplace(590e8193bb8aebeb).( |
| 1839 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1840 | struct ggml_tensor * a, |
| 1841 | struct ggml_tensor * b) { |
| 1842 | return ggml_add1_implcxx . . $ ggml_add1_impl(68ee738007d49a26).(ctx, a, b, true); |
| 1843 | } |
| 1844 | |
| 1845 | // ggml_acc |
| 1846 | |
| 1847 | static struct ggml_tensor * ggml_acc_implcxx . . $ ggml_acc_impl(5043d0b8ee1f0fa6).( |
| 1848 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1849 | struct ggml_tensor * a, |
| 1850 | struct ggml_tensor * b, |
| 1851 | size_t nb1, |
| 1852 | size_t nb2, |
| 1853 | size_t nb3, |
| 1854 | size_t offset, |
| 1855 | bool inplace) { |
| 1856 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(b) <= ggml_nelements(a)); |
| 1857 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 1858 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 1859 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->type == GGML_TYPE_F32); |
| 1860 | |
| 1861 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1862 | |
| 1863 | int32_tcxx . . $ int32_t# params[] = { (int32_tcxx . . $ int32_t#) nb1, (int32_tcxx . . $ int32_t#) nb2, (int32_tcxx . . $ int32_t#) nb3, (int32_tcxx . . $ int32_t#) offset, inplace ? 1 : 0 }; |
| 1864 | ggml_set_op_params(result, params, sizeof(params)); |
| 1865 | |
| 1866 | result->op = GGML_OP_ACC; |
| 1867 | result->src[0] = a; |
| 1868 | result->src[1] = b; |
| 1869 | |
| 1870 | return result; |
| 1871 | } |
| 1872 | |
| 1873 | struct ggml_tensor * ggml_acccxx . . $ ggml_acc(29a548f2e4e55123).( |
| 1874 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1875 | struct ggml_tensor * a, |
| 1876 | struct ggml_tensor * b, |
| 1877 | size_t nb1, |
| 1878 | size_t nb2, |
| 1879 | size_t nb3, |
| 1880 | size_t offset) { |
| 1881 | return ggml_acc_implcxx . . $ ggml_acc_impl(5043d0b8ee1f0fa6).(ctx, a, b, nb1, nb2, nb3, offset, false); |
| 1882 | } |
| 1883 | |
| 1884 | struct ggml_tensor * ggml_acc_inplacecxx . . $ ggml_acc_inplace(29a548f2e4e55123).( |
| 1885 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1886 | struct ggml_tensor * a, |
| 1887 | struct ggml_tensor * b, |
| 1888 | size_t nb1, |
| 1889 | size_t nb2, |
| 1890 | size_t nb3, |
| 1891 | size_t offset) { |
| 1892 | return ggml_acc_implcxx . . $ ggml_acc_impl(5043d0b8ee1f0fa6).(ctx, a, b, nb1, nb2, nb3, offset, true); |
| 1893 | } |
| 1894 | |
| 1895 | // ggml_sub |
| 1896 | |
| 1897 | static struct ggml_tensor * ggml_sub_implcxx . . $ ggml_sub_impl(68ee738007d49a26).( |
| 1898 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1899 | struct ggml_tensor * a, |
| 1900 | struct ggml_tensor * b, |
| 1901 | bool inplace) { |
| 1902 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat(b, a)); |
| 1903 | |
| 1904 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1905 | |
| 1906 | result->op = GGML_OP_SUB; |
| 1907 | result->src[0] = a; |
| 1908 | result->src[1] = b; |
| 1909 | |
| 1910 | return result; |
| 1911 | } |
| 1912 | |
| 1913 | struct ggml_tensor * ggml_subcxx . . $ ggml_sub(590e8193bb8aebeb).( |
| 1914 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1915 | struct ggml_tensor * a, |
| 1916 | struct ggml_tensor * b) { |
| 1917 | return ggml_sub_implcxx . . $ ggml_sub_impl(68ee738007d49a26).(ctx, a, b, false); |
| 1918 | } |
| 1919 | |
| 1920 | struct ggml_tensor * ggml_sub_inplacecxx . . $ ggml_sub_inplace(590e8193bb8aebeb).( |
| 1921 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1922 | struct ggml_tensor * a, |
| 1923 | struct ggml_tensor * b) { |
| 1924 | return ggml_sub_implcxx . . $ ggml_sub_impl(68ee738007d49a26).(ctx, a, b, true); |
| 1925 | } |
| 1926 | |
| 1927 | // ggml_mul |
| 1928 | |
| 1929 | static struct ggml_tensor * ggml_mul_implcxx . . $ ggml_mul_impl(68ee738007d49a26).( |
| 1930 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1931 | struct ggml_tensor * a, |
| 1932 | struct ggml_tensor * b, |
| 1933 | bool inplace) { |
| 1934 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat(b, a)); |
| 1935 | |
| 1936 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1937 | |
| 1938 | result->op = GGML_OP_MUL; |
| 1939 | result->src[0] = a; |
| 1940 | result->src[1] = b; |
| 1941 | |
| 1942 | return result; |
| 1943 | } |
| 1944 | |
| 1945 | struct ggml_tensor * ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).( |
| 1946 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1947 | struct ggml_tensor * a, |
| 1948 | struct ggml_tensor * b) { |
| 1949 | return ggml_mul_implcxx . . $ ggml_mul_impl(68ee738007d49a26).(ctx, a, b, false); |
| 1950 | } |
| 1951 | |
| 1952 | struct ggml_tensor * ggml_mul_inplacecxx . . $ ggml_mul_inplace(590e8193bb8aebeb).( |
| 1953 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1954 | struct ggml_tensor * a, |
| 1955 | struct ggml_tensor * b) { |
| 1956 | return ggml_mul_implcxx . . $ ggml_mul_impl(68ee738007d49a26).(ctx, a, b, true); |
| 1957 | } |
| 1958 | |
| 1959 | // ggml_div |
| 1960 | |
| 1961 | static struct ggml_tensor * ggml_div_implcxx . . $ ggml_div_impl(68ee738007d49a26).( |
| 1962 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1963 | struct ggml_tensor * a, |
| 1964 | struct ggml_tensor * b, |
| 1965 | bool inplace) { |
| 1966 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat(b, a)); |
| 1967 | |
| 1968 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1969 | |
| 1970 | result->op = GGML_OP_DIV; |
| 1971 | result->src[0] = a; |
| 1972 | result->src[1] = b; |
| 1973 | |
| 1974 | return result; |
| 1975 | } |
| 1976 | |
| 1977 | struct ggml_tensor * ggml_divcxx . . $ ggml_div(590e8193bb8aebeb).( |
| 1978 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1979 | struct ggml_tensor * a, |
| 1980 | struct ggml_tensor * b) { |
| 1981 | return ggml_div_implcxx . . $ ggml_div_impl(68ee738007d49a26).(ctx, a, b, false); |
| 1982 | } |
| 1983 | |
| 1984 | struct ggml_tensor * ggml_div_inplacecxx . . $ ggml_div_inplace(590e8193bb8aebeb).( |
| 1985 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1986 | struct ggml_tensor * a, |
| 1987 | struct ggml_tensor * b) { |
| 1988 | return ggml_div_implcxx . . $ ggml_div_impl(68ee738007d49a26).(ctx, a, b, true); |
| 1989 | } |
| 1990 | |
| 1991 | // ggml_sqr |
| 1992 | |
| 1993 | static struct ggml_tensor * ggml_sqr_implcxx . . $ ggml_sqr_impl(cb9053aa8fa7848).( |
| 1994 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 1995 | struct ggml_tensor * a, |
| 1996 | bool inplace) { |
| 1997 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 1998 | |
| 1999 | result->op = GGML_OP_SQR; |
| 2000 | result->src[0] = a; |
| 2001 | |
| 2002 | return result; |
| 2003 | } |
| 2004 | |
| 2005 | struct ggml_tensor * ggml_sqrcxx . . $ ggml_sqr(71a7fa2ddee25242).( |
| 2006 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2007 | struct ggml_tensor * a) { |
| 2008 | return ggml_sqr_implcxx . . $ ggml_sqr_impl(cb9053aa8fa7848).(ctx, a, false); |
| 2009 | } |
| 2010 | |
| 2011 | struct ggml_tensor * ggml_sqr_inplacecxx . . $ ggml_sqr_inplace(71a7fa2ddee25242).( |
| 2012 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2013 | struct ggml_tensor * a) { |
| 2014 | return ggml_sqr_implcxx . . $ ggml_sqr_impl(cb9053aa8fa7848).(ctx, a, true); |
| 2015 | } |
| 2016 | |
| 2017 | // ggml_sqrt |
| 2018 | |
| 2019 | static struct ggml_tensor * ggml_sqrt_implcxx . . $ ggml_sqrt_impl(cb9053aa8fa7848).( |
| 2020 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2021 | struct ggml_tensor * a, |
| 2022 | bool inplace) { |
| 2023 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2024 | |
| 2025 | result->op = GGML_OP_SQRT; |
| 2026 | result->src[0] = a; |
| 2027 | |
| 2028 | return result; |
| 2029 | } |
| 2030 | |
| 2031 | struct ggml_tensor * ggml_sqrtcxx . . $ ggml_sqrt(71a7fa2ddee25242).( |
| 2032 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2033 | struct ggml_tensor * a) { |
| 2034 | return ggml_sqrt_implcxx . . $ ggml_sqrt_impl(cb9053aa8fa7848).(ctx, a, false); |
| 2035 | } |
| 2036 | |
| 2037 | struct ggml_tensor * ggml_sqrt_inplacecxx . . $ ggml_sqrt_inplace(71a7fa2ddee25242).( |
| 2038 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2039 | struct ggml_tensor * a) { |
| 2040 | return ggml_sqrt_implcxx . . $ ggml_sqrt_impl(cb9053aa8fa7848).(ctx, a, true); |
| 2041 | } |
| 2042 | |
| 2043 | // ggml_log |
| 2044 | |
| 2045 | static struct ggml_tensor * ggml_log_implcxx . . $ ggml_log_impl(cb9053aa8fa7848).( |
| 2046 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2047 | struct ggml_tensor * a, |
| 2048 | bool inplace) { |
| 2049 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2050 | |
| 2051 | result->op = GGML_OP_LOG; |
| 2052 | result->src[0] = a; |
| 2053 | |
| 2054 | return result; |
| 2055 | } |
| 2056 | |
| 2057 | struct ggml_tensor * ggml_logcxx . . $ ggml_log(71a7fa2ddee25242).( |
| 2058 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2059 | struct ggml_tensor * a) { |
| 2060 | return ggml_log_implcxx . . $ ggml_log_impl(cb9053aa8fa7848).(ctx, a, false); |
| 2061 | } |
| 2062 | |
| 2063 | struct ggml_tensor * ggml_log_inplacecxx . . $ ggml_log_inplace(71a7fa2ddee25242).( |
| 2064 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2065 | struct ggml_tensor * a) { |
| 2066 | return ggml_log_implcxx . . $ ggml_log_impl(cb9053aa8fa7848).(ctx, a, true); |
| 2067 | } |
| 2068 | |
| 2069 | struct ggml_tensor * ggml_expm1cxx . . $ ggml_expm1(71a7fa2ddee25242).( |
| 2070 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2071 | struct ggml_tensor * a) { |
| 2072 | return ggml_unary(ctx, a, GGML_UNARY_OP_EXPM1); |
| 2073 | } |
| 2074 | |
| 2075 | struct ggml_tensor * ggml_expm1_inplacecxx . . $ ggml_expm1_inplace(71a7fa2ddee25242).( |
| 2076 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2077 | struct ggml_tensor * a) { |
| 2078 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_EXPM1); |
| 2079 | } |
| 2080 | |
| 2081 | struct ggml_tensor * ggml_softpluscxx . . $ ggml_softplus(71a7fa2ddee25242).( |
| 2082 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2083 | struct ggml_tensor * a) { |
| 2084 | return ggml_unary(ctx, a, GGML_UNARY_OP_SOFTPLUS); |
| 2085 | } |
| 2086 | |
| 2087 | struct ggml_tensor * ggml_softplus_inplacecxx . . $ ggml_softplus_inplace(71a7fa2ddee25242).( |
| 2088 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2089 | struct ggml_tensor * a) { |
| 2090 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_SOFTPLUS); |
| 2091 | } |
| 2092 | |
| 2093 | // ggml_sin |
| 2094 | |
| 2095 | static struct ggml_tensor * ggml_sin_implcxx . . $ ggml_sin_impl(cb9053aa8fa7848).( |
| 2096 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2097 | struct ggml_tensor * a, |
| 2098 | bool inplace) { |
| 2099 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2100 | |
| 2101 | result->op = GGML_OP_SIN; |
| 2102 | result->src[0] = a; |
| 2103 | |
| 2104 | return result; |
| 2105 | } |
| 2106 | |
| 2107 | struct ggml_tensor * ggml_sincxx . . $ ggml_sin(71a7fa2ddee25242).( |
| 2108 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2109 | struct ggml_tensor * a) { |
| 2110 | return ggml_sin_implcxx . . $ ggml_sin_impl(cb9053aa8fa7848).(ctx, a, false); |
| 2111 | } |
| 2112 | |
| 2113 | struct ggml_tensor * ggml_sin_inplacecxx . . $ ggml_sin_inplace(71a7fa2ddee25242).( |
| 2114 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2115 | struct ggml_tensor * a) { |
| 2116 | return ggml_sin_implcxx . . $ ggml_sin_impl(cb9053aa8fa7848).(ctx, a, true); |
| 2117 | } |
| 2118 | |
| 2119 | // ggml_cos |
| 2120 | |
| 2121 | static struct ggml_tensor * ggml_cos_implcxx . . $ ggml_cos_impl(cb9053aa8fa7848).( |
| 2122 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2123 | struct ggml_tensor * a, |
| 2124 | bool inplace) { |
| 2125 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2126 | |
| 2127 | result->op = GGML_OP_COS; |
| 2128 | result->src[0] = a; |
| 2129 | |
| 2130 | return result; |
| 2131 | } |
| 2132 | |
| 2133 | struct ggml_tensor * ggml_coscxx . . $ ggml_cos(71a7fa2ddee25242).( |
| 2134 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2135 | struct ggml_tensor * a) { |
| 2136 | return ggml_cos_implcxx . . $ ggml_cos_impl(cb9053aa8fa7848).(ctx, a, false); |
| 2137 | } |
| 2138 | |
| 2139 | struct ggml_tensor * ggml_cos_inplacecxx . . $ ggml_cos_inplace(71a7fa2ddee25242).( |
| 2140 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2141 | struct ggml_tensor * a) { |
| 2142 | return ggml_cos_implcxx . . $ ggml_cos_impl(cb9053aa8fa7848).(ctx, a, true); |
| 2143 | } |
| 2144 | |
| 2145 | // ggml_sum |
| 2146 | |
| 2147 | struct ggml_tensor * ggml_sumcxx . . $ ggml_sum(71a7fa2ddee25242).( |
| 2148 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2149 | struct ggml_tensor * a) { |
| 2150 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, a->type, 1); |
| 2151 | |
| 2152 | result->op = GGML_OP_SUM; |
| 2153 | result->src[0] = a; |
| 2154 | |
| 2155 | return result; |
| 2156 | } |
| 2157 | |
| 2158 | // ggml_sum_rows |
| 2159 | |
| 2160 | struct ggml_tensor * ggml_sum_rowscxx . . $ ggml_sum_rows(71a7fa2ddee25242).( |
| 2161 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2162 | struct ggml_tensor * a) { |
| 2163 | int64_tcxx . . $ int64_t# ne[GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!] = { 1 }; |
| 2164 | for (int i = 1; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; ++i) { |
| 2165 | ne[i] = a->ne[i]; |
| 2166 | } |
| 2167 | |
| 2168 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, a->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, ne); |
| 2169 | |
| 2170 | result->op = GGML_OP_SUM_ROWS; |
| 2171 | result->src[0] = a; |
| 2172 | |
| 2173 | return result; |
| 2174 | } |
| 2175 | |
| 2176 | // ggml_cumsum |
| 2177 | |
| 2178 | struct ggml_tensor * ggml_cumsumcxx . . $ ggml_cumsum(71a7fa2ddee25242).( |
| 2179 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2180 | struct ggml_tensor * a) { |
| 2181 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 2182 | |
| 2183 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2184 | |
| 2185 | result->op = GGML_OP_CUMSUM; |
| 2186 | result->src[0] = a; |
| 2187 | |
| 2188 | return result; |
| 2189 | } |
| 2190 | |
| 2191 | // ggml_mean |
| 2192 | |
| 2193 | struct ggml_tensor * ggml_meancxx . . $ ggml_mean(71a7fa2ddee25242).( |
| 2194 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2195 | struct ggml_tensor * a) { |
| 2196 | int64_tcxx . . $ int64_t# ne[4] = { 1, a->ne[1], a->ne[2], a->ne[3] }; |
| 2197 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 2198 | |
| 2199 | result->op = GGML_OP_MEAN; |
| 2200 | result->src[0] = a; |
| 2201 | |
| 2202 | return result; |
| 2203 | } |
| 2204 | |
| 2205 | // ggml_argmax |
| 2206 | |
| 2207 | struct ggml_tensor * ggml_argmaxcxx . . $ ggml_argmax(71a7fa2ddee25242).( |
| 2208 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2209 | struct ggml_tensor * a) { |
| 2210 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_matrix(a)); |
| 2211 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] <= INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!); |
| 2212 | |
| 2213 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, GGML_TYPE_I32, a->ne[1]); |
| 2214 | |
| 2215 | result->op = GGML_OP_ARGMAX; |
| 2216 | result->src[0] = a; |
| 2217 | |
| 2218 | return result; |
| 2219 | } |
| 2220 | |
| 2221 | // ggml_count_equal |
| 2222 | |
| 2223 | struct ggml_tensor * ggml_count_equalcxx . . $ ggml_count_equal(590e8193bb8aebeb).( |
| 2224 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2225 | struct ggml_tensor * a, |
| 2226 | struct ggml_tensor * b) { |
| 2227 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, b)); |
| 2228 | |
| 2229 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, GGML_TYPE_I64, 1); |
| 2230 | |
| 2231 | result->op = GGML_OP_COUNT_EQUAL; |
| 2232 | result->src[0] = a; |
| 2233 | result->src[1] = b; |
| 2234 | |
| 2235 | return result; |
| 2236 | } |
| 2237 | |
| 2238 | // ggml_repeat |
| 2239 | |
| 2240 | struct ggml_tensor * ggml_repeatcxx . . $ ggml_repeat(590e8193bb8aebeb).( |
| 2241 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2242 | struct ggml_tensor * a, |
| 2243 | struct ggml_tensor * b) { |
| 2244 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat(a, b)); |
| 2245 | |
| 2246 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, a->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, b->ne); |
| 2247 | |
| 2248 | result->op = GGML_OP_REPEAT; |
| 2249 | result->src[0] = a; |
| 2250 | |
| 2251 | return result; |
| 2252 | } |
| 2253 | |
| 2254 | struct ggml_tensor * ggml_repeat_4dcxx . . $ ggml_repeat_4d(35a4bd770d1e0c77).( |
| 2255 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2256 | struct ggml_tensor * a, |
| 2257 | int64_tcxx . . $ int64_t# ne0, int64_tcxx . . $ int64_t# ne1, int64_tcxx . . $ int64_t# ne2, int64_tcxx . . $ int64_t# ne3) { |
| 2258 | const bool can_repeat = ggml_is_emptycxx . . $ ggml_is_empty(8fa73a561a000eab).(a) || ( |
| 2259 | (ne0 % a->ne[0] == 0) && |
| 2260 | (ne1 % a->ne[1] == 0) && |
| 2261 | (ne2 % a->ne[2] == 0) && |
| 2262 | (ne3 % a->ne[3] == 0) |
| 2263 | ); |
| 2264 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(can_repeat); |
| 2265 | |
| 2266 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, a->type, ne0, ne1, ne2, ne3); |
| 2267 | |
| 2268 | result->op = GGML_OP_REPEAT; |
| 2269 | result->src[0] = a; |
| 2270 | |
| 2271 | return result; |
| 2272 | } |
| 2273 | |
| 2274 | // ggml_repeat_back |
| 2275 | |
| 2276 | struct ggml_tensor * ggml_repeat_backcxx . . $ ggml_repeat_back(590e8193bb8aebeb).( |
| 2277 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2278 | struct ggml_tensor * a, |
| 2279 | struct ggml_tensor * b) { |
| 2280 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_repeat(b, a)); |
| 2281 | |
| 2282 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, a->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, b->ne); |
| 2283 | |
| 2284 | result->op = GGML_OP_REPEAT_BACK; |
| 2285 | result->src[0] = a; |
| 2286 | |
| 2287 | return result; |
| 2288 | } |
| 2289 | |
| 2290 | // ggml_concat |
| 2291 | |
| 2292 | struct ggml_tensor * ggml_concatcxx . . $ ggml_concat(aef13d738563d208).( |
| 2293 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2294 | struct ggml_tensor * a, |
| 2295 | struct ggml_tensor * b, |
| 2296 | int dim) { |
| 2297 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dim >= 0 && dim < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!); |
| 2298 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == b->type); |
| 2299 | |
| 2300 | int64_tcxx . . $ int64_t# ne[GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!]; |
| 2301 | for (int d = 0; d < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; ++d) { |
| 2302 | if (d == dim) { |
| 2303 | ne[d] = a->ne[d] + b->ne[d]; |
| 2304 | continue; |
| 2305 | } |
| 2306 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[d] == b->ne[d]); |
| 2307 | ne[d] = a->ne[d]; |
| 2308 | } |
| 2309 | |
| 2310 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, a->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, ne); |
| 2311 | |
| 2312 | ggml_set_op_params_i32(result, 0, dim); |
| 2313 | |
| 2314 | result->op = GGML_OP_CONCAT; |
| 2315 | result->src[0] = a; |
| 2316 | result->src[1] = b; |
| 2317 | |
| 2318 | return result; |
| 2319 | } |
| 2320 | |
| 2321 | // ggml_abs |
| 2322 | |
| 2323 | struct ggml_tensor * ggml_abscxx . . $ ggml_abs(71a7fa2ddee25242).( |
| 2324 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2325 | struct ggml_tensor * a) { |
| 2326 | return ggml_unary(ctx, a, GGML_UNARY_OP_ABS); |
| 2327 | } |
| 2328 | |
| 2329 | struct ggml_tensor * ggml_abs_inplacecxx . . $ ggml_abs_inplace(71a7fa2ddee25242).( |
| 2330 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2331 | struct ggml_tensor * a) { |
| 2332 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_ABS); |
| 2333 | } |
| 2334 | |
| 2335 | // ggml_sgn |
| 2336 | |
| 2337 | struct ggml_tensor * ggml_sgncxx . . $ ggml_sgn(71a7fa2ddee25242).( |
| 2338 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2339 | struct ggml_tensor * a) { |
| 2340 | return ggml_unary(ctx, a, GGML_UNARY_OP_SGN); |
| 2341 | } |
| 2342 | |
| 2343 | struct ggml_tensor * ggml_sgn_inplacecxx . . $ ggml_sgn_inplace(71a7fa2ddee25242).( |
| 2344 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2345 | struct ggml_tensor * a) { |
| 2346 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_SGN); |
| 2347 | } |
| 2348 | |
| 2349 | // ggml_neg |
| 2350 | |
| 2351 | struct ggml_tensor * ggml_negcxx . . $ ggml_neg(71a7fa2ddee25242).( |
| 2352 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2353 | struct ggml_tensor * a) { |
| 2354 | return ggml_unary(ctx, a, GGML_UNARY_OP_NEG); |
| 2355 | } |
| 2356 | |
| 2357 | struct ggml_tensor * ggml_neg_inplacecxx . . $ ggml_neg_inplace(71a7fa2ddee25242).( |
| 2358 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2359 | struct ggml_tensor * a) { |
| 2360 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_NEG); |
| 2361 | } |
| 2362 | |
| 2363 | // ggml_step |
| 2364 | |
| 2365 | struct ggml_tensor * ggml_stepcxx . . $ ggml_step(71a7fa2ddee25242).( |
| 2366 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2367 | struct ggml_tensor * a) { |
| 2368 | return ggml_unary(ctx, a, GGML_UNARY_OP_STEP); |
| 2369 | } |
| 2370 | |
| 2371 | struct ggml_tensor * ggml_step_inplacecxx . . $ ggml_step_inplace(71a7fa2ddee25242).( |
| 2372 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2373 | struct ggml_tensor * a) { |
| 2374 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_STEP); |
| 2375 | } |
| 2376 | |
| 2377 | // ggml_tanh |
| 2378 | |
| 2379 | struct ggml_tensor * ggml_tanhcxx . . $ ggml_tanh(71a7fa2ddee25242).( |
| 2380 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2381 | struct ggml_tensor * a) { |
| 2382 | return ggml_unary(ctx, a, GGML_UNARY_OP_TANH); |
| 2383 | } |
| 2384 | |
| 2385 | struct ggml_tensor * ggml_tanh_inplacecxx . . $ ggml_tanh_inplace(71a7fa2ddee25242).( |
| 2386 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2387 | struct ggml_tensor * a) { |
| 2388 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_TANH); |
| 2389 | } |
| 2390 | |
| 2391 | // ggml_elu |
| 2392 | |
| 2393 | struct ggml_tensor * ggml_elucxx . . $ ggml_elu(71a7fa2ddee25242).( |
| 2394 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2395 | struct ggml_tensor * a) { |
| 2396 | return ggml_unary(ctx, a, GGML_UNARY_OP_ELU); |
| 2397 | } |
| 2398 | |
| 2399 | struct ggml_tensor * ggml_elu_inplacecxx . . $ ggml_elu_inplace(71a7fa2ddee25242).( |
| 2400 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2401 | struct ggml_tensor * a) { |
| 2402 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_ELU); |
| 2403 | } |
| 2404 | |
| 2405 | // ggml_relu |
| 2406 | |
| 2407 | struct ggml_tensor * ggml_relucxx . . $ ggml_relu(71a7fa2ddee25242).( |
| 2408 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2409 | struct ggml_tensor * a) { |
| 2410 | return ggml_unary(ctx, a, GGML_UNARY_OP_RELU); |
| 2411 | } |
| 2412 | |
| 2413 | struct ggml_tensor * ggml_relu_inplacecxx . . $ ggml_relu_inplace(71a7fa2ddee25242).( |
| 2414 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2415 | struct ggml_tensor * a) { |
| 2416 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_RELU); |
| 2417 | } |
| 2418 | |
| 2419 | // ggml_leaky_relu |
| 2420 | |
| 2421 | struct ggml_tensor * ggml_leaky_relucxx . . $ ggml_leaky_relu(abd14b6ff57d2af7).( |
| 2422 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2423 | struct ggml_tensor * a, |
| 2424 | float negative_slope, |
| 2425 | bool inplace) { |
| 2426 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2427 | |
| 2428 | ggml_set_op_params(result, &negative_slope, sizeof(negative_slope)); |
| 2429 | |
| 2430 | result->op = GGML_OP_LEAKY_RELU; |
| 2431 | result->src[0] = a; |
| 2432 | |
| 2433 | return result; |
| 2434 | } |
| 2435 | |
| 2436 | // ggml_sigmoid |
| 2437 | |
| 2438 | struct ggml_tensor * ggml_sigmoidcxx . . $ ggml_sigmoid(71a7fa2ddee25242).( |
| 2439 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2440 | struct ggml_tensor * a) { |
| 2441 | return ggml_unary(ctx, a, GGML_UNARY_OP_SIGMOID); |
| 2442 | } |
| 2443 | |
| 2444 | struct ggml_tensor * ggml_sigmoid_inplacecxx . . $ ggml_sigmoid_inplace(71a7fa2ddee25242).( |
| 2445 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2446 | struct ggml_tensor * a) { |
| 2447 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_SIGMOID); |
| 2448 | } |
| 2449 | |
| 2450 | // ggml_gelu |
| 2451 | |
| 2452 | struct ggml_tensor * ggml_gelucxx . . $ ggml_gelu(71a7fa2ddee25242).( |
| 2453 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2454 | struct ggml_tensor * a) { |
| 2455 | return ggml_unary(ctx, a, GGML_UNARY_OP_GELU); |
| 2456 | } |
| 2457 | |
| 2458 | struct ggml_tensor * ggml_gelu_inplacecxx . . $ ggml_gelu_inplace(71a7fa2ddee25242).( |
| 2459 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2460 | struct ggml_tensor * a) { |
| 2461 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_GELU); |
| 2462 | } |
| 2463 | |
| 2464 | // ggml_gelu_erf |
| 2465 | |
| 2466 | struct ggml_tensor * ggml_gelu_erfcxx . . $ ggml_gelu_erf(71a7fa2ddee25242).( |
| 2467 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2468 | struct ggml_tensor * a) { |
| 2469 | return ggml_unary(ctx, a, GGML_UNARY_OP_GELU_ERF); |
| 2470 | } |
| 2471 | |
| 2472 | struct ggml_tensor * ggml_gelu_erf_inplacecxx . . $ ggml_gelu_erf_inplace(71a7fa2ddee25242).( |
| 2473 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2474 | struct ggml_tensor * a) { |
| 2475 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_GELU_ERF); |
| 2476 | } |
| 2477 | |
| 2478 | // ggml_gelu_quick |
| 2479 | |
| 2480 | struct ggml_tensor * ggml_gelu_quickcxx . . $ ggml_gelu_quick(71a7fa2ddee25242).( |
| 2481 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2482 | struct ggml_tensor * a) { |
| 2483 | return ggml_unary(ctx, a, GGML_UNARY_OP_GELU_QUICK); |
| 2484 | } |
| 2485 | |
| 2486 | struct ggml_tensor * ggml_gelu_quick_inplacecxx . . $ ggml_gelu_quick_inplace(71a7fa2ddee25242).( |
| 2487 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2488 | struct ggml_tensor * a) { |
| 2489 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_GELU_QUICK); |
| 2490 | } |
| 2491 | |
| 2492 | // ggml_silu |
| 2493 | |
| 2494 | struct ggml_tensor * ggml_silucxx . . $ ggml_silu(71a7fa2ddee25242).( |
| 2495 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2496 | struct ggml_tensor * a) { |
| 2497 | return ggml_unary(ctx, a, GGML_UNARY_OP_SILU); |
| 2498 | } |
| 2499 | |
| 2500 | struct ggml_tensor * ggml_silu_inplacecxx . . $ ggml_silu_inplace(71a7fa2ddee25242).( |
| 2501 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2502 | struct ggml_tensor * a) { |
| 2503 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_SILU); |
| 2504 | } |
| 2505 | |
| 2506 | // ggml_xielu |
| 2507 | |
| 2508 | struct ggml_tensor * ggml_xielucxx . . $ ggml_xielu(b4bdf7293be61f13).( |
| 2509 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2510 | struct ggml_tensor * a, |
| 2511 | float alpha_n, |
| 2512 | float alpha_p, |
| 2513 | float beta, |
| 2514 | float eps) { |
| 2515 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2516 | |
| 2517 | ggml_set_op_params_i32(result, 0, (int32_tcxx . . $ int32_t#) GGML_UNARY_OP_XIELU); |
| 2518 | ggml_set_op_params_f32(result, 1, beta + ggml_compute_softplus_f32(alpha_n)); |
| 2519 | ggml_set_op_params_f32(result, 2, ggml_compute_softplus_f32(alpha_p)); |
| 2520 | ggml_set_op_params_f32(result, 3, beta); |
| 2521 | ggml_set_op_params_f32(result, 4, eps); |
| 2522 | |
| 2523 | result->op = GGML_OP_UNARY; |
| 2524 | result->src[0] = a; |
| 2525 | |
| 2526 | return result; |
| 2527 | } |
| 2528 | |
| 2529 | // ggml_silu_back |
| 2530 | |
| 2531 | struct ggml_tensor * ggml_silu_backcxx . . $ ggml_silu_back(590e8193bb8aebeb).( |
| 2532 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2533 | struct ggml_tensor * a, |
| 2534 | struct ggml_tensor * b) { |
| 2535 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2536 | |
| 2537 | result->op = GGML_OP_SILU_BACK; |
| 2538 | result->src[0] = a; |
| 2539 | result->src[1] = b; |
| 2540 | |
| 2541 | return result; |
| 2542 | } |
| 2543 | |
| 2544 | // ggml hardswish |
| 2545 | |
| 2546 | struct ggml_tensor * ggml_hardswishcxx . . $ ggml_hardswish(71a7fa2ddee25242).( |
| 2547 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2548 | struct ggml_tensor * a) { |
| 2549 | return ggml_unary(ctx, a, GGML_UNARY_OP_HARDSWISH); |
| 2550 | } |
| 2551 | |
| 2552 | // ggml hardsigmoid |
| 2553 | |
| 2554 | struct ggml_tensor * ggml_hardsigmoidcxx . . $ ggml_hardsigmoid(71a7fa2ddee25242).( |
| 2555 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2556 | struct ggml_tensor * a) { |
| 2557 | return ggml_unary(ctx, a, GGML_UNARY_OP_HARDSIGMOID); |
| 2558 | } |
| 2559 | |
| 2560 | // ggml exp |
| 2561 | |
| 2562 | struct ggml_tensor * ggml_expcxx . . $ ggml_exp(71a7fa2ddee25242).( |
| 2563 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2564 | struct ggml_tensor * a) { |
| 2565 | return ggml_unary(ctx, a, GGML_UNARY_OP_EXP); |
| 2566 | } |
| 2567 | |
| 2568 | struct ggml_tensor * ggml_exp_inplacecxx . . $ ggml_exp_inplace(71a7fa2ddee25242).( |
| 2569 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2570 | struct ggml_tensor * a) { |
| 2571 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_EXP); |
| 2572 | } |
| 2573 | |
| 2574 | // ggml_glu |
| 2575 | |
| 2576 | static struct ggml_tensor * ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).( |
| 2577 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2578 | struct ggml_tensor * a, |
| 2579 | struct ggml_tensor * b, |
| 2580 | enum ggml_glu_op op, |
| 2581 | bool swapped) { |
| 2582 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous_1(a)); |
| 2583 | |
| 2584 | if (b) { |
| 2585 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous_1(b)); |
| 2586 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, b)); |
| 2587 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == b->type); |
| 2588 | } |
| 2589 | |
| 2590 | int64_tcxx . . $ int64_t# ne[GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!] = { a->ne[0] / 2 }; for (int i = 1; i < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!; i++) ne[i] = a->ne[i]; |
| 2591 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, b ? a->ne : ne, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 0); |
| 2592 | |
| 2593 | ggml_set_op_params_i32(result, 0, (int32_tcxx . . $ int32_t#) op); |
| 2594 | ggml_set_op_params_i32(result, 1, (int32_tcxx . . $ int32_t#) swapped); |
| 2595 | |
| 2596 | result->op = GGML_OP_GLU; |
| 2597 | result->src[0] = a; |
| 2598 | result->src[1] = b; |
| 2599 | |
| 2600 | return result; |
| 2601 | } |
| 2602 | |
| 2603 | // ggml_floor |
| 2604 | |
| 2605 | struct ggml_tensor * ggml_floorcxx . . $ ggml_floor(71a7fa2ddee25242).( |
| 2606 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2607 | struct ggml_tensor * a) { |
| 2608 | return ggml_unary(ctx, a, GGML_UNARY_OP_FLOOR); |
| 2609 | } |
| 2610 | |
| 2611 | struct ggml_tensor * ggml_floor_inplacecxx . . $ ggml_floor_inplace(71a7fa2ddee25242).( |
| 2612 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2613 | struct ggml_tensor * a) { |
| 2614 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_FLOOR); |
| 2615 | } |
| 2616 | |
| 2617 | // ggml_ceil |
| 2618 | |
| 2619 | struct ggml_tensor * ggml_ceilcxx . . $ ggml_ceil(71a7fa2ddee25242).( |
| 2620 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2621 | struct ggml_tensor * a) { |
| 2622 | return ggml_unary(ctx, a, GGML_UNARY_OP_CEIL); |
| 2623 | } |
| 2624 | |
| 2625 | struct ggml_tensor * ggml_ceil_inplacecxx . . $ ggml_ceil_inplace(71a7fa2ddee25242).( |
| 2626 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2627 | struct ggml_tensor * a) { |
| 2628 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_CEIL); |
| 2629 | } |
| 2630 | |
| 2631 | //ggml_round |
| 2632 | |
| 2633 | struct ggml_tensor * ggml_roundcxx . . $ ggml_round(71a7fa2ddee25242).( |
| 2634 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2635 | struct ggml_tensor * a) { |
| 2636 | return ggml_unary(ctx, a, GGML_UNARY_OP_ROUND); |
| 2637 | } |
| 2638 | |
| 2639 | struct ggml_tensor * ggml_round_inplacecxx . . $ ggml_round_inplace(71a7fa2ddee25242).( |
| 2640 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2641 | struct ggml_tensor * a) { |
| 2642 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_ROUND); |
| 2643 | } |
| 2644 | |
| 2645 | //ggml_trunc |
| 2646 | |
| 2647 | struct ggml_tensor * ggml_trunccxx . . $ ggml_trunc(71a7fa2ddee25242).( |
| 2648 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2649 | struct ggml_tensor * a) { |
| 2650 | return ggml_unary(ctx, a, GGML_UNARY_OP_TRUNC); |
| 2651 | } |
| 2652 | |
| 2653 | struct ggml_tensor * ggml_trunc_inplacecxx . . $ ggml_trunc_inplace(71a7fa2ddee25242).( |
| 2654 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2655 | struct ggml_tensor * a) { |
| 2656 | return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_TRUNC); |
| 2657 | } |
| 2658 | |
| 2659 | struct ggml_tensor * ggml_glucxx . . $ ggml_glu(49cd9232583257eb).( |
| 2660 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2661 | struct ggml_tensor * a, |
| 2662 | enum ggml_glu_op op, |
| 2663 | bool swapped) { |
| 2664 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, op, swapped); |
| 2665 | } |
| 2666 | |
| 2667 | struct ggml_tensor * ggml_glu_splitcxx . . $ ggml_glu_split(c9ecde6e91fb6ecf).( |
| 2668 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2669 | struct ggml_tensor * a, |
| 2670 | struct ggml_tensor * b, |
| 2671 | enum ggml_glu_op op) { |
| 2672 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, op, false); |
| 2673 | } |
| 2674 | |
| 2675 | // ggml_reglu |
| 2676 | |
| 2677 | struct ggml_tensor * ggml_reglucxx . . $ ggml_reglu(71a7fa2ddee25242).( |
| 2678 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2679 | struct ggml_tensor * a) { |
| 2680 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_REGLU, false); |
| 2681 | } |
| 2682 | |
| 2683 | struct ggml_tensor * ggml_reglu_swappedcxx . . $ ggml_reglu_swapped(71a7fa2ddee25242).( |
| 2684 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2685 | struct ggml_tensor * a) { |
| 2686 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_REGLU, true); |
| 2687 | } |
| 2688 | |
| 2689 | struct ggml_tensor * ggml_reglu_splitcxx . . $ ggml_reglu_split(590e8193bb8aebeb).( |
| 2690 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2691 | struct ggml_tensor * a, |
| 2692 | struct ggml_tensor * b) { |
| 2693 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, GGML_GLU_OP_REGLU, false); |
| 2694 | } |
| 2695 | |
| 2696 | // ggml_geglu |
| 2697 | |
| 2698 | struct ggml_tensor * ggml_geglucxx . . $ ggml_geglu(71a7fa2ddee25242).( |
| 2699 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2700 | struct ggml_tensor * a) { |
| 2701 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_GEGLU, false); |
| 2702 | } |
| 2703 | |
| 2704 | struct ggml_tensor * ggml_geglu_swappedcxx . . $ ggml_geglu_swapped(71a7fa2ddee25242).( |
| 2705 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2706 | struct ggml_tensor * a) { |
| 2707 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_GEGLU, true); |
| 2708 | } |
| 2709 | |
| 2710 | struct ggml_tensor * ggml_geglu_splitcxx . . $ ggml_geglu_split(590e8193bb8aebeb).( |
| 2711 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2712 | struct ggml_tensor * a, |
| 2713 | struct ggml_tensor * b) { |
| 2714 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, GGML_GLU_OP_GEGLU, false); |
| 2715 | } |
| 2716 | |
| 2717 | // ggml_swiglu |
| 2718 | |
| 2719 | struct ggml_tensor * ggml_swiglucxx . . $ ggml_swiglu(71a7fa2ddee25242).( |
| 2720 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2721 | struct ggml_tensor * a) { |
| 2722 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_SWIGLU, false); |
| 2723 | } |
| 2724 | |
| 2725 | struct ggml_tensor * ggml_swiglu_swappedcxx . . $ ggml_swiglu_swapped(71a7fa2ddee25242).( |
| 2726 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2727 | struct ggml_tensor * a) { |
| 2728 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_SWIGLU, true); |
| 2729 | } |
| 2730 | |
| 2731 | struct ggml_tensor * ggml_swiglu_splitcxx . . $ ggml_swiglu_split(590e8193bb8aebeb).( |
| 2732 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2733 | struct ggml_tensor * a, |
| 2734 | struct ggml_tensor * b) { |
| 2735 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, GGML_GLU_OP_SWIGLU, false); |
| 2736 | } |
| 2737 | |
| 2738 | // ggml_geglu_erf |
| 2739 | |
| 2740 | struct ggml_tensor * ggml_geglu_erfcxx . . $ ggml_geglu_erf(71a7fa2ddee25242).( |
| 2741 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2742 | struct ggml_tensor * a) { |
| 2743 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_GEGLU_ERF, false); |
| 2744 | } |
| 2745 | |
| 2746 | struct ggml_tensor * ggml_geglu_erf_swappedcxx . . $ ggml_geglu_erf_swapped(71a7fa2ddee25242).( |
| 2747 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2748 | struct ggml_tensor * a) { |
| 2749 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_GEGLU_ERF, true); |
| 2750 | } |
| 2751 | |
| 2752 | struct ggml_tensor * ggml_geglu_erf_splitcxx . . $ ggml_geglu_erf_split(590e8193bb8aebeb).( |
| 2753 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2754 | struct ggml_tensor * a, |
| 2755 | struct ggml_tensor * b) { |
| 2756 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, GGML_GLU_OP_GEGLU_ERF, false); |
| 2757 | } |
| 2758 | |
| 2759 | // ggml_geglu_quick |
| 2760 | |
| 2761 | struct ggml_tensor * ggml_geglu_quickcxx . . $ ggml_geglu_quick(71a7fa2ddee25242).( |
| 2762 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2763 | struct ggml_tensor * a) { |
| 2764 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_GEGLU_QUICK, false); |
| 2765 | } |
| 2766 | |
| 2767 | struct ggml_tensor * ggml_geglu_quick_swappedcxx . . $ ggml_geglu_quick_swapped(71a7fa2ddee25242).( |
| 2768 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2769 | struct ggml_tensor * a) { |
| 2770 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, GGML_GLU_OP_GEGLU_QUICK, true); |
| 2771 | } |
| 2772 | |
| 2773 | struct ggml_tensor * ggml_geglu_quick_splitcxx . . $ ggml_geglu_quick_split(590e8193bb8aebeb).( |
| 2774 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2775 | struct ggml_tensor * a, |
| 2776 | struct ggml_tensor * b) { |
| 2777 | return ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, GGML_GLU_OP_GEGLU_QUICK, false); |
| 2778 | } |
| 2779 | |
| 2780 | struct ggml_tensor * ggml_swiglu_oaicxx . . $ ggml_swiglu_oai(815f2d07c0da5a9c).( |
| 2781 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2782 | struct ggml_tensor * a, |
| 2783 | struct ggml_tensor * b, |
| 2784 | float alpha, |
| 2785 | float limit) { |
| 2786 | struct ggml_tensor * result = ggml_glu_implcxx . . $ ggml_glu_impl(bd5bb3494524a3b8).(ctx, a, b, GGML_GLU_OP_SWIGLU_OAI, false); |
| 2787 | ggml_set_op_params_f32(result, 2, alpha); |
| 2788 | ggml_set_op_params_f32(result, 3, limit); |
| 2789 | |
| 2790 | return result; |
| 2791 | } |
| 2792 | |
| 2793 | // ggml_norm |
| 2794 | |
| 2795 | static struct ggml_tensor * ggml_norm_implcxx . . $ ggml_norm_impl(abd14b6ff57d2af7).( |
| 2796 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2797 | struct ggml_tensor * a, |
| 2798 | float eps, |
| 2799 | bool inplace) { |
| 2800 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2801 | |
| 2802 | ggml_set_op_params(result, &eps, sizeof(eps)); |
| 2803 | |
| 2804 | result->op = GGML_OP_NORM; |
| 2805 | result->src[0] = a; |
| 2806 | |
| 2807 | return result; |
| 2808 | } |
| 2809 | |
| 2810 | struct ggml_tensor * ggml_normcxx . . $ ggml_norm(2b9396bfe07630bc).( |
| 2811 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2812 | struct ggml_tensor * a, |
| 2813 | float eps) { |
| 2814 | return ggml_norm_implcxx . . $ ggml_norm_impl(abd14b6ff57d2af7).(ctx, a, eps, false); |
| 2815 | } |
| 2816 | |
| 2817 | struct ggml_tensor * ggml_norm_inplacecxx . . $ ggml_norm_inplace(2b9396bfe07630bc).( |
| 2818 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2819 | struct ggml_tensor * a, |
| 2820 | float eps) { |
| 2821 | return ggml_norm_implcxx . . $ ggml_norm_impl(abd14b6ff57d2af7).(ctx, a, eps, true); |
| 2822 | } |
| 2823 | |
| 2824 | // ggml_rms_norm |
| 2825 | |
| 2826 | static struct ggml_tensor * ggml_rms_norm_implcxx . . $ ggml_rms_norm_impl(abd14b6ff57d2af7).( |
| 2827 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2828 | struct ggml_tensor * a, |
| 2829 | float eps, |
| 2830 | bool inplace) { |
| 2831 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2832 | |
| 2833 | ggml_set_op_params(result, &eps, sizeof(eps)); |
| 2834 | |
| 2835 | result->op = GGML_OP_RMS_NORM; |
| 2836 | result->src[0] = a; |
| 2837 | |
| 2838 | return result; |
| 2839 | } |
| 2840 | |
| 2841 | struct ggml_tensor * ggml_rms_normcxx . . $ ggml_rms_norm(2b9396bfe07630bc).( |
| 2842 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2843 | struct ggml_tensor * a, |
| 2844 | float eps) { |
| 2845 | return ggml_rms_norm_implcxx . . $ ggml_rms_norm_impl(abd14b6ff57d2af7).(ctx, a, eps, false); |
| 2846 | } |
| 2847 | |
| 2848 | struct ggml_tensor * ggml_rms_norm_inplacecxx . . $ ggml_rms_norm_inplace(2b9396bfe07630bc).( |
| 2849 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2850 | struct ggml_tensor * a, |
| 2851 | float eps) { |
| 2852 | return ggml_rms_norm_implcxx . . $ ggml_rms_norm_impl(abd14b6ff57d2af7).(ctx, a, eps, true); |
| 2853 | } |
| 2854 | |
| 2855 | // ggml_rms_norm_back |
| 2856 | |
| 2857 | struct ggml_tensor * ggml_rms_norm_backcxx . . $ ggml_rms_norm_back(e71eeb674f62ec63).( |
| 2858 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2859 | struct ggml_tensor * a, |
| 2860 | struct ggml_tensor * b, |
| 2861 | float eps) { |
| 2862 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2863 | |
| 2864 | ggml_set_op_params(result, &eps, sizeof(eps)); |
| 2865 | |
| 2866 | result->op = GGML_OP_RMS_NORM_BACK; |
| 2867 | result->src[0] = a; |
| 2868 | result->src[1] = b; |
| 2869 | |
| 2870 | return result; |
| 2871 | } |
| 2872 | |
| 2873 | // ggml_group_norm |
| 2874 | |
| 2875 | static struct ggml_tensor * ggml_group_norm_implcxx . . $ ggml_group_norm_impl(6365356cf45411b8).( |
| 2876 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2877 | struct ggml_tensor * a, |
| 2878 | int n_groups, |
| 2879 | float eps, |
| 2880 | bool inplace) { |
| 2881 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2882 | |
| 2883 | ggml_set_op_params_i32(result, 0, n_groups); |
| 2884 | ggml_set_op_params_f32(result, 1, eps); |
| 2885 | |
| 2886 | result->op = GGML_OP_GROUP_NORM; |
| 2887 | result->src[0] = a; |
| 2888 | |
| 2889 | return result; |
| 2890 | } |
| 2891 | |
| 2892 | struct ggml_tensor * ggml_group_normcxx . . $ ggml_group_norm(45ae27fe83c02e55).( |
| 2893 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2894 | struct ggml_tensor * a, |
| 2895 | int n_groups, |
| 2896 | float eps) { |
| 2897 | return ggml_group_norm_implcxx . . $ ggml_group_norm_impl(6365356cf45411b8).(ctx, a, n_groups, eps, false); |
| 2898 | } |
| 2899 | |
| 2900 | struct ggml_tensor * ggml_group_norm_inplacecxx . . $ ggml_group_norm_inplace(45ae27fe83c02e55).( |
| 2901 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2902 | struct ggml_tensor * a, |
| 2903 | int n_groups, |
| 2904 | float eps) { |
| 2905 | return ggml_group_norm_implcxx . . $ ggml_group_norm_impl(6365356cf45411b8).(ctx, a, n_groups, eps, true); |
| 2906 | } |
| 2907 | |
| 2908 | // ggml_l2_norm |
| 2909 | |
| 2910 | static struct ggml_tensor * ggml_l2_norm_implcxx . . $ ggml_l2_norm_impl(abd14b6ff57d2af7).( |
| 2911 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2912 | struct ggml_tensor * a, |
| 2913 | float eps, |
| 2914 | bool inplace) { |
| 2915 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 2916 | |
| 2917 | ggml_set_op_params_f32(result, 0, eps); |
| 2918 | |
| 2919 | result->op = GGML_OP_L2_NORM; |
| 2920 | result->src[0] = a; |
| 2921 | |
| 2922 | return result; |
| 2923 | } |
| 2924 | |
| 2925 | struct ggml_tensor * ggml_l2_normcxx . . $ ggml_l2_norm(2b9396bfe07630bc).( |
| 2926 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2927 | struct ggml_tensor * a, |
| 2928 | float eps) { |
| 2929 | return ggml_l2_norm_implcxx . . $ ggml_l2_norm_impl(abd14b6ff57d2af7).(ctx, a, eps, false); |
| 2930 | } |
| 2931 | |
| 2932 | struct ggml_tensor * ggml_l2_norm_inplacecxx . . $ ggml_l2_norm_inplace(2b9396bfe07630bc).( |
| 2933 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2934 | struct ggml_tensor * a, |
| 2935 | float eps) { |
| 2936 | return ggml_l2_norm_implcxx . . $ ggml_l2_norm_impl(abd14b6ff57d2af7).(ctx, a, eps, true); |
| 2937 | } |
| 2938 | |
| 2939 | // ggml_mul_mat |
| 2940 | |
| 2941 | static inline bool ggml_can_mul_matcxx . . $ ggml_can_mul_mat(3bd891636d1661b7).(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { |
| 2942 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 2943 | |
| 2944 | return (t0->ne[0] == t1->ne[0]) && |
| 2945 | (t1->ne[2]%t0->ne[2] == 0) && // verify t0 is broadcastable |
| 2946 | (t1->ne[3]%t0->ne[3] == 0); |
| 2947 | } |
| 2948 | |
| 2949 | struct ggml_tensor * ggml_mul_matcxx . . $ ggml_mul_mat(590e8193bb8aebeb).( |
| 2950 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2951 | struct ggml_tensor * a, |
| 2952 | struct ggml_tensor * b) { |
| 2953 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_mul_mat(a, b)); |
| 2954 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!ggml_is_transposed(a)); |
| 2955 | |
| 2956 | const int64_tcxx . . $ int64_t# ne[4] = { a->ne[1], b->ne[1], b->ne[2], b->ne[3] }; |
| 2957 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 2958 | |
| 2959 | result->op = GGML_OP_MUL_MAT; |
| 2960 | result->src[0] = a; |
| 2961 | result->src[1] = b; |
| 2962 | |
| 2963 | return result; |
| 2964 | } |
| 2965 | |
| 2966 | void ggml_mul_mat_set_preccxx . . $ ggml_mul_mat_set_prec(2c583290e1112ede).( |
| 2967 | struct ggml_tensor * a, |
| 2968 | enum ggml_prec prec) { |
| 2969 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->op == GGML_OP_MUL_MAT); |
| 2970 | |
| 2971 | const int32_tcxx . . $ int32_t# prec_i32 = (int32_tcxx . . $ int32_t#) prec; |
| 2972 | |
| 2973 | ggml_set_op_params_i32(a, 0, prec_i32); |
| 2974 | } |
| 2975 | |
| 2976 | // ggml_mul_mat_id |
| 2977 | |
| 2978 | /* |
| 2979 | c = ggml_mul_mat_id(ctx, as, b, ids); |
| 2980 | |
| 2981 | as -> [cols, rows, n_expert] |
| 2982 | b -> [cols, n_expert_used, n_tokens] |
| 2983 | ids -> [n_expert_used, n_tokens] (i32) |
| 2984 | c -> [rows, n_expert_used, n_tokens] |
| 2985 | |
| 2986 | in b, n_expert_used can be broadcasted to match the n_expert_used of ids |
| 2987 | |
| 2988 | c ~= as[:,:,i] @ b[:,i%r,t], i = ids[e,t] for all e,t in ids |
| 2989 | */ |
| 2990 | struct ggml_tensor * ggml_mul_mat_idcxx . . $ ggml_mul_mat_id(28fd2ad14bf2989).( |
| 2991 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 2992 | struct ggml_tensor * as, |
| 2993 | struct ggml_tensor * b, |
| 2994 | struct ggml_tensor * ids) { |
| 2995 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!ggml_is_transposed(as)); |
| 2996 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->type == GGML_TYPE_I32); |
| 2997 | |
| 2998 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(as->ne[3] == 1); // as is 3d (one matrix per expert) |
| 2999 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[3] == 1); // b is 3d |
| 3000 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->ne[2] == 1 && ids->ne[3] == 1); // ids is 2d |
| 3001 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->ne[1] == b->ne[2]); // must have an expert list per b row |
| 3002 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(as->ne[0] == b->ne[0]); // can_mul_mat |
| 3003 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->ne[0] % b->ne[1] == 0); // can broadcast |
| 3004 | |
| 3005 | const int64_tcxx . . $ int64_t# ne[4] = { as->ne[1], ids->ne[0], b->ne[2], 1 }; |
| 3006 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 3007 | |
| 3008 | result->op = GGML_OP_MUL_MAT_ID; |
| 3009 | result->src[0] = as; |
| 3010 | result->src[1] = b; |
| 3011 | result->src[2] = ids; |
| 3012 | |
| 3013 | return result; |
| 3014 | } |
| 3015 | |
| 3016 | // ggml_out_prod |
| 3017 | |
| 3018 | static inline bool ggml_can_out_prodcxx . . $ ggml_can_out_prod(3bd891636d1661b7).(const struct ggml_tensor * t0, const struct ggml_tensor * t1) { |
| 3019 | static_assert(GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`! == 4, "GGML_MAX_DIMS is not 4 - update this function"); |
| 3020 | |
| 3021 | return (t0->ne[1] == t1->ne[1]) && |
| 3022 | (t1->ne[2]%t0->ne[2] == 0) && // verify t0 is broadcastable |
| 3023 | (t1->ne[3]%t0->ne[3] == 0); |
| 3024 | } |
| 3025 | |
| 3026 | struct ggml_tensor * ggml_out_prodcxx . . $ ggml_out_prod(590e8193bb8aebeb).( |
| 3027 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3028 | struct ggml_tensor * a, |
| 3029 | struct ggml_tensor * b) { |
| 3030 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_out_prod(a, b)); |
| 3031 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!ggml_is_transposed(a)); |
| 3032 | |
| 3033 | // a is broadcastable to b for ne[2] and ne[3] -> use b->ne[2] and b->ne[3] |
| 3034 | const int64_tcxx . . $ int64_t# ne[4] = { a->ne[0], b->ne[0], b->ne[2], b->ne[3] }; |
| 3035 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 3036 | |
| 3037 | result->op = GGML_OP_OUT_PROD; |
| 3038 | result->src[0] = a; |
| 3039 | result->src[1] = b; |
| 3040 | |
| 3041 | return result; |
| 3042 | } |
| 3043 | |
| 3044 | // ggml_scale |
| 3045 | |
| 3046 | static struct ggml_tensor * ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).( |
| 3047 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3048 | struct ggml_tensor * a, |
| 3049 | float s, |
| 3050 | float b, |
| 3051 | bool inplace) { |
| 3052 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_padded_1d(a)); |
| 3053 | |
| 3054 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3055 | |
| 3056 | float params[2] = { s, b }; |
| 3057 | ggml_set_op_params(result, ¶ms, sizeof(params)); |
| 3058 | |
| 3059 | result->op = GGML_OP_SCALE; |
| 3060 | result->src[0] = a; |
| 3061 | |
| 3062 | return result; |
| 3063 | } |
| 3064 | |
| 3065 | struct ggml_tensor * ggml_scalecxx . . $ ggml_scale(2b9396bfe07630bc).( |
| 3066 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3067 | struct ggml_tensor * a, |
| 3068 | float s) { |
| 3069 | return ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).(ctx, a, s, 0.0, false); |
| 3070 | } |
| 3071 | |
| 3072 | struct ggml_tensor * ggml_scale_inplacecxx . . $ ggml_scale_inplace(2b9396bfe07630bc).( |
| 3073 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3074 | struct ggml_tensor * a, |
| 3075 | float s) { |
| 3076 | return ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).(ctx, a, s, 0.0, true); |
| 3077 | } |
| 3078 | |
| 3079 | struct ggml_tensor * ggml_scale_biascxx . . $ ggml_scale_bias(a7d32b7035d2f05b).( |
| 3080 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3081 | struct ggml_tensor * a, |
| 3082 | float s, |
| 3083 | float b) { |
| 3084 | return ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).(ctx, a, s, b, false); |
| 3085 | } |
| 3086 | |
| 3087 | struct ggml_tensor * ggml_scale_bias_inplacecxx . . $ ggml_scale_bias_inplace(a7d32b7035d2f05b).( |
| 3088 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3089 | struct ggml_tensor * a, |
| 3090 | float s, |
| 3091 | float b) { |
| 3092 | return ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).(ctx, a, s, b, true); |
| 3093 | } |
| 3094 | |
| 3095 | // ggml_set |
| 3096 | |
| 3097 | static struct ggml_tensor * ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).( |
| 3098 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3099 | struct ggml_tensor * a, |
| 3100 | struct ggml_tensor * b, |
| 3101 | size_t nb1, |
| 3102 | size_t nb2, |
| 3103 | size_t nb3, |
| 3104 | size_t offset, |
| 3105 | bool inplace) { |
| 3106 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) >= ggml_nelements(b)); |
| 3107 | |
| 3108 | // make a view of the destination |
| 3109 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3110 | |
| 3111 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(offset < (size_t)(1 << 30)); |
| 3112 | int32_tcxx . . $ int32_t# params[] = { (int32_tcxx . . $ int32_t#) nb1, (int32_tcxx . . $ int32_t#) nb2, (int32_tcxx . . $ int32_t#) nb3, (int32_tcxx . . $ int32_t#) offset, inplace ? 1 : 0 }; |
| 3113 | ggml_set_op_params(result, params, sizeof(params)); |
| 3114 | |
| 3115 | result->op = GGML_OP_SET; |
| 3116 | result->src[0] = a; |
| 3117 | result->src[1] = b; |
| 3118 | |
| 3119 | return result; |
| 3120 | } |
| 3121 | |
| 3122 | struct ggml_tensor * ggml_setcxx . . $ ggml_set(29a548f2e4e55123).( |
| 3123 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3124 | struct ggml_tensor * a, |
| 3125 | struct ggml_tensor * b, |
| 3126 | size_t nb1, |
| 3127 | size_t nb2, |
| 3128 | size_t nb3, |
| 3129 | size_t offset) { |
| 3130 | return ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).(ctx, a, b, nb1, nb2, nb3, offset, false); |
| 3131 | } |
| 3132 | |
| 3133 | struct ggml_tensor * ggml_set_inplacecxx . . $ ggml_set_inplace(29a548f2e4e55123).( |
| 3134 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3135 | struct ggml_tensor * a, |
| 3136 | struct ggml_tensor * b, |
| 3137 | size_t nb1, |
| 3138 | size_t nb2, |
| 3139 | size_t nb3, |
| 3140 | size_t offset) { |
| 3141 | return ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).(ctx, a, b, nb1, nb2, nb3, offset, true); |
| 3142 | } |
| 3143 | |
| 3144 | struct ggml_tensor * ggml_set_1dcxx . . $ ggml_set_1d(350727d7c79ad1c7).( |
| 3145 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3146 | struct ggml_tensor * a, |
| 3147 | struct ggml_tensor * b, |
| 3148 | size_t offset) { |
| 3149 | return ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).(ctx, a, b, a->nb[1], a->nb[2], a->nb[3], offset, false); |
| 3150 | } |
| 3151 | |
| 3152 | struct ggml_tensor * ggml_set_1d_inplacecxx . . $ ggml_set_1d_inplace(350727d7c79ad1c7).( |
| 3153 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3154 | struct ggml_tensor * a, |
| 3155 | struct ggml_tensor * b, |
| 3156 | size_t offset) { |
| 3157 | return ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).(ctx, a, b, a->nb[1], a->nb[2], a->nb[3], offset, true); |
| 3158 | } |
| 3159 | |
| 3160 | struct ggml_tensor * ggml_set_2dcxx . . $ ggml_set_2d(798d6dd5b29ca689).( |
| 3161 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3162 | struct ggml_tensor * a, |
| 3163 | struct ggml_tensor * b, |
| 3164 | size_t nb1, |
| 3165 | size_t offset) { |
| 3166 | return ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).(ctx, a, b, nb1, a->nb[2], a->nb[3], offset, false); |
| 3167 | } |
| 3168 | |
| 3169 | struct ggml_tensor * ggml_set_2d_inplacecxx . . $ ggml_set_2d_inplace(798d6dd5b29ca689).( |
| 3170 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3171 | struct ggml_tensor * a, |
| 3172 | struct ggml_tensor * b, |
| 3173 | size_t nb1, |
| 3174 | size_t offset) { |
| 3175 | return ggml_set_implcxx . . $ ggml_set_impl(5043d0b8ee1f0fa6).(ctx, a, b, nb1, a->nb[2], a->nb[3], offset, true); |
| 3176 | } |
| 3177 | |
| 3178 | // ggml_cpy |
| 3179 | |
| 3180 | static struct ggml_tensor * ggml_cpy_implcxx . . $ ggml_cpy_impl(590e8193bb8aebeb).( |
| 3181 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3182 | struct ggml_tensor * a, |
| 3183 | struct ggml_tensor * b) { |
| 3184 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == ggml_nelements(b)); |
| 3185 | |
| 3186 | // make a view of the destination |
| 3187 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, b); |
| 3188 | if (strlen(b->name) > 0) { |
| 3189 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (copy of %s)", b->name, a->name); |
| 3190 | } else { |
| 3191 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (copy)", a->name); |
| 3192 | } |
| 3193 | |
| 3194 | result->op = GGML_OP_CPY; |
| 3195 | result->src[0] = a; |
| 3196 | result->src[1] = b; |
| 3197 | |
| 3198 | return result; |
| 3199 | } |
| 3200 | |
| 3201 | struct ggml_tensor * ggml_cpycxx . . $ ggml_cpy(590e8193bb8aebeb).( |
| 3202 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3203 | struct ggml_tensor * a, |
| 3204 | struct ggml_tensor * b) { |
| 3205 | return ggml_cpy_implcxx . . $ ggml_cpy_impl(590e8193bb8aebeb).(ctx, a, b); |
| 3206 | } |
| 3207 | |
| 3208 | struct ggml_tensor * ggml_castcxx . . $ ggml_cast(da3c2829b06accb1).( |
| 3209 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3210 | struct ggml_tensor * a, |
| 3211 | enum ggml_type type) { |
| 3212 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, a->ne); |
| 3213 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (copy)", a->name); |
| 3214 | |
| 3215 | result->op = GGML_OP_CPY; |
| 3216 | result->src[0] = a; |
| 3217 | result->src[1] = result; // note: this self-reference might seem redundant, but it's actually needed by some |
| 3218 | // backends for consistency with ggml_cpy_impl() above |
| 3219 | |
| 3220 | return result; |
| 3221 | } |
| 3222 | |
| 3223 | // ggml_cont |
| 3224 | |
| 3225 | static struct ggml_tensor * ggml_cont_implcxx . . $ ggml_cont_impl(71a7fa2ddee25242).( |
| 3226 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3227 | struct ggml_tensor * a) { |
| 3228 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3229 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (cont)", a->name); |
| 3230 | |
| 3231 | result->op = GGML_OP_CONT; |
| 3232 | result->src[0] = a; |
| 3233 | |
| 3234 | return result; |
| 3235 | } |
| 3236 | |
| 3237 | struct ggml_tensor * ggml_contcxx . . $ ggml_cont(71a7fa2ddee25242).( |
| 3238 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3239 | struct ggml_tensor * a) { |
| 3240 | return ggml_cont_implcxx . . $ ggml_cont_impl(71a7fa2ddee25242).(ctx, a); |
| 3241 | } |
| 3242 | |
| 3243 | // make contiguous, with new shape |
| 3244 | GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! struct ggml_tensor * ggml_cont_1dcxx . . $ ggml_cont_1d(aa4fbbfd3be4a6c9).( |
| 3245 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3246 | struct ggml_tensor * a, |
| 3247 | int64_tcxx . . $ int64_t# ne0) { |
| 3248 | return ggml_cont_4d(ctx, a, ne0, 1, 1, 1); |
| 3249 | } |
| 3250 | |
| 3251 | GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! struct ggml_tensor * ggml_cont_2dcxx . . $ ggml_cont_2d(a8ad33b92c65ec1c).( |
| 3252 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3253 | struct ggml_tensor * a, |
| 3254 | int64_tcxx . . $ int64_t# ne0, |
| 3255 | int64_tcxx . . $ int64_t# ne1) { |
| 3256 | return ggml_cont_4d(ctx, a, ne0, ne1, 1, 1); |
| 3257 | } |
| 3258 | |
| 3259 | GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! struct ggml_tensor * ggml_cont_3dcxx . . $ ggml_cont_3d(67a16a7d20b25b94).( |
| 3260 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3261 | struct ggml_tensor * a, |
| 3262 | int64_tcxx . . $ int64_t# ne0, |
| 3263 | int64_tcxx . . $ int64_t# ne1, |
| 3264 | int64_tcxx . . $ int64_t# ne2) { |
| 3265 | return ggml_cont_4d(ctx, a, ne0, ne1, ne2, 1); |
| 3266 | } |
| 3267 | |
| 3268 | struct ggml_tensor * ggml_cont_4dcxx . . $ ggml_cont_4d(35a4bd770d1e0c77).( |
| 3269 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3270 | struct ggml_tensor * a, |
| 3271 | int64_tcxx . . $ int64_t# ne0, |
| 3272 | int64_tcxx . . $ int64_t# ne1, |
| 3273 | int64_tcxx . . $ int64_t# ne2, |
| 3274 | int64_tcxx . . $ int64_t# ne3) { |
| 3275 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == (ne0*ne1*ne2*ne3)); |
| 3276 | |
| 3277 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, a->type, ne0, ne1, ne2, ne3); |
| 3278 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (cont)", a->name); |
| 3279 | |
| 3280 | result->op = GGML_OP_CONT; |
| 3281 | result->src[0] = a; |
| 3282 | |
| 3283 | return result; |
| 3284 | } |
| 3285 | |
| 3286 | // ggml_reshape |
| 3287 | |
| 3288 | struct ggml_tensor * ggml_reshapecxx . . $ ggml_reshape(590e8193bb8aebeb).( |
| 3289 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3290 | struct ggml_tensor * a, |
| 3291 | struct ggml_tensor * b) { |
| 3292 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 3293 | // as only the shape of b is relevant, and not its memory layout, b is allowed to be non contiguous. |
| 3294 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == ggml_nelements(b)); |
| 3295 | |
| 3296 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, b->ne, a, 0); |
| 3297 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (reshaped)", a->name); |
| 3298 | |
| 3299 | result->op = GGML_OP_RESHAPE; |
| 3300 | result->src[0] = a; |
| 3301 | |
| 3302 | return result; |
| 3303 | } |
| 3304 | |
| 3305 | struct ggml_tensor * ggml_reshape_1dcxx . . $ ggml_reshape_1d(aa4fbbfd3be4a6c9).( |
| 3306 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3307 | struct ggml_tensor * a, |
| 3308 | int64_tcxx . . $ int64_t# ne0) { |
| 3309 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 3310 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == ne0); |
| 3311 | |
| 3312 | const int64_tcxx . . $ int64_t# ne[1] = { ne0 }; |
| 3313 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, 1, ne, a, 0); |
| 3314 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (reshaped)", a->name); |
| 3315 | |
| 3316 | result->op = GGML_OP_RESHAPE; |
| 3317 | result->src[0] = a; |
| 3318 | |
| 3319 | return result; |
| 3320 | } |
| 3321 | |
| 3322 | struct ggml_tensor * ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).( |
| 3323 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3324 | struct ggml_tensor * a, |
| 3325 | int64_tcxx . . $ int64_t# ne0, |
| 3326 | int64_tcxx . . $ int64_t# ne1) { |
| 3327 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 3328 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == ne0*ne1); |
| 3329 | |
| 3330 | const int64_tcxx . . $ int64_t# ne[2] = { ne0, ne1 }; |
| 3331 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, 2, ne, a, 0); |
| 3332 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (reshaped)", a->name); |
| 3333 | |
| 3334 | result->op = GGML_OP_RESHAPE; |
| 3335 | result->src[0] = a; |
| 3336 | |
| 3337 | return result; |
| 3338 | } |
| 3339 | |
| 3340 | struct ggml_tensor * ggml_reshape_3dcxx . . $ ggml_reshape_3d(67a16a7d20b25b94).( |
| 3341 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3342 | struct ggml_tensor * a, |
| 3343 | int64_tcxx . . $ int64_t# ne0, |
| 3344 | int64_tcxx . . $ int64_t# ne1, |
| 3345 | int64_tcxx . . $ int64_t# ne2) { |
| 3346 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 3347 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == ne0*ne1*ne2); |
| 3348 | |
| 3349 | const int64_tcxx . . $ int64_t# ne[3] = { ne0, ne1, ne2 }; |
| 3350 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, 3, ne, a, 0); |
| 3351 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (reshaped)", a->name); |
| 3352 | |
| 3353 | result->op = GGML_OP_RESHAPE; |
| 3354 | result->src[0] = a; |
| 3355 | |
| 3356 | return result; |
| 3357 | } |
| 3358 | |
| 3359 | struct ggml_tensor * ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).( |
| 3360 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3361 | struct ggml_tensor * a, |
| 3362 | int64_tcxx . . $ int64_t# ne0, |
| 3363 | int64_tcxx . . $ int64_t# ne1, |
| 3364 | int64_tcxx . . $ int64_t# ne2, |
| 3365 | int64_tcxx . . $ int64_t# ne3) { |
| 3366 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 3367 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(a) == ne0*ne1*ne2*ne3); |
| 3368 | |
| 3369 | const int64_tcxx . . $ int64_t# ne[4] = { ne0, ne1, ne2, ne3 }; |
| 3370 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, 4, ne, a, 0); |
| 3371 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (reshaped)", a->name); |
| 3372 | |
| 3373 | result->op = GGML_OP_RESHAPE; |
| 3374 | result->src[0] = a; |
| 3375 | |
| 3376 | return result; |
| 3377 | } |
| 3378 | |
| 3379 | static struct ggml_tensor * ggml_view_implcxx . . $ ggml_view_impl(4c6f6d01f8b9d4c8).( |
| 3380 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3381 | struct ggml_tensor * a, |
| 3382 | int n_dims, |
| 3383 | const int64_tcxx . . $ int64_t# * ne, |
| 3384 | size_t offset) { |
| 3385 | struct ggml_tensor * result = ggml_new_tensor_implcxx . . $ ggml_new_tensor_impl(938ac4e32be56489).(ctx, a->type, n_dims, ne, a, offset); |
| 3386 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (view)", a->name); |
| 3387 | |
| 3388 | ggml_set_op_params(result, &offset, sizeof(offset)); |
| 3389 | |
| 3390 | result->op = GGML_OP_VIEW; |
| 3391 | result->src[0] = a; |
| 3392 | |
| 3393 | return result; |
| 3394 | } |
| 3395 | |
| 3396 | // ggml_view_1d |
| 3397 | |
| 3398 | struct ggml_tensor * ggml_view_1dcxx . . $ ggml_view_1d(e30028e6f7a747a8).( |
| 3399 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3400 | struct ggml_tensor * a, |
| 3401 | int64_tcxx . . $ int64_t# ne0, |
| 3402 | size_t offset) { |
| 3403 | struct ggml_tensor * result = ggml_view_implcxx . . $ ggml_view_impl(4c6f6d01f8b9d4c8).(ctx, a, 1, &ne0, offset); |
| 3404 | |
| 3405 | return result; |
| 3406 | } |
| 3407 | |
| 3408 | // ggml_view_2d |
| 3409 | |
| 3410 | struct ggml_tensor * ggml_view_2dcxx . . $ ggml_view_2d(c44e926b4a3dd0aa).( |
| 3411 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3412 | struct ggml_tensor * a, |
| 3413 | int64_tcxx . . $ int64_t# ne0, |
| 3414 | int64_tcxx . . $ int64_t# ne1, |
| 3415 | size_t nb1, |
| 3416 | size_t offset) { |
| 3417 | const int64_tcxx . . $ int64_t# ne[2] = { ne0, ne1 }; |
| 3418 | |
| 3419 | struct ggml_tensor * result = ggml_view_implcxx . . $ ggml_view_impl(4c6f6d01f8b9d4c8).(ctx, a, 2, ne, offset); |
| 3420 | |
| 3421 | result->nb[1] = nb1; |
| 3422 | result->nb[2] = result->nb[1]*ne1; |
| 3423 | result->nb[3] = result->nb[2]; |
| 3424 | |
| 3425 | return result; |
| 3426 | } |
| 3427 | |
| 3428 | // ggml_view_3d |
| 3429 | |
| 3430 | struct ggml_tensor * ggml_view_3dcxx . . $ ggml_view_3d(b26083a5abd9cbfc).( |
| 3431 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3432 | struct ggml_tensor * a, |
| 3433 | int64_tcxx . . $ int64_t# ne0, |
| 3434 | int64_tcxx . . $ int64_t# ne1, |
| 3435 | int64_tcxx . . $ int64_t# ne2, |
| 3436 | size_t nb1, |
| 3437 | size_t nb2, |
| 3438 | size_t offset) { |
| 3439 | const int64_tcxx . . $ int64_t# ne[3] = { ne0, ne1, ne2 }; |
| 3440 | |
| 3441 | struct ggml_tensor * result = ggml_view_implcxx . . $ ggml_view_impl(4c6f6d01f8b9d4c8).(ctx, a, 3, ne, offset); |
| 3442 | |
| 3443 | result->nb[1] = nb1; |
| 3444 | result->nb[2] = nb2; |
| 3445 | result->nb[3] = result->nb[2]*ne2; |
| 3446 | |
| 3447 | return result; |
| 3448 | } |
| 3449 | |
| 3450 | // ggml_view_4d |
| 3451 | |
| 3452 | struct ggml_tensor * ggml_view_4dcxx . . $ ggml_view_4d(57a2df61c58fa26c).( |
| 3453 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3454 | struct ggml_tensor * a, |
| 3455 | int64_tcxx . . $ int64_t# ne0, |
| 3456 | int64_tcxx . . $ int64_t# ne1, |
| 3457 | int64_tcxx . . $ int64_t# ne2, |
| 3458 | int64_tcxx . . $ int64_t# ne3, |
| 3459 | size_t nb1, |
| 3460 | size_t nb2, |
| 3461 | size_t nb3, |
| 3462 | size_t offset) { |
| 3463 | const int64_tcxx . . $ int64_t# ne[4] = { ne0, ne1, ne2, ne3 }; |
| 3464 | |
| 3465 | struct ggml_tensor * result = ggml_view_implcxx . . $ ggml_view_impl(4c6f6d01f8b9d4c8).(ctx, a, 4, ne, offset); |
| 3466 | |
| 3467 | result->nb[1] = nb1; |
| 3468 | result->nb[2] = nb2; |
| 3469 | result->nb[3] = nb3; |
| 3470 | |
| 3471 | return result; |
| 3472 | } |
| 3473 | |
| 3474 | // ggml_permute |
| 3475 | |
| 3476 | struct ggml_tensor * ggml_permutecxx . . $ ggml_permute(1642edaa96518f7e).( |
| 3477 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3478 | struct ggml_tensor * a, |
| 3479 | int axis0, |
| 3480 | int axis1, |
| 3481 | int axis2, |
| 3482 | int axis3) { |
| 3483 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis0 >= 0 && axis0 < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!); |
| 3484 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis1 >= 0 && axis1 < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!); |
| 3485 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis2 >= 0 && axis2 < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!); |
| 3486 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis3 >= 0 && axis3 < GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!); |
| 3487 | |
| 3488 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis0 != axis1); |
| 3489 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis0 != axis2); |
| 3490 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis0 != axis3); |
| 3491 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis1 != axis2); |
| 3492 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis1 != axis3); |
| 3493 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(axis2 != axis3); |
| 3494 | |
| 3495 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 3496 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (permuted)", a->name); |
| 3497 | |
| 3498 | int ne[GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!]; |
| 3499 | int nb[GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!]; |
| 3500 | |
| 3501 | ne[axis0] = a->ne[0]; |
| 3502 | ne[axis1] = a->ne[1]; |
| 3503 | ne[axis2] = a->ne[2]; |
| 3504 | ne[axis3] = a->ne[3]; |
| 3505 | |
| 3506 | nb[axis0] = a->nb[0]; |
| 3507 | nb[axis1] = a->nb[1]; |
| 3508 | nb[axis2] = a->nb[2]; |
| 3509 | nb[axis3] = a->nb[3]; |
| 3510 | |
| 3511 | result->ne[0] = ne[0]; |
| 3512 | result->ne[1] = ne[1]; |
| 3513 | result->ne[2] = ne[2]; |
| 3514 | result->ne[3] = ne[3]; |
| 3515 | |
| 3516 | result->nb[0] = nb[0]; |
| 3517 | result->nb[1] = nb[1]; |
| 3518 | result->nb[2] = nb[2]; |
| 3519 | result->nb[3] = nb[3]; |
| 3520 | |
| 3521 | result->op = GGML_OP_PERMUTE; |
| 3522 | result->src[0] = a; |
| 3523 | |
| 3524 | int32_tcxx . . $ int32_t# params[] = { axis0, axis1, axis2, axis3 }; |
| 3525 | ggml_set_op_params(result, params, sizeof(params)); |
| 3526 | |
| 3527 | return result; |
| 3528 | } |
| 3529 | |
| 3530 | // ggml_transpose |
| 3531 | |
| 3532 | struct ggml_tensor * ggml_transposecxx . . $ ggml_transpose(71a7fa2ddee25242).( |
| 3533 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3534 | struct ggml_tensor * a) { |
| 3535 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 3536 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(result, "%s (transposed)", a->name); |
| 3537 | |
| 3538 | result->ne[0] = a->ne[1]; |
| 3539 | result->ne[1] = a->ne[0]; |
| 3540 | |
| 3541 | result->nb[0] = a->nb[1]; |
| 3542 | result->nb[1] = a->nb[0]; |
| 3543 | |
| 3544 | result->op = GGML_OP_TRANSPOSE; |
| 3545 | result->src[0] = a; |
| 3546 | |
| 3547 | return result; |
| 3548 | } |
| 3549 | |
| 3550 | // ggml_get_rows |
| 3551 | |
| 3552 | struct ggml_tensor * ggml_get_rowscxx . . $ ggml_get_rows(590e8193bb8aebeb).( |
| 3553 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3554 | struct ggml_tensor * a, |
| 3555 | struct ggml_tensor * b) { |
| 3556 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[1]); |
| 3557 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == b->ne[2]); |
| 3558 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[3] == 1); |
| 3559 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->type == GGML_TYPE_I32); |
| 3560 | |
| 3561 | // TODO: implement non F32 return |
| 3562 | enum ggml_type type = GGML_TYPE_F32; |
| 3563 | if (a->type == GGML_TYPE_I32) { |
| 3564 | type = a->type; |
| 3565 | } |
| 3566 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, type, a->ne[0], b->ne[0], b->ne[1], b->ne[2]); |
| 3567 | |
| 3568 | result->op = GGML_OP_GET_ROWS; |
| 3569 | result->src[0] = a; |
| 3570 | result->src[1] = b; |
| 3571 | |
| 3572 | return result; |
| 3573 | } |
| 3574 | |
| 3575 | // ggml_get_rows_back |
| 3576 | |
| 3577 | struct ggml_tensor * ggml_get_rows_backcxx . . $ ggml_get_rows_back(28fd2ad14bf2989).( |
| 3578 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3579 | struct ggml_tensor * a, |
| 3580 | struct ggml_tensor * b, |
| 3581 | struct ggml_tensor * c) { |
| 3582 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_matrix(a) && ggml_is_vector(b) && b->type == GGML_TYPE_I32); |
| 3583 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_matrix(c) && (a->ne[0] == c->ne[0])); |
| 3584 | |
| 3585 | // TODO: implement non F32 return |
| 3586 | //struct ggml_tensor * result = ggml_new_tensor_2d(ctx, a->type, a->ne[0], b->ne[0]); |
| 3587 | struct ggml_tensor * result = ggml_new_tensor_2dcxx . . $ ggml_new_tensor_2d(7610aad4b808d570).(ctx, GGML_TYPE_F32, c->ne[0], c->ne[1]); |
| 3588 | |
| 3589 | result->op = GGML_OP_GET_ROWS_BACK; |
| 3590 | result->src[0] = a; |
| 3591 | result->src[1] = b; |
| 3592 | |
| 3593 | return result; |
| 3594 | } |
| 3595 | |
| 3596 | // ggml_set_rows |
| 3597 | |
| 3598 | struct ggml_tensor * ggml_set_rowscxx . . $ ggml_set_rows(28fd2ad14bf2989).( |
| 3599 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3600 | struct ggml_tensor * a, |
| 3601 | struct ggml_tensor * b, |
| 3602 | struct ggml_tensor * c) { |
| 3603 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] == b->ne[0]); |
| 3604 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[2]); |
| 3605 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == b->ne[3]); |
| 3606 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[1] == c->ne[0]); |
| 3607 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[2] % c->ne[1] == 0); |
| 3608 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[3] % c->ne[2] == 0); |
| 3609 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(c->ne[3] == 1); |
| 3610 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->type == GGML_TYPE_F32); |
| 3611 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(c->type == GGML_TYPE_I64 || c->type == GGML_TYPE_I32); |
| 3612 | |
| 3613 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous_rows(a)); |
| 3614 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous_rows(b)); |
| 3615 | |
| 3616 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 3617 | |
| 3618 | result->op = GGML_OP_SET_ROWS; |
| 3619 | result->src[0] = b; |
| 3620 | result->src[1] = c; |
| 3621 | result->src[2] = a; // note: order is weird due to legacy reasons (https://github.com/ggml-org/llama.cpp/pull/16063#discussion_r2385795931) |
| 3622 | |
| 3623 | return result; |
| 3624 | } |
| 3625 | |
| 3626 | // ggml_diag |
| 3627 | |
| 3628 | struct ggml_tensor * ggml_diagcxx . . $ ggml_diag(71a7fa2ddee25242).( |
| 3629 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3630 | struct ggml_tensor * a) { |
| 3631 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[1] == 1); |
| 3632 | |
| 3633 | const int64_tcxx . . $ int64_t# ne[4] = { a->ne[0], a->ne[0], a->ne[2], a->ne[3] }; |
| 3634 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, a->type, 4, ne); |
| 3635 | |
| 3636 | result->op = GGML_OP_DIAG; |
| 3637 | result->src[0] = a; |
| 3638 | |
| 3639 | return result; |
| 3640 | } |
| 3641 | |
| 3642 | // ggml_diag_mask_inf |
| 3643 | |
| 3644 | static struct ggml_tensor * ggml_diag_mask_inf_implcxx . . $ ggml_diag_mask_inf_impl(4cd2a9fe5c83eb9e).( |
| 3645 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3646 | struct ggml_tensor * a, |
| 3647 | int n_past, |
| 3648 | bool inplace) { |
| 3649 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3650 | |
| 3651 | int32_tcxx . . $ int32_t# params[] = { n_past }; |
| 3652 | ggml_set_op_params(result, params, sizeof(params)); |
| 3653 | |
| 3654 | result->op = GGML_OP_DIAG_MASK_INF; |
| 3655 | result->src[0] = a; |
| 3656 | |
| 3657 | return result; |
| 3658 | } |
| 3659 | |
| 3660 | struct ggml_tensor * ggml_diag_mask_infcxx . . $ ggml_diag_mask_inf(afdb15e78e46f369).( |
| 3661 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3662 | struct ggml_tensor * a, |
| 3663 | int n_past) { |
| 3664 | return ggml_diag_mask_inf_implcxx . . $ ggml_diag_mask_inf_impl(4cd2a9fe5c83eb9e).(ctx, a, n_past, false); |
| 3665 | } |
| 3666 | |
| 3667 | struct ggml_tensor * ggml_diag_mask_inf_inplacecxx . . $ ggml_diag_mask_inf_inplace(afdb15e78e46f369).( |
| 3668 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3669 | struct ggml_tensor * a, |
| 3670 | int n_past) { |
| 3671 | return ggml_diag_mask_inf_implcxx . . $ ggml_diag_mask_inf_impl(4cd2a9fe5c83eb9e).(ctx, a, n_past, true); |
| 3672 | } |
| 3673 | |
| 3674 | // ggml_diag_mask_zero |
| 3675 | |
| 3676 | static struct ggml_tensor * ggml_diag_mask_zero_implcxx . . $ ggml_diag_mask_zero_impl(4cd2a9fe5c83eb9e).( |
| 3677 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3678 | struct ggml_tensor * a, |
| 3679 | int n_past, |
| 3680 | bool inplace) { |
| 3681 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3682 | |
| 3683 | int32_tcxx . . $ int32_t# params[] = { n_past }; |
| 3684 | ggml_set_op_params(result, params, sizeof(params)); |
| 3685 | |
| 3686 | result->op = GGML_OP_DIAG_MASK_ZERO; |
| 3687 | result->src[0] = a; |
| 3688 | |
| 3689 | return result; |
| 3690 | } |
| 3691 | |
| 3692 | struct ggml_tensor * ggml_diag_mask_zerocxx . . $ ggml_diag_mask_zero(afdb15e78e46f369).( |
| 3693 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3694 | struct ggml_tensor * a, |
| 3695 | int n_past) { |
| 3696 | return ggml_diag_mask_zero_implcxx . . $ ggml_diag_mask_zero_impl(4cd2a9fe5c83eb9e).(ctx, a, n_past, false); |
| 3697 | } |
| 3698 | |
| 3699 | struct ggml_tensor * ggml_diag_mask_zero_inplacecxx . . $ ggml_diag_mask_zero_inplace(afdb15e78e46f369).( |
| 3700 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3701 | struct ggml_tensor * a, |
| 3702 | int n_past) { |
| 3703 | return ggml_diag_mask_zero_implcxx . . $ ggml_diag_mask_zero_impl(4cd2a9fe5c83eb9e).(ctx, a, n_past, true); |
| 3704 | } |
| 3705 | |
| 3706 | // ggml_soft_max |
| 3707 | |
| 3708 | static struct ggml_tensor * ggml_soft_max_implcxx . . $ ggml_soft_max_impl(e30712580c289d39).( |
| 3709 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3710 | struct ggml_tensor * a, |
| 3711 | struct ggml_tensor * mask, |
| 3712 | float scale, |
| 3713 | float max_bias, |
| 3714 | bool inplace) { |
| 3715 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 3716 | |
| 3717 | if (mask) { |
| 3718 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(mask->type == GGML_TYPE_F16 || mask->type == GGML_TYPE_F32); |
| 3719 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(mask)); |
| 3720 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(mask->ne[0] == a->ne[0]); |
| 3721 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(mask->ne[1] >= a->ne[1]); |
| 3722 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2]%mask->ne[2] == 0); |
| 3723 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3]%mask->ne[3] == 0); |
| 3724 | } |
| 3725 | |
| 3726 | if (max_bias > 0.0f) { |
| 3727 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(mask); |
| 3728 | } |
| 3729 | |
| 3730 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3731 | |
| 3732 | float params[] = { scale, max_bias }; |
| 3733 | ggml_set_op_params(result, params, sizeof(params)); |
| 3734 | |
| 3735 | result->op = GGML_OP_SOFT_MAX; |
| 3736 | result->src[0] = a; |
| 3737 | result->src[1] = mask; |
| 3738 | |
| 3739 | return result; |
| 3740 | } |
| 3741 | |
| 3742 | struct ggml_tensor * ggml_soft_maxcxx . . $ ggml_soft_max(71a7fa2ddee25242).( |
| 3743 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3744 | struct ggml_tensor * a) { |
| 3745 | return ggml_soft_max_implcxx . . $ ggml_soft_max_impl(e30712580c289d39).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 1.0f, 0.0f, false); |
| 3746 | } |
| 3747 | |
| 3748 | struct ggml_tensor * ggml_soft_max_inplacecxx . . $ ggml_soft_max_inplace(71a7fa2ddee25242).( |
| 3749 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3750 | struct ggml_tensor * a) { |
| 3751 | return ggml_soft_max_implcxx . . $ ggml_soft_max_impl(e30712580c289d39).(ctx, a, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, 1.0f, 0.0f, true); |
| 3752 | } |
| 3753 | |
| 3754 | struct ggml_tensor * ggml_soft_max_extcxx . . $ ggml_soft_max_ext(815f2d07c0da5a9c).( |
| 3755 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3756 | struct ggml_tensor * a, |
| 3757 | struct ggml_tensor * mask, |
| 3758 | float scale, |
| 3759 | float max_bias) { |
| 3760 | return ggml_soft_max_implcxx . . $ ggml_soft_max_impl(e30712580c289d39).(ctx, a, mask, scale, max_bias, false); |
| 3761 | } |
| 3762 | |
| 3763 | struct ggml_tensor * ggml_soft_max_ext_inplacecxx . . $ ggml_soft_max_ext_inplace(815f2d07c0da5a9c).( |
| 3764 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3765 | struct ggml_tensor * a, |
| 3766 | struct ggml_tensor * mask, |
| 3767 | float scale, |
| 3768 | float max_bias) { |
| 3769 | return ggml_soft_max_implcxx . . $ ggml_soft_max_impl(e30712580c289d39).(ctx, a, mask, scale, max_bias, true); |
| 3770 | } |
| 3771 | |
| 3772 | void ggml_soft_max_add_sinkscxx . . $ ggml_soft_max_add_sinks(d5fccb81be4f727c).( |
| 3773 | struct ggml_tensor * a, |
| 3774 | struct ggml_tensor * sinks) { |
| 3775 | if (!sinks) { |
| 3776 | a->src[2] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 3777 | return; |
| 3778 | } |
| 3779 | |
| 3780 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->op == GGML_OP_SOFT_MAX); |
| 3781 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->src[2] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 3782 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->src[0]->ne[2] == sinks->ne[0]); |
| 3783 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(sinks->type == GGML_TYPE_F32); |
| 3784 | |
| 3785 | a->src[2] = sinks; |
| 3786 | } |
| 3787 | |
| 3788 | // ggml_soft_max_ext_back |
| 3789 | |
| 3790 | static struct ggml_tensor * ggml_soft_max_ext_back_implcxx . . $ ggml_soft_max_ext_back_impl(e30712580c289d39).( |
| 3791 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3792 | struct ggml_tensor * a, |
| 3793 | struct ggml_tensor * b, |
| 3794 | float scale, |
| 3795 | float max_bias, |
| 3796 | bool inplace) { |
| 3797 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3798 | |
| 3799 | result->op = GGML_OP_SOFT_MAX_BACK; |
| 3800 | result->src[0] = a; |
| 3801 | result->src[1] = b; |
| 3802 | |
| 3803 | memcpy((float *) result->op_params + 0, &scale, sizeof(float)); |
| 3804 | memcpy((float *) result->op_params + 1, &max_bias, sizeof(float)); |
| 3805 | |
| 3806 | return result; |
| 3807 | } |
| 3808 | |
| 3809 | struct ggml_tensor * ggml_soft_max_ext_backcxx . . $ ggml_soft_max_ext_back(815f2d07c0da5a9c).( |
| 3810 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3811 | struct ggml_tensor * a, |
| 3812 | struct ggml_tensor * b, |
| 3813 | float scale, |
| 3814 | float max_bias) { |
| 3815 | return ggml_soft_max_ext_back_implcxx . . $ ggml_soft_max_ext_back_impl(e30712580c289d39).(ctx, a, b, scale, max_bias, false); |
| 3816 | } |
| 3817 | |
| 3818 | struct ggml_tensor * ggml_soft_max_ext_back_inplacecxx . . $ ggml_soft_max_ext_back_inplace(815f2d07c0da5a9c).( |
| 3819 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3820 | struct ggml_tensor * a, |
| 3821 | struct ggml_tensor * b, |
| 3822 | float scale, |
| 3823 | float max_bias) { |
| 3824 | return ggml_soft_max_ext_back_implcxx . . $ ggml_soft_max_ext_back_impl(e30712580c289d39).(ctx, a, b, scale, max_bias, true); |
| 3825 | } |
| 3826 | |
| 3827 | // ggml_rope |
| 3828 | |
| 3829 | static struct ggml_tensor * ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3830 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3831 | struct ggml_tensor * a, |
| 3832 | struct ggml_tensor * b, |
| 3833 | struct ggml_tensor * c, |
| 3834 | int n_dims, |
| 3835 | int sections[GGML_MROPE_SECTIONScxx . . $ `external/whispercpp/ggml.h:268:9`!], |
| 3836 | int mode, |
| 3837 | int n_ctx_orig, |
| 3838 | float freq_base, |
| 3839 | float freq_scale, |
| 3840 | float ext_factor, |
| 3841 | float attn_factor, |
| 3842 | float beta_fast, |
| 3843 | float beta_slow, |
| 3844 | bool inplace) { |
| 3845 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((mode & 1) == 0 && "mode & 1 == 1 is no longer supported"); |
| 3846 | |
| 3847 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_vector(b)); |
| 3848 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->type == GGML_TYPE_I32); |
| 3849 | |
| 3850 | bool mrope_used = mode & GGML_ROPE_TYPE_MROPEcxx . . $ `external/whispercpp/ggml.h:264:9`!; |
| 3851 | if (mrope_used) { |
| 3852 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] * 4 == b->ne[0]); // mrope expecting 4 position ids per token |
| 3853 | } else { |
| 3854 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[0]); |
| 3855 | } |
| 3856 | |
| 3857 | if (c) { |
| 3858 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(c->type == GGML_TYPE_F32); |
| 3859 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(c->ne[0] >= n_dims / 2); |
| 3860 | } |
| 3861 | |
| 3862 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 3863 | |
| 3864 | int32_tcxx . . $ int32_t# params[15] = { /*n_past*/ 0, n_dims, mode, /*n_ctx*/ 0, n_ctx_orig }; |
| 3865 | memcpy(params + 5, &freq_base, sizeof(float)); |
| 3866 | memcpy(params + 6, &freq_scale, sizeof(float)); |
| 3867 | memcpy(params + 7, &ext_factor, sizeof(float)); |
| 3868 | memcpy(params + 8, &attn_factor, sizeof(float)); |
| 3869 | memcpy(params + 9, &beta_fast, sizeof(float)); |
| 3870 | memcpy(params + 10, &beta_slow, sizeof(float)); |
| 3871 | if (mrope_used && sections) { |
| 3872 | memcpy(params + 11, sections, sizeof(int32_tcxx . . $ int32_t#) * GGML_MROPE_SECTIONScxx . . $ `external/whispercpp/ggml.h:268:9`!); |
| 3873 | } else { |
| 3874 | memset(params + 11, 0, sizeof(int32_tcxx . . $ int32_t#) * GGML_MROPE_SECTIONScxx . . $ `external/whispercpp/ggml.h:268:9`!); |
| 3875 | } |
| 3876 | ggml_set_op_params(result, params, sizeof(params)); |
| 3877 | |
| 3878 | result->op = GGML_OP_ROPE; |
| 3879 | result->src[0] = a; |
| 3880 | result->src[1] = b; |
| 3881 | result->src[2] = c; |
| 3882 | |
| 3883 | return result; |
| 3884 | } |
| 3885 | |
| 3886 | struct ggml_tensor * ggml_ropecxx . . $ ggml_rope(6311a8bd444a2dee).( |
| 3887 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3888 | struct ggml_tensor * a, |
| 3889 | struct ggml_tensor * b, |
| 3890 | int n_dims, |
| 3891 | int mode) { |
| 3892 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3893 | ctx, a, b, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, n_dims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mode, 0, 10000.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, false |
| 3894 | ); |
| 3895 | } |
| 3896 | |
| 3897 | struct ggml_tensor * ggml_rope_multicxx . . $ ggml_rope_multi(f619456346d7ed7e).( |
| 3898 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3899 | struct ggml_tensor * a, |
| 3900 | struct ggml_tensor * b, |
| 3901 | struct ggml_tensor * c, |
| 3902 | int n_dims, |
| 3903 | int sections[GGML_MROPE_SECTIONScxx . . $ `external/whispercpp/ggml.h:268:9`!], |
| 3904 | int mode, |
| 3905 | int n_ctx_orig, |
| 3906 | float freq_base, |
| 3907 | float freq_scale, |
| 3908 | float ext_factor, |
| 3909 | float attn_factor, |
| 3910 | float beta_fast, |
| 3911 | float beta_slow) { |
| 3912 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3913 | ctx, a, b, c, n_dims, sections, mode, n_ctx_orig, freq_base, freq_scale, |
| 3914 | ext_factor, attn_factor, beta_fast, beta_slow, false |
| 3915 | ); |
| 3916 | } |
| 3917 | |
| 3918 | struct ggml_tensor * ggml_rope_multi_inplacecxx . . $ ggml_rope_multi_inplace(f619456346d7ed7e).( |
| 3919 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3920 | struct ggml_tensor * a, |
| 3921 | struct ggml_tensor * b, |
| 3922 | struct ggml_tensor * c, |
| 3923 | int n_dims, |
| 3924 | int sections[GGML_MROPE_SECTIONScxx . . $ `external/whispercpp/ggml.h:268:9`!], |
| 3925 | int mode, |
| 3926 | int n_ctx_orig, |
| 3927 | float freq_base, |
| 3928 | float freq_scale, |
| 3929 | float ext_factor, |
| 3930 | float attn_factor, |
| 3931 | float beta_fast, |
| 3932 | float beta_slow) { |
| 3933 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3934 | ctx, a, b, c, n_dims, sections, mode, n_ctx_orig, freq_base, freq_scale, |
| 3935 | ext_factor, attn_factor, beta_fast, beta_slow, true |
| 3936 | ); |
| 3937 | } |
| 3938 | |
| 3939 | struct ggml_tensor * ggml_rope_inplacecxx . . $ ggml_rope_inplace(6311a8bd444a2dee).( |
| 3940 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3941 | struct ggml_tensor * a, |
| 3942 | struct ggml_tensor * b, |
| 3943 | int n_dims, |
| 3944 | int mode) { |
| 3945 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3946 | ctx, a, b, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, n_dims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mode, 0, 10000.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, true |
| 3947 | ); |
| 3948 | } |
| 3949 | |
| 3950 | struct ggml_tensor * ggml_rope_extcxx . . $ ggml_rope_ext(da69a26837edcf2d).( |
| 3951 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3952 | struct ggml_tensor * a, |
| 3953 | struct ggml_tensor * b, |
| 3954 | struct ggml_tensor * c, |
| 3955 | int n_dims, |
| 3956 | int mode, |
| 3957 | int n_ctx_orig, |
| 3958 | float freq_base, |
| 3959 | float freq_scale, |
| 3960 | float ext_factor, |
| 3961 | float attn_factor, |
| 3962 | float beta_fast, |
| 3963 | float beta_slow) { |
| 3964 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3965 | ctx, a, b, c, n_dims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mode, n_ctx_orig, freq_base, freq_scale, |
| 3966 | ext_factor, attn_factor, beta_fast, beta_slow, false |
| 3967 | ); |
| 3968 | } |
| 3969 | |
| 3970 | struct ggml_tensor * ggml_rope_ext_inplacecxx . . $ ggml_rope_ext_inplace(da69a26837edcf2d).( |
| 3971 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3972 | struct ggml_tensor * a, |
| 3973 | struct ggml_tensor * b, |
| 3974 | struct ggml_tensor * c, |
| 3975 | int n_dims, |
| 3976 | int mode, |
| 3977 | int n_ctx_orig, |
| 3978 | float freq_base, |
| 3979 | float freq_scale, |
| 3980 | float ext_factor, |
| 3981 | float attn_factor, |
| 3982 | float beta_fast, |
| 3983 | float beta_slow) { |
| 3984 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 3985 | ctx, a, b, c, n_dims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mode, n_ctx_orig, freq_base, freq_scale, |
| 3986 | ext_factor, attn_factor, beta_fast, beta_slow, true |
| 3987 | ); |
| 3988 | } |
| 3989 | |
| 3990 | struct ggml_tensor * ggml_rope_customcxx . . $ ggml_rope_custom(59cfd76bdaa84d5c).( |
| 3991 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 3992 | struct ggml_tensor * a, |
| 3993 | struct ggml_tensor * b, |
| 3994 | int n_dims, |
| 3995 | int mode, |
| 3996 | int n_ctx_orig, |
| 3997 | float freq_base, |
| 3998 | float freq_scale, |
| 3999 | float ext_factor, |
| 4000 | float attn_factor, |
| 4001 | float beta_fast, |
| 4002 | float beta_slow) { |
| 4003 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 4004 | ctx, a, b, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, n_dims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mode, n_ctx_orig, freq_base, freq_scale, |
| 4005 | ext_factor, attn_factor, beta_fast, beta_slow, false |
| 4006 | ); |
| 4007 | } |
| 4008 | |
| 4009 | struct ggml_tensor * ggml_rope_custom_inplacecxx . . $ ggml_rope_custom_inplace(59cfd76bdaa84d5c).( |
| 4010 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4011 | struct ggml_tensor * a, |
| 4012 | struct ggml_tensor * b, |
| 4013 | int n_dims, |
| 4014 | int mode, |
| 4015 | int n_ctx_orig, |
| 4016 | float freq_base, |
| 4017 | float freq_scale, |
| 4018 | float ext_factor, |
| 4019 | float attn_factor, |
| 4020 | float beta_fast, |
| 4021 | float beta_slow) { |
| 4022 | return ggml_rope_implcxx . . $ ggml_rope_impl(cd8ce94356e6e7aa).( |
| 4023 | ctx, a, b, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, n_dims, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, mode, n_ctx_orig, freq_base, freq_scale, |
| 4024 | ext_factor, attn_factor, beta_fast, beta_slow, true |
| 4025 | ); |
| 4026 | } |
| 4027 | |
| 4028 | // Apparently solving `n_rot = 2pi * x * base^((2 * max_pos_emb) / n_dims)` for x, we get |
| 4029 | // `corr_dim(n_rot) = n_dims * log(max_pos_emb / (n_rot * 2pi)) / (2 * log(base))` |
| 4030 | static float ggml_rope_yarn_corr_dimcxx . . $ ggml_rope_yarn_corr_dim(d287910fd745093b).(int n_dims, int n_ctx_orig, float n_rot, float base) { |
| 4031 | return n_dims * logf(n_ctx_orig / (n_rot * 2 * (float)M_PIcxx . . $ `melder/NUMmath.h:48:9`!)) / (2 * logf(base)); |
| 4032 | } |
| 4033 | |
| 4034 | void ggml_rope_yarn_corr_dimscxx . . $ ggml_rope_yarn_corr_dims(753695b26c34e75b).( |
| 4035 | int n_dims, int n_ctx_orig, float freq_base, float beta_fast, float beta_slow, float dims[2] |
| 4036 | ) { |
| 4037 | // start and end correction dims |
| 4038 | float start = floorf(ggml_rope_yarn_corr_dimcxx . . $ ggml_rope_yarn_corr_dim(d287910fd745093b).(n_dims, n_ctx_orig, beta_fast, freq_base)); |
| 4039 | float end = ceilf(ggml_rope_yarn_corr_dimcxx . . $ ggml_rope_yarn_corr_dim(d287910fd745093b).(n_dims, n_ctx_orig, beta_slow, freq_base)); |
| 4040 | dims[0] = MAXcxx . . $ `external/whispercpp/ggml-impl.h:38:13`!(0, start); |
| 4041 | dims[1] = MINcxx . . $ `external/whispercpp/ggml-impl.h:34:13`!(n_dims - 1, end); |
| 4042 | } |
| 4043 | |
| 4044 | // ggml_rope_back |
| 4045 | |
| 4046 | struct ggml_tensor * ggml_rope_ext_backcxx . . $ ggml_rope_ext_back(da69a26837edcf2d).( |
| 4047 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4048 | struct ggml_tensor * a, |
| 4049 | struct ggml_tensor * b, |
| 4050 | struct ggml_tensor * c, |
| 4051 | int n_dims, |
| 4052 | int mode, |
| 4053 | int n_ctx_orig, |
| 4054 | float freq_base, |
| 4055 | float freq_scale, |
| 4056 | float ext_factor, |
| 4057 | float attn_factor, |
| 4058 | float beta_fast, |
| 4059 | float beta_slow) { |
| 4060 | struct ggml_tensor * result = ggml_rope_extcxx . . $ ggml_rope_ext(da69a26837edcf2d).( |
| 4061 | ctx, a, b, c, n_dims, mode, n_ctx_orig, freq_base, freq_scale, ext_factor, attn_factor, beta_fast, beta_slow); |
| 4062 | result->op = GGML_OP_ROPE_BACK; |
| 4063 | return result; |
| 4064 | } |
| 4065 | |
| 4066 | struct ggml_tensor * ggml_rope_multi_backcxx . . $ ggml_rope_multi_back(f619456346d7ed7e).( |
| 4067 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4068 | struct ggml_tensor * a, |
| 4069 | struct ggml_tensor * b, |
| 4070 | struct ggml_tensor * c, |
| 4071 | int n_dims, |
| 4072 | int sections[4], |
| 4073 | int mode, |
| 4074 | int n_ctx_orig, |
| 4075 | float freq_base, |
| 4076 | float freq_scale, |
| 4077 | float ext_factor, |
| 4078 | float attn_factor, |
| 4079 | float beta_fast, |
| 4080 | float beta_slow) { |
| 4081 | struct ggml_tensor * result = ggml_rope_multicxx . . $ ggml_rope_multi(f619456346d7ed7e).( |
| 4082 | ctx, a, b, c, n_dims, sections, mode, n_ctx_orig, freq_base, freq_scale, ext_factor, attn_factor, beta_fast, beta_slow); |
| 4083 | result->op = GGML_OP_ROPE_BACK; |
| 4084 | return result; |
| 4085 | } |
| 4086 | // ggml_clamp |
| 4087 | |
| 4088 | struct ggml_tensor * ggml_clampcxx . . $ ggml_clamp(a7d32b7035d2f05b).( |
| 4089 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4090 | struct ggml_tensor * a, |
| 4091 | float min, |
| 4092 | float max) { |
| 4093 | // TODO: when implement backward, fix this: |
| 4094 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 4095 | |
| 4096 | float params[] = { min, max }; |
| 4097 | ggml_set_op_params(result, params, sizeof(params)); |
| 4098 | |
| 4099 | result->op = GGML_OP_CLAMP; |
| 4100 | result->src[0] = a; |
| 4101 | |
| 4102 | return result; |
| 4103 | } |
| 4104 | |
| 4105 | static int64_tcxx . . $ int64_t# ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(int64_tcxx . . $ int64_t# ins, int64_tcxx . . $ int64_t# ks, int s, int p, int d) { |
| 4106 | return (ins + 2 * p - d * (ks - 1) - 1) / s + 1; |
| 4107 | } |
| 4108 | |
| 4109 | // im2col: [N, IC, IH, IW] => [N, OH, OW, IC*KH*KW] |
| 4110 | // a: [OC,IC, KH, KW] |
| 4111 | // b: [N, IC, IH, IW] |
| 4112 | // result: [N, OH, OW, IC*KH*KW] |
| 4113 | struct ggml_tensor * ggml_im2colcxx . . $ ggml_im2col(8e400c440500e946).( |
| 4114 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4115 | struct ggml_tensor * a, |
| 4116 | struct ggml_tensor * b, |
| 4117 | int s0, |
| 4118 | int s1, |
| 4119 | int p0, |
| 4120 | int p1, |
| 4121 | int d0, |
| 4122 | int d1, |
| 4123 | bool is_2D, |
| 4124 | enum ggml_type dst_type) { |
| 4125 | if (is_2D) { |
| 4126 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[2]); |
| 4127 | } else { |
| 4128 | //GGML_ASSERT(b->ne[1] % a->ne[1] == 0); |
| 4129 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[1] == a->ne[1]); |
| 4130 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[3] == 1); |
| 4131 | } |
| 4132 | |
| 4133 | const int64_tcxx . . $ int64_t# OH = is_2D ? ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[1], a->ne[1], s1, p1, d1) : 0; |
| 4134 | const int64_tcxx . . $ int64_t# OW = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[0], a->ne[0], s0, p0, d0); |
| 4135 | |
| 4136 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((!is_2D || OH > 0) && "b too small compared to a"); |
| 4137 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((OW > 0) && "b too small compared to a"); |
| 4138 | |
| 4139 | const int64_tcxx . . $ int64_t# ne[4] = { |
| 4140 | is_2D ? (a->ne[2] * a->ne[1] * a->ne[0]) : a->ne[1] * a->ne[0], |
| 4141 | OW, |
| 4142 | is_2D ? OH : b->ne[2], |
| 4143 | is_2D ? b->ne[3] : 1, |
| 4144 | }; |
| 4145 | |
| 4146 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, dst_type, 4, ne); |
| 4147 | int32_tcxx . . $ int32_t# params[] = { s0, s1, p0, p1, d0, d1, (is_2D ? 1 : 0) }; |
| 4148 | ggml_set_op_params(result, params, sizeof(params)); |
| 4149 | |
| 4150 | result->op = GGML_OP_IM2COL; |
| 4151 | result->src[0] = a; |
| 4152 | result->src[1] = b; |
| 4153 | |
| 4154 | return result; |
| 4155 | } |
| 4156 | |
| 4157 | struct ggml_tensor * ggml_im2col_backcxx . . $ ggml_im2col_back(e0dc01b407788623).( |
| 4158 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4159 | struct ggml_tensor * a, |
| 4160 | struct ggml_tensor * b, |
| 4161 | int64_tcxx . . $ int64_t# * ne, |
| 4162 | int s0, |
| 4163 | int s1, |
| 4164 | int p0, |
| 4165 | int p1, |
| 4166 | int d0, |
| 4167 | int d1, |
| 4168 | bool is_2D) { |
| 4169 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 4170 | int32_tcxx . . $ int32_t# params[] = { s0, s1, p0, p1, d0, d1, (is_2D ? 1 : 0) }; |
| 4171 | ggml_set_op_params(result, params, sizeof(params)); |
| 4172 | |
| 4173 | result->op = GGML_OP_IM2COL_BACK; |
| 4174 | result->src[0] = a; |
| 4175 | result->src[1] = b; |
| 4176 | |
| 4177 | return result; |
| 4178 | } |
| 4179 | |
| 4180 | // ggml_conv_1d |
| 4181 | |
| 4182 | struct ggml_tensor * ggml_conv_1dcxx . . $ ggml_conv_1d(8784f8cdaed3b4fd).( |
| 4183 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4184 | struct ggml_tensor * a, |
| 4185 | struct ggml_tensor * b, |
| 4186 | int s0, |
| 4187 | int p0, |
| 4188 | int d0) { |
| 4189 | struct ggml_tensor * im2col = ggml_im2colcxx . . $ ggml_im2col(8e400c440500e946).(ctx, a, b, s0, 0, p0, 0, d0, 0, false, GGML_TYPE_F16); // [N, OL, IC * K] |
| 4190 | |
| 4191 | struct ggml_tensor * result = |
| 4192 | ggml_mul_matcxx . . $ ggml_mul_mat(590e8193bb8aebeb).(ctx, |
| 4193 | ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).(ctx, im2col, im2col->ne[0], (im2col->ne[2] * im2col->ne[1])), // [N, OL, IC * K] => [N*OL, IC * K] |
| 4194 | ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).(ctx, a, (a->ne[0] * a->ne[1]), a->ne[2])); // [OC,IC, K] => [OC, IC * K] |
| 4195 | |
| 4196 | result = ggml_reshape_3dcxx . . $ ggml_reshape_3d(67a16a7d20b25b94).(ctx, result, im2col->ne[1], a->ne[2], im2col->ne[2]); // [N, OC, OL] |
| 4197 | |
| 4198 | return result; |
| 4199 | } |
| 4200 | |
| 4201 | // ggml_conv_1d_ph |
| 4202 | |
| 4203 | struct ggml_tensor* ggml_conv_1d_phcxx . . $ ggml_conv_1d_ph(6311a8bd444a2dee).( |
| 4204 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4205 | struct ggml_tensor * a, |
| 4206 | struct ggml_tensor * b, |
| 4207 | int s, |
| 4208 | int d) { |
| 4209 | return ggml_conv_1dcxx . . $ ggml_conv_1d(8784f8cdaed3b4fd).(ctx, a, b, s, a->ne[0] / 2, d); |
| 4210 | } |
| 4211 | |
| 4212 | // ggml_conv_1d_dw |
| 4213 | |
| 4214 | struct ggml_tensor * ggml_conv_1d_dwcxx . . $ ggml_conv_1d_dw(8784f8cdaed3b4fd).( |
| 4215 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4216 | struct ggml_tensor * a, |
| 4217 | struct ggml_tensor * b, |
| 4218 | int s0, |
| 4219 | int p0, |
| 4220 | int d0) { |
| 4221 | struct ggml_tensor * new_b = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, b, b->ne[0], 1, b->ne[1], b->ne[2]); |
| 4222 | |
| 4223 | struct ggml_tensor * im2col = ggml_im2colcxx . . $ ggml_im2col(8e400c440500e946).(ctx, a, new_b, s0, 0, p0, 0, d0, 0, false, GGML_TYPE_F16); |
| 4224 | |
| 4225 | struct ggml_tensor * result = ggml_mul_matcxx . . $ ggml_mul_mat(590e8193bb8aebeb).(ctx, im2col, a); |
| 4226 | |
| 4227 | result = ggml_reshape_3dcxx . . $ ggml_reshape_3d(67a16a7d20b25b94).(ctx, result, result->ne[0], result->ne[2], 1); |
| 4228 | |
| 4229 | return result; |
| 4230 | } |
| 4231 | |
| 4232 | // ggml_conv_1d_dw_ph |
| 4233 | |
| 4234 | struct ggml_tensor * ggml_conv_1d_dw_phcxx . . $ ggml_conv_1d_dw_ph(6311a8bd444a2dee).( |
| 4235 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4236 | struct ggml_tensor * a, |
| 4237 | struct ggml_tensor * b, |
| 4238 | int s0, |
| 4239 | int d0) { |
| 4240 | return ggml_conv_1d_dwcxx . . $ ggml_conv_1d_dw(8784f8cdaed3b4fd).(ctx, a, b, s0, a->ne[0] / 2, d0); |
| 4241 | } |
| 4242 | |
| 4243 | // ggml_conv_transpose_1d |
| 4244 | |
| 4245 | static int64_tcxx . . $ int64_t# ggml_calc_conv_transpose_1d_output_sizecxx . . $ ggml_calc_conv_transpose_1d_output_size(5da3564e4df29932).(int64_tcxx . . $ int64_t# ins, int64_tcxx . . $ int64_t# ks, int s, int p, int d) { |
| 4246 | return (ins - 1) * s - 2 * p + d * (ks - 1) + 1; |
| 4247 | } |
| 4248 | |
| 4249 | GGML_APIcxx . . $ `external/whispercpp/ggml.h:199:13`! struct ggml_tensor * ggml_conv_transpose_1dcxx . . $ ggml_conv_transpose_1d(8784f8cdaed3b4fd).( |
| 4250 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4251 | struct ggml_tensor * a, |
| 4252 | struct ggml_tensor * b, |
| 4253 | int s0, |
| 4254 | int p0, |
| 4255 | int d0) { |
| 4256 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_matrix(b)); |
| 4257 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[1]); |
| 4258 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == 1); |
| 4259 | |
| 4260 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(p0 == 0); |
| 4261 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(d0 == 1); |
| 4262 | |
| 4263 | const int64_tcxx . . $ int64_t# ne[4] = { |
| 4264 | ggml_calc_conv_transpose_1d_output_sizecxx . . $ ggml_calc_conv_transpose_1d_output_size(5da3564e4df29932).(b->ne[0], a->ne[0], s0, 0 /*p0*/, 1 /*d0*/), |
| 4265 | a->ne[1], b->ne[2], 1, |
| 4266 | }; |
| 4267 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 4268 | |
| 4269 | int32_tcxx . . $ int32_t# params[] = { s0, p0, d0 }; |
| 4270 | ggml_set_op_params(result, params, sizeof(params)); |
| 4271 | |
| 4272 | result->op = GGML_OP_CONV_TRANSPOSE_1D; |
| 4273 | result->src[0] = a; |
| 4274 | result->src[1] = b; |
| 4275 | |
| 4276 | return result; |
| 4277 | } |
| 4278 | |
| 4279 | // ggml_conv_2d |
| 4280 | |
| 4281 | // a: [OC,IC, KH, KW] |
| 4282 | // b: [N, IC, IH, IW] |
| 4283 | // result: [N, OC, OH, OW] |
| 4284 | struct ggml_tensor * ggml_conv_2dcxx . . $ ggml_conv_2d(ecc0ee37449ef42b).( |
| 4285 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4286 | struct ggml_tensor * a, |
| 4287 | struct ggml_tensor * b, |
| 4288 | int s0, |
| 4289 | int s1, |
| 4290 | int p0, |
| 4291 | int p1, |
| 4292 | int d0, |
| 4293 | int d1) { |
| 4294 | struct ggml_tensor * im2col = ggml_im2colcxx . . $ ggml_im2col(8e400c440500e946).(ctx, a, b, s0, s1, p0, p1, d0, d1, true, a->type); // [N, OH, OW, IC * KH * KW] |
| 4295 | |
| 4296 | struct ggml_tensor * result = |
| 4297 | ggml_mul_matcxx . . $ ggml_mul_mat(590e8193bb8aebeb).(ctx, |
| 4298 | ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).(ctx, im2col, im2col->ne[0], im2col->ne[3] * im2col->ne[2] * im2col->ne[1]), // [N, OH, OW, IC * KH * KW] => [N*OH*OW, IC * KH * KW] |
| 4299 | ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).(ctx, a, (a->ne[0] * a->ne[1] * a->ne[2]), a->ne[3])); // [OC,IC, KH, KW] => [OC, IC * KH * KW] |
| 4300 | |
| 4301 | result = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, result, im2col->ne[1], im2col->ne[2], im2col->ne[3], a->ne[3]); // [OC, N, OH, OW] |
| 4302 | result = ggml_contcxx . . $ ggml_cont(71a7fa2ddee25242).(ctx, ggml_permutecxx . . $ ggml_permute(1642edaa96518f7e).(ctx, result, 0, 1, 3, 2)); // [N, OC, OH, OW] |
| 4303 | |
| 4304 | |
| 4305 | return result; |
| 4306 | } |
| 4307 | |
| 4308 | // a: [OC*IC, KD, KH, KW] |
| 4309 | // b: [N*IC, ID, IH, IW] |
| 4310 | // result: [N*OD, OH, OW, IC * KD * KH * KW] |
| 4311 | struct ggml_tensor * ggml_im2col_3dcxx . . $ ggml_im2col_3d(7c40e73d7674b1bb).( |
| 4312 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4313 | struct ggml_tensor * a, |
| 4314 | struct ggml_tensor * b, |
| 4315 | int64_tcxx . . $ int64_t# IC, |
| 4316 | int s0, // stride width |
| 4317 | int s1, // stride height |
| 4318 | int s2, // stride depth |
| 4319 | int p0, // padding width |
| 4320 | int p1, // padding height |
| 4321 | int p2, // padding depth |
| 4322 | int d0, // dilation width |
| 4323 | int d1, // dilation height |
| 4324 | int d2, // dilation depth |
| 4325 | enum ggml_type dst_type) { |
| 4326 | const int64_tcxx . . $ int64_t# N = b->ne[3] / IC; |
| 4327 | const int64_tcxx . . $ int64_t# ID = b->ne[2]; |
| 4328 | const int64_tcxx . . $ int64_t# IH = b->ne[1]; |
| 4329 | const int64_tcxx . . $ int64_t# IW = b->ne[0]; |
| 4330 | |
| 4331 | const int64_tcxx . . $ int64_t# OC = a->ne[3] / IC; |
| 4332 | UNUSEDcxx . . $ `external/whispercpp/ggml.cpp:57:9`!(OC); |
| 4333 | const int64_tcxx . . $ int64_t# KD = a->ne[2]; |
| 4334 | const int64_tcxx . . $ int64_t# KH = a->ne[1]; |
| 4335 | const int64_tcxx . . $ int64_t# KW = a->ne[0]; |
| 4336 | const int64_tcxx . . $ int64_t# OD = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(ID, KD, s2, p2, d2); |
| 4337 | const int64_tcxx . . $ int64_t# OH = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(IH, KH, s1, p1, d1); |
| 4338 | const int64_tcxx . . $ int64_t# OW = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(IW, KW, s0, p0, d0); |
| 4339 | |
| 4340 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((OD > 0) && "b too small compared to a"); |
| 4341 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((OH > 0) && "b too small compared to a"); |
| 4342 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((OW > 0) && "b too small compared to a"); |
| 4343 | |
| 4344 | |
| 4345 | const int64_tcxx . . $ int64_t# ne[4] = {KW*KH*KD*IC, OW, OH, OD*N}; |
| 4346 | |
| 4347 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, dst_type, 4, ne); |
| 4348 | int32_tcxx . . $ int32_t# params[] = { s0, s1, s2, p0, p1, p2, d0, d1, d2, (int32_tcxx . . $ int32_t#)IC}; |
| 4349 | ggml_set_op_params(result, params, sizeof(params)); |
| 4350 | |
| 4351 | result->op = GGML_OP_IM2COL_3D; |
| 4352 | result->src[0] = a; |
| 4353 | result->src[1] = b; |
| 4354 | |
| 4355 | return result; |
| 4356 | } |
| 4357 | |
| 4358 | // a: [OC*IC, KD, KH, KW] |
| 4359 | // b: [N*IC, ID, IH, IW] |
| 4360 | // result: [N*OC, OD, OH, OW] |
| 4361 | struct ggml_tensor * ggml_conv_3dcxx . . $ ggml_conv_3d(6ca6df5770eb4e7e).( |
| 4362 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4363 | struct ggml_tensor * a, |
| 4364 | struct ggml_tensor * b, |
| 4365 | int64_tcxx . . $ int64_t# IC, |
| 4366 | int s0, // stride width |
| 4367 | int s1, // stride height |
| 4368 | int s2, // stride depth |
| 4369 | int p0, // padding width |
| 4370 | int p1, // padding height |
| 4371 | int p2, // padding depth |
| 4372 | int d0, // dilation width |
| 4373 | int d1, // dilation height |
| 4374 | int d2 // dilation depth |
| 4375 | ) { |
| 4376 | struct ggml_tensor * im2col = ggml_im2col_3dcxx . . $ ggml_im2col_3d(7c40e73d7674b1bb).(ctx, a, b, IC, s0, s1, s2, p0, p1, p2, d0, d1, d2, a->type); // [N*OD, OH, OW, IC * KD * KH * KW] |
| 4377 | |
| 4378 | int64_tcxx . . $ int64_t# OC = a->ne[3] / IC; |
| 4379 | int64_tcxx . . $ int64_t# N = b->ne[3] / IC; |
| 4380 | struct ggml_tensor * result = |
| 4381 | ggml_mul_matcxx . . $ ggml_mul_mat(590e8193bb8aebeb).(ctx, |
| 4382 | ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).(ctx, im2col, im2col->ne[0], im2col->ne[3] * im2col->ne[2] * im2col->ne[1]), // [N*OD, OH, OW, IC * KD * KH * KW] => [N*OD*OH*OW, IC * KD * KH * KW] |
| 4383 | ggml_reshape_2dcxx . . $ ggml_reshape_2d(a8ad33b92c65ec1c).(ctx, a, (a->ne[0] * a->ne[1] * a->ne[2] * IC), OC)); // [OC*IC, KD, KH, KW] => [OC, IC * KD * KH * KW] |
| 4384 | |
| 4385 | int64_tcxx . . $ int64_t# OD = im2col->ne[3] / N; |
| 4386 | result = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, result, im2col->ne[1]*im2col->ne[2], OD, N, OC); // [OC, N*OD*OH*OW] => [OC, N, OD, OH*OW] |
| 4387 | result = ggml_contcxx . . $ ggml_cont(71a7fa2ddee25242).(ctx, ggml_permutecxx . . $ ggml_permute(1642edaa96518f7e).(ctx, result, 0, 1, 3, 2)); // [N, OC, OD, OH*OW] |
| 4388 | result = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, result, im2col->ne[1], im2col->ne[2], OD, OC * N); // [N*OC, OD, OH, OW] |
| 4389 | |
| 4390 | return result; |
| 4391 | } |
| 4392 | |
| 4393 | // ggml_conv_2d_sk_p0 |
| 4394 | |
| 4395 | struct ggml_tensor * ggml_conv_2d_sk_p0cxx . . $ ggml_conv_2d_sk_p0(590e8193bb8aebeb).( |
| 4396 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4397 | struct ggml_tensor * a, |
| 4398 | struct ggml_tensor * b) { |
| 4399 | return ggml_conv_2dcxx . . $ ggml_conv_2d(ecc0ee37449ef42b).(ctx, a, b, a->ne[0], a->ne[1], 0, 0, 1, 1); |
| 4400 | } |
| 4401 | |
| 4402 | // ggml_conv_2d_s1_ph |
| 4403 | |
| 4404 | struct ggml_tensor * ggml_conv_2d_s1_phcxx . . $ ggml_conv_2d_s1_ph(590e8193bb8aebeb).( |
| 4405 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4406 | struct ggml_tensor * a, |
| 4407 | struct ggml_tensor * b) { |
| 4408 | return ggml_conv_2dcxx . . $ ggml_conv_2d(ecc0ee37449ef42b).(ctx, a, b, 1, 1, a->ne[0] / 2, a->ne[1] / 2, 1, 1); |
| 4409 | } |
| 4410 | |
| 4411 | // ggml_conv_2d_dw |
| 4412 | |
| 4413 | struct ggml_tensor * ggml_conv_2d_dwcxx . . $ ggml_conv_2d_dw(ecc0ee37449ef42b).( |
| 4414 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4415 | struct ggml_tensor * a, |
| 4416 | struct ggml_tensor * b, |
| 4417 | int s0, |
| 4418 | int s1, |
| 4419 | int p0, |
| 4420 | int p1, |
| 4421 | int d0, |
| 4422 | int d1) { |
| 4423 | struct ggml_tensor * new_a = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, a, a->ne[0], a->ne[1], 1, a->ne[2] * a->ne[3]); |
| 4424 | struct ggml_tensor * im2col = ggml_im2colcxx . . $ ggml_im2col(8e400c440500e946).(ctx, new_a, |
| 4425 | ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, b, b->ne[0], b->ne[1], 1, b->ne[2] * b->ne[3]), |
| 4426 | s0, s1, p0, p1, d0, d1, true, GGML_TYPE_F16); // [N * IC, OH, OW, KH * KW] |
| 4427 | struct ggml_tensor * new_b = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, im2col, im2col->ne[0], im2col->ne[2] * im2col->ne[1], b->ne[2], b->ne[3]); // [N * IC, OH, OW, KH * KW] => [N, IC, OH * OW, KH * KW] |
| 4428 | |
| 4429 | new_a = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, new_a, (new_a->ne[0] * new_a->ne[1]), new_a->ne[2], new_a->ne[3], 1); // [OC,1, KH, KW] => [1, OC, 1, KH * KW] |
| 4430 | struct ggml_tensor * result = ggml_mul_matcxx . . $ ggml_mul_mat(590e8193bb8aebeb).(ctx, new_a, new_b); |
| 4431 | result = ggml_reshape_4dcxx . . $ ggml_reshape_4d(35a4bd770d1e0c77).(ctx, result, im2col->ne[1], im2col->ne[2], b->ne[2], b->ne[3]); // [N, OC, OH, OW] |
| 4432 | |
| 4433 | return result; |
| 4434 | } |
| 4435 | |
| 4436 | // ggml_conv_2d_dw_direct |
| 4437 | |
| 4438 | struct ggml_tensor * ggml_conv_2d_dw_directcxx . . $ ggml_conv_2d_dw_direct(ecc0ee37449ef42b).( |
| 4439 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4440 | struct ggml_tensor * a, |
| 4441 | struct ggml_tensor * b, |
| 4442 | int stride0, |
| 4443 | int stride1, |
| 4444 | int pad0, |
| 4445 | int pad1, |
| 4446 | int dilation0, |
| 4447 | int dilation1) { |
| 4448 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == 1); |
| 4449 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == b->ne[2]); |
| 4450 | int64_tcxx . . $ int64_t# ne[4]; |
| 4451 | ne[0] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[0], a->ne[0], stride0, pad0, dilation0); |
| 4452 | ne[1] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[1], a->ne[1], stride1, pad1, dilation1); |
| 4453 | ne[2] = b->ne[2]; |
| 4454 | ne[3] = b->ne[3]; |
| 4455 | |
| 4456 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, b->type, 4, ne); |
| 4457 | |
| 4458 | if (ggml_is_contiguous_channelscxx . . $ ggml_is_contiguous_channels(8fa73a561a000eab).(b)) { |
| 4459 | // Result will be permuted the same way as input (CWHN order) |
| 4460 | const int64_tcxx . . $ int64_t# type_size = ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(result->type); |
| 4461 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_blck_size(result->type) == 1); |
| 4462 | result->nb[0] = result->ne[2] * type_size; |
| 4463 | result->nb[1] = result->ne[0] * result->nb[0]; |
| 4464 | result->nb[2] = type_size; |
| 4465 | } |
| 4466 | |
| 4467 | int32_tcxx . . $ int32_t# params[] = { stride0, stride1, pad0, pad1, dilation0, dilation1 }; |
| 4468 | ggml_set_op_params(result, params, sizeof(params)); |
| 4469 | |
| 4470 | result->op = GGML_OP_CONV_2D_DW; |
| 4471 | result->src[0] = a; |
| 4472 | result->src[1] = b; |
| 4473 | return result; |
| 4474 | } |
| 4475 | |
| 4476 | // ggml_conv_2d_direct |
| 4477 | |
| 4478 | struct ggml_tensor * ggml_conv_2d_directcxx . . $ ggml_conv_2d_direct(ecc0ee37449ef42b).( |
| 4479 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4480 | struct ggml_tensor * a, // convolution kernel [KW, KH, IC, OC] |
| 4481 | struct ggml_tensor * b, // input data [W, H, C, N] |
| 4482 | int s0, // stride dimension 0 |
| 4483 | int s1, // stride dimension 1 |
| 4484 | int p0, // padding dimension 0 |
| 4485 | int p1, // padding dimension 1 |
| 4486 | int d0, // dilation dimension 0 |
| 4487 | int d1) {// dilation dimension 1 |
| 4488 | |
| 4489 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[2]); |
| 4490 | //GGML_ASSERT(a->type == b->type); |
| 4491 | |
| 4492 | int64_tcxx . . $ int64_t# ne[4]; |
| 4493 | ne[0] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[0], a->ne[0], s0, p0, d0); |
| 4494 | ne[1] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[1], a->ne[1], s1, p1, d1); |
| 4495 | ne[2] = a->ne[3]; |
| 4496 | ne[3] = b->ne[3]; |
| 4497 | |
| 4498 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, b->type, 4, ne); |
| 4499 | |
| 4500 | ggml_set_op_params_i32(result, 0, s0); |
| 4501 | ggml_set_op_params_i32(result, 1, s1); |
| 4502 | ggml_set_op_params_i32(result, 2, p0); |
| 4503 | ggml_set_op_params_i32(result, 3, p1); |
| 4504 | ggml_set_op_params_i32(result, 4, d0); |
| 4505 | ggml_set_op_params_i32(result, 5, d1); |
| 4506 | |
| 4507 | result->op = GGML_OP_CONV_2D; |
| 4508 | result->src[0] = a; |
| 4509 | result->src[1] = b; |
| 4510 | |
| 4511 | return result; |
| 4512 | } |
| 4513 | |
| 4514 | // ggml_conv_3d_direct |
| 4515 | |
| 4516 | struct ggml_tensor * ggml_conv_3d_directcxx . . $ ggml_conv_3d_direct(8b783ec6ddbd8c8b).( |
| 4517 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4518 | struct ggml_tensor * a, |
| 4519 | struct ggml_tensor * b, |
| 4520 | int s0, |
| 4521 | int s1, |
| 4522 | int s2, |
| 4523 | int p0, |
| 4524 | int p1, |
| 4525 | int p2, |
| 4526 | int d0, |
| 4527 | int d1, |
| 4528 | int d2, |
| 4529 | int c, |
| 4530 | int n, |
| 4531 | int oc) { |
| 4532 | |
| 4533 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == (int64_t) c * oc); |
| 4534 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[3] == (int64_t) c * n); |
| 4535 | |
| 4536 | int64_tcxx . . $ int64_t# ne[4]; |
| 4537 | ne[0] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[0], a->ne[0], s0, p0, d0); |
| 4538 | ne[1] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[1], a->ne[1], s1, p1, d1); |
| 4539 | ne[2] = ggml_calc_conv_output_sizecxx . . $ ggml_calc_conv_output_size(5da3564e4df29932).(b->ne[2], a->ne[2], s2, p2, d2); |
| 4540 | ne[3] = (int64_tcxx . . $ int64_t#) oc * n; |
| 4541 | |
| 4542 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 4543 | |
| 4544 | ggml_set_op_params_i32(result, 0, s0); |
| 4545 | ggml_set_op_params_i32(result, 1, s1); |
| 4546 | ggml_set_op_params_i32(result, 2, s2); |
| 4547 | ggml_set_op_params_i32(result, 3, p0); |
| 4548 | ggml_set_op_params_i32(result, 4, p1); |
| 4549 | ggml_set_op_params_i32(result, 5, p2); |
| 4550 | ggml_set_op_params_i32(result, 6, d0); |
| 4551 | ggml_set_op_params_i32(result, 7, d1); |
| 4552 | ggml_set_op_params_i32(result, 8, d2); |
| 4553 | ggml_set_op_params_i32(result, 9, c); |
| 4554 | ggml_set_op_params_i32(result, 10, n); |
| 4555 | ggml_set_op_params_i32(result, 11, oc); |
| 4556 | |
| 4557 | result->op = GGML_OP_CONV_3D; |
| 4558 | result->src[0] = a; |
| 4559 | result->src[1] = b; |
| 4560 | |
| 4561 | return result; |
| 4562 | } |
| 4563 | |
| 4564 | // ggml_conv_transpose_2d_p0 |
| 4565 | |
| 4566 | static int64_tcxx . . $ int64_t# ggml_calc_conv_transpose_output_sizecxx . . $ ggml_calc_conv_transpose_output_size(14085cb0ae402b2e).(int64_tcxx . . $ int64_t# ins, int64_tcxx . . $ int64_t# ks, int s, int p) { |
| 4567 | return (ins - 1) * s - 2 * p + ks; |
| 4568 | } |
| 4569 | |
| 4570 | struct ggml_tensor * ggml_conv_transpose_2d_p0cxx . . $ ggml_conv_transpose_2d_p0(aef13d738563d208).( |
| 4571 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4572 | struct ggml_tensor * a, |
| 4573 | struct ggml_tensor * b, |
| 4574 | int stride) { |
| 4575 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == b->ne[2]); |
| 4576 | |
| 4577 | const int64_tcxx . . $ int64_t# ne[4] = { |
| 4578 | ggml_calc_conv_transpose_output_sizecxx . . $ ggml_calc_conv_transpose_output_size(14085cb0ae402b2e).(b->ne[0], a->ne[0], stride, 0 /*p0*/), |
| 4579 | ggml_calc_conv_transpose_output_sizecxx . . $ ggml_calc_conv_transpose_output_size(14085cb0ae402b2e).(b->ne[1], a->ne[1], stride, 0 /*p1*/), |
| 4580 | a->ne[2], b->ne[3], |
| 4581 | }; |
| 4582 | |
| 4583 | struct ggml_tensor* result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 4584 | |
| 4585 | ggml_set_op_params_i32(result, 0, stride); |
| 4586 | |
| 4587 | result->op = GGML_OP_CONV_TRANSPOSE_2D; |
| 4588 | result->src[0] = a; |
| 4589 | result->src[1] = b; |
| 4590 | |
| 4591 | return result; |
| 4592 | } |
| 4593 | |
| 4594 | // ggml_pool_* |
| 4595 | |
| 4596 | static int64_tcxx . . $ int64_t# ggml_calc_pool_output_sizecxx . . $ ggml_calc_pool_output_size(abbe7e81a4efca2a).(int64_tcxx . . $ int64_t# ins, int ks, int s, float p) { |
| 4597 | return (ins + 2 * p - ks) / s + 1; |
| 4598 | } |
| 4599 | |
| 4600 | // ggml_pool_1d |
| 4601 | |
| 4602 | struct ggml_tensor * ggml_pool_1dcxx . . $ ggml_pool_1d(a828fd5137fc6946).( |
| 4603 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4604 | struct ggml_tensor * a, |
| 4605 | enum ggml_op_pool op, |
| 4606 | int k0, |
| 4607 | int s0, |
| 4608 | int p0) { |
| 4609 | const int64_tcxx . . $ int64_t# ne[4] = { |
| 4610 | ggml_calc_pool_output_sizecxx . . $ ggml_calc_pool_output_size(abbe7e81a4efca2a).(a->ne[0], k0, s0, p0), |
| 4611 | a->ne[1], |
| 4612 | a->ne[2], |
| 4613 | a->ne[3], |
| 4614 | }; |
| 4615 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ne[0] > 0); |
| 4616 | |
| 4617 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 4618 | |
| 4619 | int32_tcxx . . $ int32_t# params[] = { op, k0, s0, p0 }; |
| 4620 | ggml_set_op_params(result, params, sizeof(params)); |
| 4621 | |
| 4622 | result->op = GGML_OP_POOL_1D; |
| 4623 | result->src[0] = a; |
| 4624 | |
| 4625 | return result; |
| 4626 | } |
| 4627 | |
| 4628 | // ggml_pool_2d |
| 4629 | |
| 4630 | struct ggml_tensor * ggml_pool_2dcxx . . $ ggml_pool_2d(b647b1f253aa94f1).( |
| 4631 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4632 | struct ggml_tensor * a, |
| 4633 | enum ggml_op_pool op, |
| 4634 | int k0, |
| 4635 | int k1, |
| 4636 | int s0, |
| 4637 | int s1, |
| 4638 | float p0, |
| 4639 | float p1) { |
| 4640 | struct ggml_tensor * result; |
| 4641 | const int64_tcxx . . $ int64_t# ne[4] = { |
| 4642 | ggml_calc_pool_output_sizecxx . . $ ggml_calc_pool_output_size(abbe7e81a4efca2a).(a->ne[0], k0, s0, p0), |
| 4643 | ggml_calc_pool_output_sizecxx . . $ ggml_calc_pool_output_size(abbe7e81a4efca2a).(a->ne[1], k1, s1, p1), |
| 4644 | a->ne[2], |
| 4645 | a->ne[3], |
| 4646 | }; |
| 4647 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ne[0] > 0); |
| 4648 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ne[1] > 0); |
| 4649 | |
| 4650 | result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 4651 | |
| 4652 | int32_tcxx . . $ int32_t# params[] = { op, k0, k1, s0, s1, (int32_tcxx . . $ int32_t#) p0, (int32_tcxx . . $ int32_t#) p1 }; |
| 4653 | ggml_set_op_params(result, params, sizeof(params)); |
| 4654 | |
| 4655 | result->op = GGML_OP_POOL_2D; |
| 4656 | result->src[0] = a; |
| 4657 | |
| 4658 | return result; |
| 4659 | } |
| 4660 | |
| 4661 | struct ggml_tensor * ggml_pool_2d_backcxx . . $ ggml_pool_2d_back(6f799d6eb64995c2).( |
| 4662 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4663 | struct ggml_tensor * a, |
| 4664 | struct ggml_tensor * af, |
| 4665 | enum ggml_op_pool op, |
| 4666 | int k0, |
| 4667 | int k1, |
| 4668 | int s0, |
| 4669 | int s1, |
| 4670 | float p0, |
| 4671 | float p1) { |
| 4672 | struct ggml_tensor * result; |
| 4673 | result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, af->ne); |
| 4674 | |
| 4675 | int32_tcxx . . $ int32_t# params[] = { op, k0, k1, s0, s1, (int32_tcxx . . $ int32_t#) p0, (int32_tcxx . . $ int32_t#) p1 }; |
| 4676 | ggml_set_op_params(result, params, sizeof(params)); |
| 4677 | |
| 4678 | result->op = GGML_OP_POOL_2D_BACK; |
| 4679 | result->src[0] = a; |
| 4680 | result->src[1] = af; |
| 4681 | |
| 4682 | return result; |
| 4683 | } |
| 4684 | |
| 4685 | // ggml_upscale / ggml_interpolate |
| 4686 | |
| 4687 | static struct ggml_tensor * ggml_interpolate_implcxx . . $ ggml_interpolate_impl(575c9d369770b59d).( |
| 4688 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4689 | struct ggml_tensor * a, |
| 4690 | int64_tcxx . . $ int64_t# ne0, |
| 4691 | int64_tcxx . . $ int64_t# ne1, |
| 4692 | int64_tcxx . . $ int64_t# ne2, |
| 4693 | int64_tcxx . . $ int64_t# ne3, |
| 4694 | uint32_tcxx . . $ uint32_t# mode) { |
| 4695 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((mode & 0xFF) < GGML_SCALE_MODE_COUNT); |
| 4696 | // TODO: implement antialias for modes other than bilinear |
| 4697 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!(mode & GGML_SCALE_FLAG_ANTIALIAS) || (mode & 0xFF) == GGML_SCALE_MODE_BILINEAR); |
| 4698 | |
| 4699 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, a->type, ne0, ne1, ne2, ne3); |
| 4700 | |
| 4701 | ggml_set_op_params_i32(result, 0, (int32_tcxx . . $ int32_t#)mode); |
| 4702 | |
| 4703 | result->op = GGML_OP_UPSCALE; |
| 4704 | result->src[0] = a; |
| 4705 | |
| 4706 | return result; |
| 4707 | } |
| 4708 | |
| 4709 | struct ggml_tensor * ggml_upscalecxx . . $ ggml_upscale(2ed1a71df576dba2).( |
| 4710 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4711 | struct ggml_tensor * a, |
| 4712 | int scale_factor, |
| 4713 | enum ggml_scale_mode mode) { |
| 4714 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(scale_factor > 1); |
| 4715 | return ggml_interpolate_implcxx . . $ ggml_interpolate_impl(575c9d369770b59d).(ctx, a, a->ne[0] * scale_factor, a->ne[1] * scale_factor, a->ne[2], a->ne[3], mode); |
| 4716 | } |
| 4717 | |
| 4718 | struct ggml_tensor * ggml_upscale_extcxx . . $ ggml_upscale_ext(244925283b939ddd).( |
| 4719 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4720 | struct ggml_tensor * a, |
| 4721 | int ne0, |
| 4722 | int ne1, |
| 4723 | int ne2, |
| 4724 | int ne3, |
| 4725 | enum ggml_scale_mode mode) { |
| 4726 | return ggml_interpolate_implcxx . . $ ggml_interpolate_impl(575c9d369770b59d).(ctx, a, ne0, ne1, ne2, ne3, mode); |
| 4727 | } |
| 4728 | |
| 4729 | struct ggml_tensor * ggml_interpolatecxx . . $ ggml_interpolate(575c9d369770b59d).( |
| 4730 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4731 | struct ggml_tensor * a, |
| 4732 | int64_tcxx . . $ int64_t# ne0, |
| 4733 | int64_tcxx . . $ int64_t# ne1, |
| 4734 | int64_tcxx . . $ int64_t# ne2, |
| 4735 | int64_tcxx . . $ int64_t# ne3, |
| 4736 | uint32_tcxx . . $ uint32_t# mode) { |
| 4737 | return ggml_interpolate_implcxx . . $ ggml_interpolate_impl(575c9d369770b59d).(ctx, a, ne0, ne1, ne2, ne3, mode); |
| 4738 | } |
| 4739 | |
| 4740 | // ggml_pad |
| 4741 | |
| 4742 | struct ggml_tensor * ggml_padcxx . . $ ggml_pad(1642edaa96518f7e).( |
| 4743 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4744 | struct ggml_tensor * a, |
| 4745 | int p0, |
| 4746 | int p1, |
| 4747 | int p2, |
| 4748 | int p3) { |
| 4749 | return ggml_pad_ext(ctx, a, 0, p0, 0, p1, 0, p2, 0, p3); |
| 4750 | } |
| 4751 | |
| 4752 | // ggml_pad_circular |
| 4753 | |
| 4754 | struct ggml_tensor * ggml_pad_circularcxx . . $ ggml_pad_circular(1642edaa96518f7e).( |
| 4755 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4756 | struct ggml_tensor * a, |
| 4757 | int p0, |
| 4758 | int p1, |
| 4759 | int p2, |
| 4760 | int p3) { |
| 4761 | return ggml_pad_ext_circular(ctx, a, 0, p0, 0, p1, 0, p2, 0, p3); |
| 4762 | } |
| 4763 | |
| 4764 | struct ggml_tensor * ggml_pad_extcxx . . $ ggml_pad_ext(8507e72741c574c0).( |
| 4765 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4766 | struct ggml_tensor * a, |
| 4767 | int lp0, |
| 4768 | int rp0, |
| 4769 | int lp1, |
| 4770 | int rp1, |
| 4771 | int lp2, |
| 4772 | int rp2, |
| 4773 | int lp3, |
| 4774 | int rp3 |
| 4775 | ) { |
| 4776 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, a->type, |
| 4777 | a->ne[0] + lp0 + rp0, |
| 4778 | a->ne[1] + lp1 + rp1, |
| 4779 | a->ne[2] + lp2 + rp2, |
| 4780 | a->ne[3] + lp3 + rp3); |
| 4781 | |
| 4782 | ggml_set_op_params_i32(result, 0, lp0); |
| 4783 | ggml_set_op_params_i32(result, 1, rp0); |
| 4784 | ggml_set_op_params_i32(result, 2, lp1); |
| 4785 | ggml_set_op_params_i32(result, 3, rp1); |
| 4786 | ggml_set_op_params_i32(result, 4, lp2); |
| 4787 | ggml_set_op_params_i32(result, 5, rp2); |
| 4788 | ggml_set_op_params_i32(result, 6, lp3); |
| 4789 | ggml_set_op_params_i32(result, 7, rp3); |
| 4790 | ggml_set_op_params_i32(result, 8, 0); // not circular by default |
| 4791 | |
| 4792 | |
| 4793 | result->op = GGML_OP_PAD; |
| 4794 | result->src[0] = a; |
| 4795 | |
| 4796 | return result; |
| 4797 | } |
| 4798 | |
| 4799 | // ggml_pad_ext_circular |
| 4800 | |
| 4801 | struct ggml_tensor * ggml_pad_ext_circularcxx . . $ ggml_pad_ext_circular(8507e72741c574c0).( |
| 4802 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4803 | struct ggml_tensor * a, |
| 4804 | int lp0, |
| 4805 | int rp0, |
| 4806 | int lp1, |
| 4807 | int rp1, |
| 4808 | int lp2, |
| 4809 | int rp2, |
| 4810 | int lp3, |
| 4811 | int rp3 |
| 4812 | ) { |
| 4813 | struct ggml_tensor * result = ggml_pad_extcxx . . $ ggml_pad_ext(8507e72741c574c0).(ctx, a, lp0, rp0, lp1, rp1, lp2, rp2, lp3, rp3); |
| 4814 | ggml_set_op_params_i32(result, 8, 1); // circular |
| 4815 | return result; |
| 4816 | } |
| 4817 | |
| 4818 | // ggml_pad_reflect_1d |
| 4819 | |
| 4820 | struct ggml_tensor * ggml_pad_reflect_1dcxx . . $ ggml_pad_reflect_1d(d8d51171cb373a0e).( |
| 4821 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4822 | struct ggml_tensor * a, |
| 4823 | int p0, |
| 4824 | int p1) { |
| 4825 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(p0 >= 0); |
| 4826 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(p1 >= 0); |
| 4827 | |
| 4828 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(p0 < a->ne[0]); // padding length on each size must be less than the |
| 4829 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(p1 < a->ne[0]); // existing length of the dimension being padded |
| 4830 | |
| 4831 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 4832 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 4833 | |
| 4834 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, a->type, |
| 4835 | a->ne[0] + p0 + p1, |
| 4836 | a->ne[1], |
| 4837 | a->ne[2], |
| 4838 | a->ne[3]); |
| 4839 | |
| 4840 | int32_tcxx . . $ int32_t# params[] = { p0, p1 }; |
| 4841 | ggml_set_op_params(result, params, sizeof(params)); |
| 4842 | |
| 4843 | result->op = GGML_OP_PAD_REFLECT_1D; |
| 4844 | result->src[0] = a; |
| 4845 | |
| 4846 | return result; |
| 4847 | } |
| 4848 | |
| 4849 | // ggml_roll |
| 4850 | |
| 4851 | struct ggml_tensor * ggml_rollcxx . . $ ggml_roll(1642edaa96518f7e).( |
| 4852 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4853 | struct ggml_tensor * a, |
| 4854 | int shift0, |
| 4855 | int shift1, |
| 4856 | int shift2, |
| 4857 | int shift3) { |
| 4858 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->nb[0] == ggml_type_size(a->type)); |
| 4859 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(abs(shift0) < a->ne[0]); |
| 4860 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(abs(shift1) < a->ne[1]); |
| 4861 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(abs(shift2) < a->ne[2]); |
| 4862 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(abs(shift3) < a->ne[3]); |
| 4863 | |
| 4864 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 4865 | |
| 4866 | ggml_set_op_params_i32(result, 0, shift0); |
| 4867 | ggml_set_op_params_i32(result, 1, shift1); |
| 4868 | ggml_set_op_params_i32(result, 2, shift2); |
| 4869 | ggml_set_op_params_i32(result, 3, shift3); |
| 4870 | |
| 4871 | result->op = GGML_OP_ROLL; |
| 4872 | result->src[0] = a; |
| 4873 | |
| 4874 | return result; |
| 4875 | } |
| 4876 | |
| 4877 | // ggml_timestep_embedding |
| 4878 | |
| 4879 | struct ggml_tensor * ggml_timestep_embeddingcxx . . $ ggml_timestep_embedding(d8d51171cb373a0e).( |
| 4880 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4881 | struct ggml_tensor * timesteps, |
| 4882 | int dim, |
| 4883 | int max_period) { |
| 4884 | |
| 4885 | struct ggml_tensor * result = ggml_new_tensor_2dcxx . . $ ggml_new_tensor_2d(7610aad4b808d570).(ctx, GGML_TYPE_F32, dim, timesteps->ne[0]); |
| 4886 | |
| 4887 | ggml_set_op_params_i32(result, 0, dim); |
| 4888 | ggml_set_op_params_i32(result, 1, max_period); |
| 4889 | |
| 4890 | result->op = GGML_OP_TIMESTEP_EMBEDDING; |
| 4891 | result->src[0] = timesteps; |
| 4892 | |
| 4893 | return result; |
| 4894 | } |
| 4895 | |
| 4896 | // ggml_tri |
| 4897 | |
| 4898 | struct ggml_tensor * ggml_tricxx . . $ ggml_tri(d7d380c9827da505).( |
| 4899 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4900 | struct ggml_tensor * a, |
| 4901 | enum ggml_tri_type type) { |
| 4902 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 4903 | |
| 4904 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 4905 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] == a->ne[1]); |
| 4906 | |
| 4907 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 4908 | |
| 4909 | ggml_set_op_params_i32(result, 0, type); |
| 4910 | |
| 4911 | result->op = GGML_OP_TRI; |
| 4912 | result->src[0] = a; |
| 4913 | |
| 4914 | return result; |
| 4915 | } |
| 4916 | |
| 4917 | // ggml_fill |
| 4918 | |
| 4919 | static struct ggml_tensor * ggml_fill_implcxx . . $ ggml_fill_impl(abd14b6ff57d2af7).( |
| 4920 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4921 | struct ggml_tensor * a, |
| 4922 | float c, |
| 4923 | bool inplace) { |
| 4924 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 4925 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 4926 | |
| 4927 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 4928 | |
| 4929 | ggml_set_op_params_f32(result, 0, c); |
| 4930 | |
| 4931 | result->op = GGML_OP_FILL; |
| 4932 | result->src[0] = a; |
| 4933 | |
| 4934 | return result; |
| 4935 | } |
| 4936 | |
| 4937 | struct ggml_tensor * ggml_fillcxx . . $ ggml_fill(2b9396bfe07630bc).( |
| 4938 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4939 | struct ggml_tensor * a, |
| 4940 | float c) { |
| 4941 | return ggml_fill_implcxx . . $ ggml_fill_impl(abd14b6ff57d2af7).(ctx, a, c, false); |
| 4942 | } |
| 4943 | |
| 4944 | struct ggml_tensor * ggml_fill_inplacecxx . . $ ggml_fill_inplace(2b9396bfe07630bc).( |
| 4945 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4946 | struct ggml_tensor * a, |
| 4947 | float c) { |
| 4948 | return ggml_fill_implcxx . . $ ggml_fill_impl(abd14b6ff57d2af7).(ctx, a, c, true); |
| 4949 | } |
| 4950 | |
| 4951 | // ggml_argsort |
| 4952 | |
| 4953 | struct ggml_tensor * ggml_argsortcxx . . $ ggml_argsort(820d7d064659a5f4).( |
| 4954 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4955 | struct ggml_tensor * a, |
| 4956 | enum ggml_sort_order order) { |
| 4957 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] <= INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!); |
| 4958 | |
| 4959 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_I32, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, a->ne); |
| 4960 | |
| 4961 | ggml_set_op_params_i32(result, 0, (int32_tcxx . . $ int32_t#) order); |
| 4962 | |
| 4963 | result->op = GGML_OP_ARGSORT; |
| 4964 | result->src[0] = a; |
| 4965 | |
| 4966 | return result; |
| 4967 | } |
| 4968 | |
| 4969 | // ggml_argsort_top_k |
| 4970 | |
| 4971 | struct ggml_tensor * ggml_argsort_top_kcxx . . $ ggml_argsort_top_k(afdb15e78e46f369).( |
| 4972 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4973 | struct ggml_tensor * a, |
| 4974 | int k) { |
| 4975 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] >= k); |
| 4976 | |
| 4977 | struct ggml_tensor * result = ggml_argsortcxx . . $ ggml_argsort(820d7d064659a5f4).(ctx, a, GGML_SORT_ORDER_DESC); |
| 4978 | |
| 4979 | result = ggml_view_4dcxx . . $ ggml_view_4d(57a2df61c58fa26c).(ctx, result, |
| 4980 | k, result->ne[1], result->ne[2], result->ne[3], |
| 4981 | result->nb[1], result->nb[2], result->nb[3], |
| 4982 | 0); |
| 4983 | |
| 4984 | return result; |
| 4985 | } |
| 4986 | |
| 4987 | // ggml_top_k |
| 4988 | |
| 4989 | struct ggml_tensor * ggml_top_kcxx . . $ ggml_top_k(afdb15e78e46f369).( |
| 4990 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 4991 | struct ggml_tensor * a, |
| 4992 | int k) { |
| 4993 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] >= k); |
| 4994 | |
| 4995 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, GGML_TYPE_I32, k, a->ne[1], a->ne[2], a->ne[3]); |
| 4996 | |
| 4997 | result->op = GGML_OP_TOP_K; |
| 4998 | result->src[0] = a; |
| 4999 | |
| 5000 | return result; |
| 5001 | } |
| 5002 | |
| 5003 | // ggml_arange |
| 5004 | |
| 5005 | struct ggml_tensor * ggml_arangecxx . . $ ggml_arange(cd545df834c7cb99).( |
| 5006 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5007 | float start, |
| 5008 | float stop, |
| 5009 | float step) { |
| 5010 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(stop > start); |
| 5011 | |
| 5012 | const int64_tcxx . . $ int64_t# steps = (int64_tcxx . . $ int64_t#) ceilf((stop - start) / step); |
| 5013 | |
| 5014 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, GGML_TYPE_F32, steps); |
| 5015 | |
| 5016 | ggml_set_op_params_f32(result, 0, start); |
| 5017 | ggml_set_op_params_f32(result, 1, stop); |
| 5018 | ggml_set_op_params_f32(result, 2, step); |
| 5019 | |
| 5020 | result->op = GGML_OP_ARANGE; |
| 5021 | |
| 5022 | return result; |
| 5023 | } |
| 5024 | |
| 5025 | // ggml_flash_attn_ext |
| 5026 | |
| 5027 | struct ggml_tensor * ggml_flash_attn_extcxx . . $ ggml_flash_attn_ext(ce4726505073b0a2).( |
| 5028 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5029 | struct ggml_tensor * q, |
| 5030 | struct ggml_tensor * k, |
| 5031 | struct ggml_tensor * v, |
| 5032 | struct ggml_tensor * mask, |
| 5033 | float scale, |
| 5034 | float max_bias, |
| 5035 | float logit_softcap) { |
| 5036 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_mul_mat(k, q)); |
| 5037 | // TODO: check if vT can be multiplied by (k*qT) |
| 5038 | |
| 5039 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(q->ne[3] == k->ne[3]); |
| 5040 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(q->ne[3] == v->ne[3]); |
| 5041 | |
| 5042 | if (mask) { |
| 5043 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(mask)); |
| 5044 | //GGML_ASSERT(ggml_can_repeat_rows(mask, qk)); |
| 5045 | |
| 5046 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(q->ne[2] % mask->ne[2] == 0); |
| 5047 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(q->ne[3] % mask->ne[3] == 0); |
| 5048 | } |
| 5049 | |
| 5050 | if (max_bias > 0.0f) { |
| 5051 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(mask); |
| 5052 | } |
| 5053 | |
| 5054 | // permute(0, 2, 1, 3) |
| 5055 | int64_tcxx . . $ int64_t# ne[4] = { v->ne[0], q->ne[2], q->ne[1], q->ne[3] }; |
| 5056 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 5057 | |
| 5058 | float params[] = { scale, max_bias, logit_softcap }; |
| 5059 | ggml_set_op_params(result, params, sizeof(params)); |
| 5060 | |
| 5061 | result->op = GGML_OP_FLASH_ATTN_EXT; |
| 5062 | result->src[0] = q; |
| 5063 | result->src[1] = k; |
| 5064 | result->src[2] = v; |
| 5065 | result->src[3] = mask; |
| 5066 | |
| 5067 | return result; |
| 5068 | } |
| 5069 | |
| 5070 | void ggml_flash_attn_ext_set_preccxx . . $ ggml_flash_attn_ext_set_prec(2c583290e1112ede).( |
| 5071 | struct ggml_tensor * a, |
| 5072 | enum ggml_prec prec) { |
| 5073 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->op == GGML_OP_FLASH_ATTN_EXT); |
| 5074 | |
| 5075 | const int32_tcxx . . $ int32_t# prec_i32 = (int32_tcxx . . $ int32_t#) prec; |
| 5076 | |
| 5077 | ggml_set_op_params_i32(a, 3, prec_i32); // scale is on first pos, max_bias on second |
| 5078 | } |
| 5079 | |
| 5080 | enum ggml_prec ggml_flash_attn_ext_get_preccxx . . $ ggml_flash_attn_ext_get_prec(5b4edab48678f6db).( |
| 5081 | const struct ggml_tensor * a) { |
| 5082 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->op == GGML_OP_FLASH_ATTN_EXT); |
| 5083 | |
| 5084 | const int32_tcxx . . $ int32_t# prec_i32 = ggml_get_op_params_i32(a, 3); |
| 5085 | |
| 5086 | return (enum ggml_prec) prec_i32; |
| 5087 | } |
| 5088 | |
| 5089 | void ggml_flash_attn_ext_add_sinkscxx . . $ ggml_flash_attn_ext_add_sinks(d5fccb81be4f727c).( |
| 5090 | struct ggml_tensor * a, |
| 5091 | struct ggml_tensor * sinks) { |
| 5092 | if (!sinks) { |
| 5093 | a->src[4] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 5094 | return; |
| 5095 | } |
| 5096 | |
| 5097 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->op == GGML_OP_FLASH_ATTN_EXT); |
| 5098 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->src[4] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 5099 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->src[0]->ne[2] == sinks->ne[0]); |
| 5100 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(sinks->type == GGML_TYPE_F32); |
| 5101 | |
| 5102 | a->src[4] = sinks; |
| 5103 | } |
| 5104 | |
| 5105 | // ggml_flash_attn_back |
| 5106 | |
| 5107 | struct ggml_tensor * ggml_flash_attn_backcxx . . $ ggml_flash_attn_back(17e488fbe8840509).( |
| 5108 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5109 | struct ggml_tensor * q, |
| 5110 | struct ggml_tensor * k, |
| 5111 | struct ggml_tensor * v, |
| 5112 | struct ggml_tensor * d, |
| 5113 | bool masked) { |
| 5114 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("TODO: adapt to ggml_flash_attn_ext() changes"); |
| 5115 | |
| 5116 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_can_mul_mat(k, q)); |
| 5117 | // TODO: check if vT can be multiplied by (k*qT) |
| 5118 | |
| 5119 | // d shape [D,N,ne2,ne3] |
| 5120 | // q shape [D,N,ne2,ne3] |
| 5121 | // k shape [D,M,kvne2,ne3] |
| 5122 | // v shape [M,D,kvne2,ne3] |
| 5123 | |
| 5124 | const int64_tcxx . . $ int64_t# D = q->ne[0]; |
| 5125 | const int64_tcxx . . $ int64_t# N = q->ne[1]; |
| 5126 | const int64_tcxx . . $ int64_t# M = k->ne[1]; |
| 5127 | const int64_tcxx . . $ int64_t# ne2 = q->ne[2]; |
| 5128 | const int64_tcxx . . $ int64_t# ne3 = q->ne[3]; |
| 5129 | const int64_tcxx . . $ int64_t# kvne2 = k->ne[2]; |
| 5130 | |
| 5131 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(k->ne[0] == D); |
| 5132 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[0] == M); |
| 5133 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[1] == D); |
| 5134 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(d->ne[0] == D); |
| 5135 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(d->ne[1] == N); |
| 5136 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(k->ne[2] == kvne2); |
| 5137 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(k->ne[3] == ne3); |
| 5138 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[2] == kvne2); |
| 5139 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[3] == ne3); |
| 5140 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(d->ne[2] == ne2); |
| 5141 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(d->ne[3] == ne3); |
| 5142 | |
| 5143 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ne2 % kvne2 == 0); |
| 5144 | |
| 5145 | // store gradients of q, k and v as continuous tensors concatenated in result. |
| 5146 | // note: v and gradv are actually transposed, i.e. v->ne[0] != D. |
| 5147 | const int64_tcxx . . $ int64_t# elem_q = ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(q); |
| 5148 | const int64_tcxx . . $ int64_t# elem_k = ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(k); |
| 5149 | const int64_tcxx . . $ int64_t# elem_v = ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(v); |
| 5150 | |
| 5151 | enum ggml_type result_type = GGML_TYPE_F32; |
| 5152 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_blck_size(result_type) == 1); |
| 5153 | const size_t tsize = ggml_type_sizecxx . . $ ggml_type_size(6bbb8a7e702f38c5).(result_type); |
| 5154 | |
| 5155 | const size_t offs_q = 0; |
| 5156 | const size_t offs_k = offs_q + GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(elem_q * tsize, GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 5157 | const size_t offs_v = offs_k + GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(elem_k * tsize, GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 5158 | const size_t end = offs_v + GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(elem_v * tsize, GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 5159 | |
| 5160 | const size_t nelements = (end + tsize - 1)/tsize; |
| 5161 | |
| 5162 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, GGML_TYPE_F32, nelements); |
| 5163 | |
| 5164 | int32_tcxx . . $ int32_t# masked_i = masked ? 1 : 0; |
| 5165 | ggml_set_op_params(result, &masked_i, sizeof(masked_i)); |
| 5166 | |
| 5167 | result->op = GGML_OP_FLASH_ATTN_BACK; |
| 5168 | result->src[0] = q; |
| 5169 | result->src[1] = k; |
| 5170 | result->src[2] = v; |
| 5171 | result->src[3] = d; |
| 5172 | |
| 5173 | return result; |
| 5174 | } |
| 5175 | |
| 5176 | // ggml_ssm_conv |
| 5177 | |
| 5178 | struct ggml_tensor * ggml_ssm_convcxx . . $ ggml_ssm_conv(590e8193bb8aebeb).( |
| 5179 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5180 | struct ggml_tensor * sx, |
| 5181 | struct ggml_tensor * c) { |
| 5182 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_3d(sx)); |
| 5183 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_matrix(c)); |
| 5184 | |
| 5185 | const int64_tcxx . . $ int64_t# d_conv = c->ne[0]; |
| 5186 | const int64_tcxx . . $ int64_t# d_inner = c->ne[1]; |
| 5187 | const int64_tcxx . . $ int64_t# n_t = sx->ne[0] - d_conv + 1; // tokens per sequence |
| 5188 | const int64_tcxx . . $ int64_t# n_s = sx->ne[2]; |
| 5189 | |
| 5190 | // TODO: maybe support other strides than 1? |
| 5191 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(sx->ne[0] == d_conv - 1 + n_t); |
| 5192 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(sx->ne[1] == d_inner); |
| 5193 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_t >= 0); |
| 5194 | |
| 5195 | struct ggml_tensor * result = ggml_new_tensor_3dcxx . . $ ggml_new_tensor_3d(14b991d064ecb53f).(ctx, GGML_TYPE_F32, d_inner, n_t, n_s); |
| 5196 | |
| 5197 | result->op = GGML_OP_SSM_CONV; |
| 5198 | result->src[0] = sx; |
| 5199 | result->src[1] = c; |
| 5200 | |
| 5201 | return result; |
| 5202 | } |
| 5203 | |
| 5204 | // ggml_ssm_scan |
| 5205 | |
| 5206 | struct ggml_tensor * ggml_ssm_scancxx . . $ ggml_ssm_scan(e5c2f465d909e4f8).( |
| 5207 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5208 | struct ggml_tensor * s, |
| 5209 | struct ggml_tensor * x, |
| 5210 | struct ggml_tensor * dt, |
| 5211 | struct ggml_tensor * A, |
| 5212 | struct ggml_tensor * B, |
| 5213 | struct ggml_tensor * C, |
| 5214 | struct ggml_tensor * ids) { |
| 5215 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(s)); |
| 5216 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(dt)); |
| 5217 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(A)); |
| 5218 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(x->nb[0] == ggml_type_size(x->type)); |
| 5219 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(B->nb[0] == ggml_type_size(B->type)); |
| 5220 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(C->nb[0] == ggml_type_size(C->type)); |
| 5221 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(x->nb[1] == x->ne[0]*x->nb[0]); |
| 5222 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(B->nb[1] == B->ne[0]*B->nb[0]); |
| 5223 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(C->nb[1] == C->ne[0]*C->nb[0]); |
| 5224 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(B, C)); |
| 5225 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->type == GGML_TYPE_I32); |
| 5226 | |
| 5227 | { |
| 5228 | const int64_tcxx . . $ int64_t# d_state = s->ne[0]; |
| 5229 | const int64_tcxx . . $ int64_t# head_dim = x->ne[0]; |
| 5230 | const int64_tcxx . . $ int64_t# n_head = x->ne[1]; |
| 5231 | const int64_tcxx . . $ int64_t# n_seq_tokens = x->ne[2]; |
| 5232 | const int64_tcxx . . $ int64_t# n_seqs = x->ne[3]; |
| 5233 | |
| 5234 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dt->ne[0] == n_head); |
| 5235 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dt->ne[1] == n_seq_tokens); |
| 5236 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dt->ne[2] == n_seqs); |
| 5237 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_3d(dt)); |
| 5238 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(s->ne[1] == head_dim); |
| 5239 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(s->ne[2] == n_head); |
| 5240 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(B->ne[0] == d_state); |
| 5241 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(B->ne[2] == n_seq_tokens); |
| 5242 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(B->ne[3] == n_seqs); |
| 5243 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ids->ne[0] == n_seqs); |
| 5244 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_vector(ids)); |
| 5245 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(A->ne[1] == n_head); |
| 5246 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_matrix(A)); |
| 5247 | |
| 5248 | if (A->ne[0] != 1) { |
| 5249 | // Mamba-1 has more granular decay factors |
| 5250 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(A->ne[0] == d_state); |
| 5251 | } |
| 5252 | } |
| 5253 | |
| 5254 | // concatenated y + ssm_states |
| 5255 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, GGML_TYPE_F32, ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(x) + s->ne[0]*s->ne[1]*s->ne[2]*ids->ne[0]); |
| 5256 | |
| 5257 | result->op = GGML_OP_SSM_SCAN; |
| 5258 | result->src[0] = s; |
| 5259 | result->src[1] = x; |
| 5260 | result->src[2] = dt; |
| 5261 | result->src[3] = A; |
| 5262 | result->src[4] = B; |
| 5263 | result->src[5] = C; |
| 5264 | result->src[6] = ids; |
| 5265 | |
| 5266 | return result; |
| 5267 | } |
| 5268 | |
| 5269 | // ggml_win_part |
| 5270 | |
| 5271 | struct ggml_tensor * ggml_win_partcxx . . $ ggml_win_part(afdb15e78e46f369).( |
| 5272 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5273 | struct ggml_tensor * a, |
| 5274 | int w) { |
| 5275 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == 1); |
| 5276 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 5277 | |
| 5278 | // padding |
| 5279 | const int px = (w - a->ne[1]%w)%w; |
| 5280 | const int py = (w - a->ne[2]%w)%w; |
| 5281 | |
| 5282 | const int npx = (px + a->ne[1])/w; |
| 5283 | const int npy = (py + a->ne[2])/w; |
| 5284 | const int np = npx*npy; |
| 5285 | |
| 5286 | const int64_tcxx . . $ int64_t# ne[4] = { a->ne[0], w, w, np, }; |
| 5287 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 5288 | |
| 5289 | int32_tcxx . . $ int32_t# params[] = { npx, npy, w }; |
| 5290 | ggml_set_op_params(result, params, sizeof(params)); |
| 5291 | |
| 5292 | result->op = GGML_OP_WIN_PART; |
| 5293 | result->src[0] = a; |
| 5294 | |
| 5295 | return result; |
| 5296 | } |
| 5297 | |
| 5298 | // ggml_win_unpart |
| 5299 | |
| 5300 | struct ggml_tensor * ggml_win_unpartcxx . . $ ggml_win_unpart(42fd9f8061f37981).( |
| 5301 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5302 | struct ggml_tensor * a, |
| 5303 | int w0, |
| 5304 | int h0, |
| 5305 | int w) { |
| 5306 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 5307 | |
| 5308 | const int64_tcxx . . $ int64_t# ne[4] = { a->ne[0], w0, h0, 1, }; |
| 5309 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 3, ne); |
| 5310 | |
| 5311 | int32_tcxx . . $ int32_t# params[] = { w }; |
| 5312 | ggml_set_op_params(result, params, sizeof(params)); |
| 5313 | |
| 5314 | result->op = GGML_OP_WIN_UNPART; |
| 5315 | result->src[0] = a; |
| 5316 | |
| 5317 | return result; |
| 5318 | } |
| 5319 | |
| 5320 | // ggml_get_rel_pos |
| 5321 | |
| 5322 | struct ggml_tensor * ggml_get_rel_poscxx . . $ ggml_get_rel_pos(d8d51171cb373a0e).( |
| 5323 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5324 | struct ggml_tensor * a, |
| 5325 | int qh, |
| 5326 | int kh) { |
| 5327 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(qh == kh); |
| 5328 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(2*MAXcxx . . $ `external/whispercpp/ggml-impl.h:38:13`!(qh, kh) - 1 == a->ne[1]); |
| 5329 | |
| 5330 | const int64_tcxx . . $ int64_t# ne[4] = { a->ne[0], kh, qh, 1, }; |
| 5331 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F16, 3, ne); |
| 5332 | |
| 5333 | result->op = GGML_OP_GET_REL_POS; |
| 5334 | result->src[0] = a; |
| 5335 | |
| 5336 | return result; |
| 5337 | } |
| 5338 | |
| 5339 | // ggml_add_rel_pos |
| 5340 | |
| 5341 | static struct ggml_tensor * ggml_add_rel_pos_implcxx . . $ ggml_add_rel_pos_impl(3eff40ca1441f119).( |
| 5342 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5343 | struct ggml_tensor * a, |
| 5344 | struct ggml_tensor * pw, |
| 5345 | struct ggml_tensor * ph, |
| 5346 | bool inplace) { |
| 5347 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(pw, ph)); |
| 5348 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 5349 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(pw)); |
| 5350 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(ph)); |
| 5351 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ph->type == GGML_TYPE_F32); |
| 5352 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(pw->type == GGML_TYPE_F32); |
| 5353 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(pw->ne[3] == a->ne[2]); |
| 5354 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(pw->ne[0]*pw->ne[0] == a->ne[0]); |
| 5355 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(pw->ne[1]*pw->ne[2] == a->ne[1]); |
| 5356 | |
| 5357 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 5358 | ggml_set_op_params_i32(result, 0, inplace ? 1 : 0); |
| 5359 | |
| 5360 | result->op = GGML_OP_ADD_REL_POS; |
| 5361 | result->src[0] = a; |
| 5362 | result->src[1] = pw; |
| 5363 | result->src[2] = ph; |
| 5364 | |
| 5365 | return result; |
| 5366 | } |
| 5367 | |
| 5368 | struct ggml_tensor * ggml_add_rel_poscxx . . $ ggml_add_rel_pos(28fd2ad14bf2989).( |
| 5369 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5370 | struct ggml_tensor * a, |
| 5371 | struct ggml_tensor * pw, |
| 5372 | struct ggml_tensor * ph) { |
| 5373 | return ggml_add_rel_pos_implcxx . . $ ggml_add_rel_pos_impl(3eff40ca1441f119).(ctx, a, pw, ph, false); |
| 5374 | } |
| 5375 | |
| 5376 | struct ggml_tensor * ggml_add_rel_pos_inplacecxx . . $ ggml_add_rel_pos_inplace(28fd2ad14bf2989).( |
| 5377 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5378 | struct ggml_tensor * a, |
| 5379 | struct ggml_tensor * pw, |
| 5380 | struct ggml_tensor * ph) { |
| 5381 | return ggml_add_rel_pos_implcxx . . $ ggml_add_rel_pos_impl(3eff40ca1441f119).(ctx, a, pw, ph, true); |
| 5382 | } |
| 5383 | |
| 5384 | // ggml_rwkv_wkv6 |
| 5385 | |
| 5386 | struct ggml_tensor * ggml_rwkv_wkv6cxx . . $ ggml_rwkv_wkv6(b3486aad42bbbbed).( |
| 5387 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5388 | struct ggml_tensor * k, |
| 5389 | struct ggml_tensor * v, |
| 5390 | struct ggml_tensor * r, |
| 5391 | struct ggml_tensor * tf, |
| 5392 | struct ggml_tensor * td, |
| 5393 | struct ggml_tensor * state) { |
| 5394 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(k)); |
| 5395 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(v)); |
| 5396 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(r)); |
| 5397 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(tf)); |
| 5398 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(td)); |
| 5399 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(state)); |
| 5400 | |
| 5401 | const int64_tcxx . . $ int64_t# S = k->ne[0]; |
| 5402 | const int64_tcxx . . $ int64_t# H = k->ne[1]; |
| 5403 | const int64_tcxx . . $ int64_t# n_tokens = k->ne[2]; |
| 5404 | const int64_tcxx . . $ int64_t# n_seqs = state->ne[1]; |
| 5405 | { |
| 5406 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[0] == S && v->ne[1] == H && v->ne[2] == n_tokens); |
| 5407 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(r->ne[0] == S && r->ne[1] == H && r->ne[2] == n_tokens); |
| 5408 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(td->ne[0] == S && td->ne[1] == H && td->ne[2] == n_tokens); |
| 5409 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(state) == S * S * H * n_seqs); |
| 5410 | } |
| 5411 | |
| 5412 | // concat output and new_state |
| 5413 | const int64_tcxx . . $ int64_t# ne[4] = { S * H, n_tokens + S * n_seqs, 1, 1 }; |
| 5414 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 5415 | |
| 5416 | result->op = GGML_OP_RWKV_WKV6; |
| 5417 | result->src[0] = k; |
| 5418 | result->src[1] = v; |
| 5419 | result->src[2] = r; |
| 5420 | result->src[3] = tf; |
| 5421 | result->src[4] = td; |
| 5422 | result->src[5] = state; |
| 5423 | |
| 5424 | return result; |
| 5425 | } |
| 5426 | |
| 5427 | // ggml_gated_linear_attn |
| 5428 | |
| 5429 | struct ggml_tensor * ggml_gated_linear_attncxx . . $ ggml_gated_linear_attn(6bb07db7141c5ea1).( |
| 5430 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5431 | struct ggml_tensor * k, |
| 5432 | struct ggml_tensor * v, |
| 5433 | struct ggml_tensor * q, |
| 5434 | struct ggml_tensor * g, |
| 5435 | struct ggml_tensor * state, |
| 5436 | float scale) { |
| 5437 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(k)); |
| 5438 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(v)); |
| 5439 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(q)); |
| 5440 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(g)); |
| 5441 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(state)); |
| 5442 | |
| 5443 | const int64_tcxx . . $ int64_t# S = k->ne[0]; |
| 5444 | const int64_tcxx . . $ int64_t# H = k->ne[1]; |
| 5445 | const int64_tcxx . . $ int64_t# n_tokens = k->ne[2]; |
| 5446 | const int64_tcxx . . $ int64_t# n_seqs = state->ne[1]; |
| 5447 | { |
| 5448 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[0] == S && v->ne[1] == H && v->ne[2] == n_tokens); |
| 5449 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(q->ne[0] == S && q->ne[1] == H && q->ne[2] == n_tokens); |
| 5450 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(g->ne[0] == S && g->ne[1] == H && g->ne[2] == n_tokens); |
| 5451 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(state) == S * S * H * n_seqs); |
| 5452 | } |
| 5453 | |
| 5454 | // concat output and new_state |
| 5455 | const int64_tcxx . . $ int64_t# ne[4] = { S * H, n_tokens + S * n_seqs, 1, 1 }; |
| 5456 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 5457 | |
| 5458 | ggml_set_op_params_f32(result, 0, scale); |
| 5459 | |
| 5460 | result->op = GGML_OP_GATED_LINEAR_ATTN; |
| 5461 | result->src[0] = k; |
| 5462 | result->src[1] = v; |
| 5463 | result->src[2] = q; |
| 5464 | result->src[3] = g; |
| 5465 | result->src[4] = state; |
| 5466 | |
| 5467 | return result; |
| 5468 | } |
| 5469 | |
| 5470 | // ggml_rwkv_wkv7 |
| 5471 | |
| 5472 | struct ggml_tensor * ggml_rwkv_wkv7cxx . . $ ggml_rwkv_wkv7(e5c2f465d909e4f8).( |
| 5473 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5474 | struct ggml_tensor * r, |
| 5475 | struct ggml_tensor * w, |
| 5476 | struct ggml_tensor * k, |
| 5477 | struct ggml_tensor * v, |
| 5478 | struct ggml_tensor * a, |
| 5479 | struct ggml_tensor * b, |
| 5480 | struct ggml_tensor * state) { |
| 5481 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(r)); |
| 5482 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(w)); |
| 5483 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(k)); |
| 5484 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(v)); |
| 5485 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 5486 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(b)); |
| 5487 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(state)); |
| 5488 | |
| 5489 | const int64_tcxx . . $ int64_t# S = k->ne[0]; |
| 5490 | const int64_tcxx . . $ int64_t# H = k->ne[1]; |
| 5491 | const int64_tcxx . . $ int64_t# n_tokens = k->ne[2]; |
| 5492 | const int64_tcxx . . $ int64_t# n_seqs = state->ne[1]; |
| 5493 | { |
| 5494 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(w->ne[0] == S && w->ne[1] == H && w->ne[2] == n_tokens); |
| 5495 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(k->ne[0] == S && k->ne[1] == H && k->ne[2] == n_tokens); |
| 5496 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(v->ne[0] == S && v->ne[1] == H && v->ne[2] == n_tokens); |
| 5497 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] == S && a->ne[1] == H && a->ne[2] == n_tokens); |
| 5498 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->ne[0] == S && b->ne[1] == H && b->ne[2] == n_tokens); |
| 5499 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(state) == S * S * H * n_seqs); |
| 5500 | } |
| 5501 | |
| 5502 | // concat output and new_state |
| 5503 | const int64_tcxx . . $ int64_t# ne[4] = { S * H, n_tokens + S * n_seqs, 1, 1 }; |
| 5504 | struct ggml_tensor * result = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, 4, ne); |
| 5505 | |
| 5506 | result->op = GGML_OP_RWKV_WKV7; |
| 5507 | result->src[0] = r; |
| 5508 | result->src[1] = w; |
| 5509 | result->src[2] = k; |
| 5510 | result->src[3] = v; |
| 5511 | result->src[4] = a; |
| 5512 | result->src[5] = b; |
| 5513 | result->src[6] = state; |
| 5514 | |
| 5515 | return result; |
| 5516 | } |
| 5517 | |
| 5518 | // ggml_unary |
| 5519 | |
| 5520 | static struct ggml_tensor * ggml_unary_implcxx . . $ ggml_unary_impl(6a672c6aea447e00).( |
| 5521 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5522 | struct ggml_tensor * a, |
| 5523 | enum ggml_unary_op op, |
| 5524 | bool inplace) { |
| 5525 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous_rows(a)); |
| 5526 | |
| 5527 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 5528 | |
| 5529 | ggml_set_op_params_i32(result, 0, (int32_tcxx . . $ int32_t#) op); |
| 5530 | |
| 5531 | result->op = GGML_OP_UNARY; |
| 5532 | result->src[0] = a; |
| 5533 | |
| 5534 | return result; |
| 5535 | } |
| 5536 | |
| 5537 | struct ggml_tensor * ggml_unarycxx . . $ ggml_unary(5addfc5cd05176d7).( |
| 5538 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5539 | struct ggml_tensor * a, |
| 5540 | enum ggml_unary_op op) { |
| 5541 | return ggml_unary_implcxx . . $ ggml_unary_impl(6a672c6aea447e00).(ctx, a, op, false); |
| 5542 | } |
| 5543 | |
| 5544 | struct ggml_tensor * ggml_unary_inplacecxx . . $ ggml_unary_inplace(5addfc5cd05176d7).( |
| 5545 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5546 | struct ggml_tensor * a, |
| 5547 | enum ggml_unary_op op) { |
| 5548 | return ggml_unary_implcxx . . $ ggml_unary_impl(6a672c6aea447e00).(ctx, a, op, true); |
| 5549 | } |
| 5550 | |
| 5551 | // ggml_map_custom1 |
| 5552 | |
| 5553 | static struct ggml_tensor * ggml_map_custom1_implcxx . . $ ggml_map_custom1_impl(7d3578421a729245).( |
| 5554 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5555 | struct ggml_tensor * a, |
| 5556 | const ggml_custom1_op_t fun, |
| 5557 | int n_tasks, |
| 5558 | void * userdata, |
| 5559 | bool inplace) { |
| 5560 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_tasks == GGML_N_TASKS_MAXcxx . . $ `external/whispercpp/ggml.h:2493:9`! || n_tasks > 0); |
| 5561 | |
| 5562 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 5563 | |
| 5564 | struct ggml_map_custom1_op_params params = { |
| 5565 | /*.fun =*/ fun, |
| 5566 | /*.n_tasks =*/ n_tasks, |
| 5567 | /*.userdata =*/ userdata |
| 5568 | }; |
| 5569 | ggml_set_op_params(result, ¶ms, sizeof(params)); |
| 5570 | |
| 5571 | result->op = GGML_OP_MAP_CUSTOM1; |
| 5572 | result->src[0] = a; |
| 5573 | |
| 5574 | return result; |
| 5575 | } |
| 5576 | |
| 5577 | struct ggml_tensor * ggml_map_custom1cxx . . $ ggml_map_custom1(5656c1a708799cd8).( |
| 5578 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5579 | struct ggml_tensor * a, |
| 5580 | const ggml_custom1_op_t fun, |
| 5581 | int n_tasks, |
| 5582 | void * userdata) { |
| 5583 | return ggml_map_custom1_implcxx . . $ ggml_map_custom1_impl(7d3578421a729245).(ctx, a, fun, n_tasks, userdata, false); |
| 5584 | } |
| 5585 | |
| 5586 | struct ggml_tensor * ggml_map_custom1_inplacecxx . . $ ggml_map_custom1_inplace(5656c1a708799cd8).( |
| 5587 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5588 | struct ggml_tensor * a, |
| 5589 | const ggml_custom1_op_t fun, |
| 5590 | int n_tasks, |
| 5591 | void * userdata) { |
| 5592 | return ggml_map_custom1_implcxx . . $ ggml_map_custom1_impl(7d3578421a729245).(ctx, a, fun, n_tasks, userdata, true); |
| 5593 | } |
| 5594 | |
| 5595 | // ggml_map_custom2 |
| 5596 | |
| 5597 | static struct ggml_tensor * ggml_map_custom2_implcxx . . $ ggml_map_custom2_impl(e83f0449550ee321).( |
| 5598 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5599 | struct ggml_tensor * a, |
| 5600 | struct ggml_tensor * b, |
| 5601 | const ggml_custom2_op_t fun, |
| 5602 | int n_tasks, |
| 5603 | void * userdata, |
| 5604 | bool inplace) { |
| 5605 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_tasks == GGML_N_TASKS_MAXcxx . . $ `external/whispercpp/ggml.h:2493:9`! || n_tasks > 0); |
| 5606 | |
| 5607 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 5608 | |
| 5609 | struct ggml_map_custom2_op_params params = { |
| 5610 | /*.fun =*/ fun, |
| 5611 | /*.n_tasks =*/ n_tasks, |
| 5612 | /*.userdata =*/ userdata |
| 5613 | }; |
| 5614 | ggml_set_op_params(result, ¶ms, sizeof(params)); |
| 5615 | |
| 5616 | result->op = GGML_OP_MAP_CUSTOM2; |
| 5617 | result->src[0] = a; |
| 5618 | result->src[1] = b; |
| 5619 | |
| 5620 | return result; |
| 5621 | } |
| 5622 | |
| 5623 | struct ggml_tensor * ggml_map_custom2cxx . . $ ggml_map_custom2(e1aaa500194c32c4).( |
| 5624 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5625 | struct ggml_tensor * a, |
| 5626 | struct ggml_tensor * b, |
| 5627 | const ggml_custom2_op_t fun, |
| 5628 | int n_tasks, |
| 5629 | void * userdata) { |
| 5630 | return ggml_map_custom2_implcxx . . $ ggml_map_custom2_impl(e83f0449550ee321).(ctx, a, b, fun, n_tasks, userdata, false); |
| 5631 | } |
| 5632 | |
| 5633 | struct ggml_tensor * ggml_map_custom2_inplacecxx . . $ ggml_map_custom2_inplace(e1aaa500194c32c4).( |
| 5634 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5635 | struct ggml_tensor * a, |
| 5636 | struct ggml_tensor * b, |
| 5637 | const ggml_custom2_op_t fun, |
| 5638 | int n_tasks, |
| 5639 | void * userdata) { |
| 5640 | return ggml_map_custom2_implcxx . . $ ggml_map_custom2_impl(e83f0449550ee321).(ctx, a, b, fun, n_tasks, userdata, true); |
| 5641 | } |
| 5642 | |
| 5643 | // ggml_map_custom3 |
| 5644 | |
| 5645 | static struct ggml_tensor * ggml_map_custom3_implcxx . . $ ggml_map_custom3_impl(f1b1e9f1eaf981ce).( |
| 5646 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5647 | struct ggml_tensor * a, |
| 5648 | struct ggml_tensor * b, |
| 5649 | struct ggml_tensor * c, |
| 5650 | const ggml_custom3_op_t fun, |
| 5651 | int n_tasks, |
| 5652 | void * userdata, |
| 5653 | bool inplace) { |
| 5654 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_tasks == GGML_N_TASKS_MAXcxx . . $ `external/whispercpp/ggml.h:2493:9`! || n_tasks > 0); |
| 5655 | |
| 5656 | struct ggml_tensor * result = inplace ? ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a) : ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, a); |
| 5657 | |
| 5658 | struct ggml_map_custom3_op_params params = { |
| 5659 | /*.fun =*/ fun, |
| 5660 | /*.n_tasks =*/ n_tasks, |
| 5661 | /*.userdata =*/ userdata |
| 5662 | }; |
| 5663 | ggml_set_op_params(result, ¶ms, sizeof(params)); |
| 5664 | |
| 5665 | result->op = GGML_OP_MAP_CUSTOM3; |
| 5666 | result->src[0] = a; |
| 5667 | result->src[1] = b; |
| 5668 | result->src[2] = c; |
| 5669 | |
| 5670 | return result; |
| 5671 | } |
| 5672 | |
| 5673 | struct ggml_tensor * ggml_map_custom3cxx . . $ ggml_map_custom3(7c48b017f4ee65cf).( |
| 5674 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5675 | struct ggml_tensor * a, |
| 5676 | struct ggml_tensor * b, |
| 5677 | struct ggml_tensor * c, |
| 5678 | const ggml_custom3_op_t fun, |
| 5679 | int n_tasks, |
| 5680 | void * userdata) { |
| 5681 | return ggml_map_custom3_implcxx . . $ ggml_map_custom3_impl(f1b1e9f1eaf981ce).(ctx, a, b, c, fun, n_tasks, userdata, false); |
| 5682 | } |
| 5683 | |
| 5684 | struct ggml_tensor * ggml_map_custom3_inplacecxx . . $ ggml_map_custom3_inplace(7c48b017f4ee65cf).( |
| 5685 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5686 | struct ggml_tensor * a, |
| 5687 | struct ggml_tensor * b, |
| 5688 | struct ggml_tensor * c, |
| 5689 | const ggml_custom3_op_t fun, |
| 5690 | int n_tasks, |
| 5691 | void * userdata) { |
| 5692 | return ggml_map_custom3_implcxx . . $ ggml_map_custom3_impl(f1b1e9f1eaf981ce).(ctx, a, b, c, fun, n_tasks, userdata, true); |
| 5693 | } |
| 5694 | |
| 5695 | struct ggml_tensor * ggml_custom_4dcxx . . $ ggml_custom_4d(be40425a9d69c640).( |
| 5696 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5697 | enum ggml_type type, |
| 5698 | int64_tcxx . . $ int64_t# ne0, |
| 5699 | int64_tcxx . . $ int64_t# ne1, |
| 5700 | int64_tcxx . . $ int64_t# ne2, |
| 5701 | int64_tcxx . . $ int64_t# ne3, |
| 5702 | struct ggml_tensor ** args, |
| 5703 | int n_args, |
| 5704 | ggml_custom_op_t fun, |
| 5705 | int n_tasks, |
| 5706 | void * userdata) { |
| 5707 | |
| 5708 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_args < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!); |
| 5709 | |
| 5710 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, type, ne0, ne1, ne2, ne3); |
| 5711 | |
| 5712 | struct ggml_custom_op_params params = { |
| 5713 | /*.fun =*/ fun, |
| 5714 | /*.n_tasks =*/ n_tasks, |
| 5715 | /*.userdata =*/ userdata |
| 5716 | }; |
| 5717 | ggml_set_op_params(result, ¶ms, sizeof(params)); |
| 5718 | |
| 5719 | result->op = GGML_OP_CUSTOM; |
| 5720 | for (int i = 0; i < n_args; i++) { |
| 5721 | result->src[i] = args[i]; |
| 5722 | } |
| 5723 | |
| 5724 | return result; |
| 5725 | } |
| 5726 | |
| 5727 | struct ggml_tensor * ggml_custom_inplacecxx . . $ ggml_custom_inplace(92588728fe6a3a49).( |
| 5728 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5729 | struct ggml_tensor * a, |
| 5730 | struct ggml_tensor ** args, |
| 5731 | int n_args, |
| 5732 | ggml_custom_op_t fun, |
| 5733 | int n_tasks, |
| 5734 | void * userdata) { |
| 5735 | |
| 5736 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(n_args < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`! - 1); |
| 5737 | |
| 5738 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 5739 | |
| 5740 | struct ggml_custom_op_params params = { |
| 5741 | /*.fun =*/ fun, |
| 5742 | /*.n_tasks =*/ n_tasks, |
| 5743 | /*.userdata =*/ userdata |
| 5744 | }; |
| 5745 | ggml_set_op_params(result, ¶ms, sizeof(params)); |
| 5746 | |
| 5747 | result->op = GGML_OP_CUSTOM; |
| 5748 | result->src[0] = a; |
| 5749 | for (int i = 0; i < n_args; i++) { |
| 5750 | result->src[i + 1] = args[i]; |
| 5751 | } |
| 5752 | |
| 5753 | return result; |
| 5754 | } |
| 5755 | // ggml_cross_entropy_loss |
| 5756 | |
| 5757 | struct ggml_tensor * ggml_cross_entropy_losscxx . . $ ggml_cross_entropy_loss(590e8193bb8aebeb).( |
| 5758 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5759 | struct ggml_tensor * a, |
| 5760 | struct ggml_tensor * b) { |
| 5761 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, b)); |
| 5762 | |
| 5763 | struct ggml_tensor * result = ggml_new_tensor_1dcxx . . $ ggml_new_tensor_1d(2f21c481b1610d87).(ctx, a->type, 1); |
| 5764 | |
| 5765 | result->op = GGML_OP_CROSS_ENTROPY_LOSS; |
| 5766 | result->src[0] = a; |
| 5767 | result->src[1] = b; |
| 5768 | |
| 5769 | return result; |
| 5770 | } |
| 5771 | |
| 5772 | // ggml_cross_entropy_loss_back |
| 5773 | |
| 5774 | struct ggml_tensor * ggml_cross_entropy_loss_backcxx . . $ ggml_cross_entropy_loss_back(28fd2ad14bf2989).( |
| 5775 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5776 | struct ggml_tensor * a, |
| 5777 | struct ggml_tensor * b, |
| 5778 | struct ggml_tensor * c) { |
| 5779 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_scalar(a)); |
| 5780 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(b, c)); |
| 5781 | |
| 5782 | struct ggml_tensor * result = ggml_dup_tensorcxx . . $ ggml_dup_tensor(c752896e100876cd).(ctx, b); |
| 5783 | |
| 5784 | result->op = GGML_OP_CROSS_ENTROPY_LOSS_BACK; |
| 5785 | result->src[0] = a; |
| 5786 | result->src[1] = b; |
| 5787 | result->src[2] = c; |
| 5788 | |
| 5789 | return result; |
| 5790 | } |
| 5791 | |
| 5792 | // opt_step_adamw |
| 5793 | |
| 5794 | struct ggml_tensor * ggml_opt_step_adamwcxx . . $ ggml_opt_step_adamw(d3d118f4a4f3c364).( |
| 5795 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5796 | struct ggml_tensor * a, |
| 5797 | struct ggml_tensor * grad, |
| 5798 | struct ggml_tensor * m, |
| 5799 | struct ggml_tensor * v, |
| 5800 | struct ggml_tensor * adamw_params) { |
| 5801 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->flags & GGML_TENSOR_FLAG_PARAM); |
| 5802 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, grad)); |
| 5803 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, m)); |
| 5804 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, v)); |
| 5805 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(adamw_params->type == GGML_TYPE_F32); |
| 5806 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(adamw_params) == 7); |
| 5807 | |
| 5808 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 5809 | |
| 5810 | result->op = GGML_OP_OPT_STEP_ADAMW; |
| 5811 | result->src[0] = a; |
| 5812 | result->src[1] = grad; |
| 5813 | result->src[2] = m; |
| 5814 | result->src[3] = v; |
| 5815 | result->src[4] = adamw_params; |
| 5816 | |
| 5817 | return result; |
| 5818 | } |
| 5819 | |
| 5820 | // opt_step_sgd |
| 5821 | |
| 5822 | struct ggml_tensor * ggml_opt_step_sgdcxx . . $ ggml_opt_step_sgd(28fd2ad14bf2989).( |
| 5823 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5824 | struct ggml_tensor * a, |
| 5825 | struct ggml_tensor * grad, |
| 5826 | struct ggml_tensor * params) { |
| 5827 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->flags & GGML_TENSOR_FLAG_PARAM); |
| 5828 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_are_same_shape(a, grad)); |
| 5829 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(params->type == GGML_TYPE_F32); |
| 5830 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(params) == 2); |
| 5831 | |
| 5832 | struct ggml_tensor * result = ggml_view_tensorcxx . . $ ggml_view_tensor(71a7fa2ddee25242).(ctx, a); |
| 5833 | |
| 5834 | result->op = GGML_OP_OPT_STEP_SGD; |
| 5835 | result->src[0] = a; |
| 5836 | result->src[1] = grad; |
| 5837 | result->src[2] = params; |
| 5838 | |
| 5839 | return result; |
| 5840 | } |
| 5841 | |
| 5842 | // solve_tri |
| 5843 | |
| 5844 | struct ggml_tensor * ggml_solve_tricxx . . $ ggml_solve_tri(126c5a044787d757).( |
| 5845 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5846 | struct ggml_tensor * a, |
| 5847 | struct ggml_tensor * b, |
| 5848 | bool left, |
| 5849 | bool lower, |
| 5850 | bool uni) { |
| 5851 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->type == GGML_TYPE_F32); |
| 5852 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(b->type == GGML_TYPE_F32); |
| 5853 | |
| 5854 | // A must be square and lower diagonal |
| 5855 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[0] == a->ne[1]); |
| 5856 | // B must have same outer dimension as A |
| 5857 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[1] == b->ne[1]); |
| 5858 | |
| 5859 | // batch dimensions must be equal |
| 5860 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[2] == b->ne[2]); |
| 5861 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(a->ne[3] == b->ne[3]); |
| 5862 | |
| 5863 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(a)); |
| 5864 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(b)); |
| 5865 | |
| 5866 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(lower && left && !uni); // TODO: support other variants |
| 5867 | |
| 5868 | struct ggml_tensor * result = ggml_new_tensor_4dcxx . . $ ggml_new_tensor_4d(466440b459334495).(ctx, GGML_TYPE_F32, b->ne[0], b->ne[1], b->ne[2], b->ne[3]); |
| 5869 | |
| 5870 | result->op = GGML_OP_SOLVE_TRI; |
| 5871 | result->src[0] = a; |
| 5872 | result->src[1] = b; |
| 5873 | |
| 5874 | return result; |
| 5875 | } |
| 5876 | |
| 5877 | //////////////////////////////////////////////////////////////////////////////// |
| 5878 | |
| 5879 | struct ggml_hash_set ggml_hash_set_newcxx . . $ ggml_hash_set_new(ec896db146153f54).(size_t size) { |
| 5880 | size = ggml_hash_size(size); |
| 5881 | struct ggml_hash_set result; |
| 5882 | result.size = size; |
| 5883 | result.keys = (struct ggml_tensor **) GGML_MALLOCcxx . . $ `external/whispercpp/ggml.cpp:262:9`!(sizeof(struct ggml_tensor *) * size); |
| 5884 | result.used = (ggml_bitset_t *) GGML_CALLOCcxx . . $ `external/whispercpp/ggml.cpp:263:9`!(ggml_bitset_size(size), sizeof(ggml_bitset_t)); |
| 5885 | return result; |
| 5886 | } |
| 5887 | |
| 5888 | void ggml_hash_set_resetcxx . . $ ggml_hash_set_reset(3b8f2cbb4a532df6).(struct ggml_hash_set * hash_set) { |
| 5889 | memset(hash_set->used, 0, sizeof(ggml_bitset_t) * ggml_bitset_size(hash_set->size)); |
| 5890 | } |
| 5891 | |
| 5892 | void ggml_hash_set_freecxx . . $ ggml_hash_set_free(3b8f2cbb4a532df6).(struct ggml_hash_set * hash_set) { |
| 5893 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(hash_set->used); |
| 5894 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(hash_set->keys); |
| 5895 | } |
| 5896 | |
| 5897 | size_t ggml_hash_sizecxx . . $ ggml_hash_size(ecdaa1632f49f591).(size_t min_sz) { |
| 5898 | // next primes after powers of two |
| 5899 | static const size_t primes[] = { |
| 5900 | 2, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, |
| 5901 | 2053, 4099, 8209, 16411, 32771, 65537, 131101, |
| 5902 | 262147, 524309, 1048583, 2097169, 4194319, 8388617, |
| 5903 | 16777259, 33554467, 67108879, 134217757, 268435459, |
| 5904 | 536870923, 1073741827, 2147483659 |
| 5905 | }; |
| 5906 | static const size_t n_primes = sizeof(primes)/sizeof(primes[0]); |
| 5907 | |
| 5908 | // find the smallest prime that is larger or equal than min_sz |
| 5909 | size_t l = 0; |
| 5910 | size_t r = n_primes; |
| 5911 | while (l < r) { |
| 5912 | size_t m = (l + r)/2; |
| 5913 | if (primes[m] < min_sz) { |
| 5914 | l = m + 1; |
| 5915 | } else { |
| 5916 | r = m; |
| 5917 | } |
| 5918 | } |
| 5919 | size_t sz = l < n_primes ? primes[l] : min_sz | 1; |
| 5920 | return sz; |
| 5921 | } |
| 5922 | |
| 5923 | struct hash_mapcxx . . $ hash_map# { |
| 5924 | struct ggml_hash_set setcxx . . $ hash_map#set.; |
| 5925 | struct ggml_tensor ** valscxx . . $ hash_map#vals.; |
| 5926 | }; |
| 5927 | |
| 5928 | static struct hash_mapcxx . . $ hash_map# * ggml_new_hash_mapcxx . . $ ggml_new_hash_map(e13710c013925a2e).(size_t size) { |
| 5929 | struct hash_mapcxx . . $ hash_map# * result = (struct hash_mapcxx . . $ hash_map# *) GGML_MALLOCcxx . . $ `external/whispercpp/ggml.cpp:262:9`!(sizeof(struct hash_map)); |
| 5930 | result->setcxx . . $ hash_map#set. = ggml_hash_set_newcxx . . $ ggml_hash_set_new(ec896db146153f54).(size); |
| 5931 | result->valscxx . . $ hash_map#vals. = (struct ggml_tensor **) GGML_CALLOCcxx . . $ `external/whispercpp/ggml.cpp:263:9`!(result->set.size, sizeof(struct ggml_tensor *)); |
| 5932 | return result; |
| 5933 | } |
| 5934 | |
| 5935 | static void ggml_hash_map_freecxx . . $ ggml_hash_map_free(115878ccdf7ac49e).(struct hash_mapcxx . . $ hash_map# * map) { |
| 5936 | ggml_hash_set_freecxx . . $ ggml_hash_set_free(3b8f2cbb4a532df6).(&map->setcxx . . $ hash_map#set.); |
| 5937 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(map->vals); |
| 5938 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(map); |
| 5939 | } |
| 5940 | |
| 5941 | // utility functions to change gradients |
| 5942 | // isrc is the index of tensor in cgraph->visited_has_set.keys |
| 5943 | // the corresponding gradient (accumulators) are also at position isrc |
| 5944 | // if tensor has a gradient accumulator, modify that accumulator in-place |
| 5945 | // else if there is no gradient for tensor, set the corresponding value |
| 5946 | // else, just add/subtract/etc. the gradients |
| 5947 | |
| 5948 | static void ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).( |
| 5949 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5950 | struct ggml_cgraph * cgraph, |
| 5951 | size_t isrc, |
| 5952 | struct ggml_tensor * tensor) { |
| 5953 | struct ggml_tensor * src = cgraph->visited_hash_set.keys[isrc]; |
| 5954 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(src); |
| 5955 | if (cgraph->grads[isrc]) { |
| 5956 | cgraph->grads[isrc] = ggml_add_implcxx . . $ ggml_add_impl(68ee738007d49a26).(ctx, cgraph->grads[isrc], tensor, /*inplace =*/ cgraph->grad_accs[isrc]); |
| 5957 | } else { |
| 5958 | cgraph->grads[isrc] = tensor; |
| 5959 | } |
| 5960 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(cgraph->grads[isrc], "grad for %s", src->name); |
| 5961 | ggml_build_forward_expand(cgraph, cgraph->grads[isrc]); |
| 5962 | } |
| 5963 | |
| 5964 | static void ggml_acc_or_setcxx . . $ ggml_acc_or_set(c21f677098863802).( |
| 5965 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5966 | struct ggml_cgraph * cgraph, |
| 5967 | size_t isrc, |
| 5968 | struct ggml_tensor * tensor, |
| 5969 | const size_t nb1, |
| 5970 | const size_t nb2, |
| 5971 | const size_t nb3, |
| 5972 | const size_t offset) { |
| 5973 | struct ggml_tensor * src = cgraph->visited_hash_set.keys[isrc]; |
| 5974 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(src); |
| 5975 | if (cgraph->grads[isrc]) { |
| 5976 | cgraph->grads[isrc] = ggml_acc_implcxx . . $ ggml_acc_impl(5043d0b8ee1f0fa6).(ctx, cgraph->grads[isrc], tensor, nb1, nb2, nb3, offset, cgraph->grad_accs[isrc]); |
| 5977 | } else { |
| 5978 | struct ggml_tensor * a_zero = ggml_scalecxx . . $ ggml_scale(2b9396bfe07630bc).(ctx, src, 0.0f); // FIXME this is going to produce NaN if a contains inf/NaN |
| 5979 | cgraph->grads[isrc] = ggml_acc_implcxx . . $ ggml_acc_impl(5043d0b8ee1f0fa6).(ctx, a_zero, tensor, nb1, nb2, nb3, offset, false); |
| 5980 | } |
| 5981 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(cgraph->grads[isrc], "grad for %s", cgraph->visited_hash_set.keys[isrc]->name); |
| 5982 | ggml_build_forward_expand(cgraph, cgraph->grads[isrc]); |
| 5983 | } |
| 5984 | |
| 5985 | static void ggml_add1_or_setcxx . . $ ggml_add1_or_set(5a8dd03e61f01a29).( |
| 5986 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 5987 | struct ggml_cgraph * cgraph, |
| 5988 | size_t isrc, |
| 5989 | struct ggml_tensor * tensor) { |
| 5990 | struct ggml_tensor * src = cgraph->visited_hash_set.keys[isrc]; |
| 5991 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(src); |
| 5992 | if (cgraph->grads[isrc]) { |
| 5993 | cgraph->grads[isrc] = ggml_add1_implcxx . . $ ggml_add1_impl(68ee738007d49a26).(ctx, cgraph->grads[isrc], tensor, cgraph->grad_accs[isrc]); |
| 5994 | } else { |
| 5995 | cgraph->grads[isrc] = ggml_repeatcxx . . $ ggml_repeat(590e8193bb8aebeb).(ctx, tensor, src); |
| 5996 | } |
| 5997 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(cgraph->grads[isrc], "grad for %s", src->name); |
| 5998 | ggml_build_forward_expand(cgraph, cgraph->grads[isrc]); |
| 5999 | } |
| 6000 | |
| 6001 | static void ggml_sub_or_setcxx . . $ ggml_sub_or_set(5a8dd03e61f01a29).( |
| 6002 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 6003 | struct ggml_cgraph * cgraph, |
| 6004 | size_t isrc, |
| 6005 | struct ggml_tensor * tensor) { |
| 6006 | struct ggml_tensor * src = cgraph->visited_hash_set.keys[isrc]; |
| 6007 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(src); |
| 6008 | if (cgraph->grads[isrc]) { |
| 6009 | cgraph->grads[isrc] = ggml_sub_implcxx . . $ ggml_sub_impl(68ee738007d49a26).(ctx, cgraph->grads[isrc], tensor, cgraph->grad_accs[isrc]); |
| 6010 | } else { |
| 6011 | cgraph->grads[isrc] = ggml_negcxx . . $ ggml_neg(71a7fa2ddee25242).(ctx, tensor); |
| 6012 | } |
| 6013 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(cgraph->grads[isrc], "grad for %s", src->name); |
| 6014 | ggml_build_forward_expand(cgraph, cgraph->grads[isrc]); |
| 6015 | } |
| 6016 | |
| 6017 | static void ggml_compute_backwardcxx . . $ ggml_compute_backward(e4625cee5d1fb532).( |
| 6018 | struct ggml_contextcxx . . $ ggml_context# * ctx, struct ggml_cgraph * cgraph, int i, const bool * grads_needed) { |
| 6019 | struct ggml_tensor * tensor = cgraph->nodes[i]; |
| 6020 | struct ggml_tensor * grad = ggml_graph_get_grad(cgraph, tensor); |
| 6021 | |
| 6022 | if (!grad) { |
| 6023 | return; |
| 6024 | } |
| 6025 | |
| 6026 | struct ggml_tensor * src0 = tensor->src[0]; |
| 6027 | struct ggml_tensor * src1 = tensor->src[1]; |
| 6028 | struct ggml_tensor * src2 = tensor->src[2]; |
| 6029 | struct ggml_hash_set * hash_set = &cgraph->visited_hash_set; |
| 6030 | const size_t isrc0 = src0 ? ggml_hash_find(hash_set, src0) : (size_t) -1; |
| 6031 | const size_t isrc1 = src1 ? ggml_hash_find(hash_set, src1) : (size_t) -1; |
| 6032 | const size_t isrc2 = src2 ? ggml_hash_find(hash_set, src2) : (size_t) -1; |
| 6033 | const bool src0_needs_grads = src0 && isrc0 != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! && ggml_bitset_get(hash_set->used, isrc0) && grads_needed[isrc0]; |
| 6034 | const bool src1_needs_grads = src1 && isrc1 != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! && ggml_bitset_get(hash_set->used, isrc1) && grads_needed[isrc1]; |
| 6035 | const bool src2_needs_grads = src2 && isrc2 != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! && ggml_bitset_get(hash_set->used, isrc2) && grads_needed[isrc2]; |
| 6036 | |
| 6037 | switch (tensor->op) { |
| 6038 | case GGML_OP_DUP: { |
| 6039 | if (src0_needs_grads) { |
| 6040 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6041 | } |
| 6042 | } break; |
| 6043 | case GGML_OP_ADD: { |
| 6044 | if (src0_needs_grads) { |
| 6045 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6046 | } |
| 6047 | if (src1_needs_grads) { |
| 6048 | struct ggml_tensor * tmp = grad; |
| 6049 | if (!ggml_are_same_shapecxx . . $ ggml_are_same_shape(3bd891636d1661b7).(src0, src1)) { |
| 6050 | tmp = ggml_repeat_backcxx . . $ ggml_repeat_back(590e8193bb8aebeb).(ctx, tmp, src1); |
| 6051 | } |
| 6052 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, tmp); |
| 6053 | } |
| 6054 | } break; |
| 6055 | case GGML_OP_ADD1: { |
| 6056 | if (src0_needs_grads) { |
| 6057 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6058 | } |
| 6059 | if (src1_needs_grads) { |
| 6060 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, ggml_meancxx . . $ ggml_mean(71a7fa2ddee25242).(ctx, grad)); // TODO: should probably be sum instead of mean |
| 6061 | } |
| 6062 | } break; |
| 6063 | case GGML_OP_ACC: { |
| 6064 | if (src0_needs_grads) { |
| 6065 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6066 | } |
| 6067 | if (src1_needs_grads) { |
| 6068 | const size_t nb1 = ((int32_tcxx . . $ int32_t# *) tensor->op_params)[0]; |
| 6069 | const size_t nb2 = ((int32_tcxx . . $ int32_t# *) tensor->op_params)[1]; |
| 6070 | const size_t nb3 = ((int32_tcxx . . $ int32_t# *) tensor->op_params)[2]; |
| 6071 | const size_t offset = ((int32_tcxx . . $ int32_t# *) tensor->op_params)[3]; |
| 6072 | |
| 6073 | struct ggml_tensor * tensor_grad_view = ggml_view_4dcxx . . $ ggml_view_4d(57a2df61c58fa26c).(ctx, |
| 6074 | grad, src1->ne[0], src1->ne[1], src1->ne[2], src1->ne[3], |
| 6075 | nb1, nb2, nb3, offset); |
| 6076 | |
| 6077 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, ggml_reshapecxx . . $ ggml_reshape(590e8193bb8aebeb).(ctx, ggml_contcxx . . $ ggml_cont(71a7fa2ddee25242).(ctx, tensor_grad_view), src1)); |
| 6078 | } |
| 6079 | } break; |
| 6080 | case GGML_OP_SUB: { |
| 6081 | if (src0_needs_grads) { |
| 6082 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6083 | } |
| 6084 | if (src1_needs_grads) { |
| 6085 | ggml_sub_or_setcxx . . $ ggml_sub_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, grad); |
| 6086 | } |
| 6087 | } break; |
| 6088 | case GGML_OP_MUL: { |
| 6089 | if (src0_needs_grads) { |
| 6090 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, src1)); |
| 6091 | } |
| 6092 | if (src1_needs_grads) { |
| 6093 | struct ggml_tensor * tmp = ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, src0, grad); |
| 6094 | if (!ggml_are_same_shapecxx . . $ ggml_are_same_shape(3bd891636d1661b7).(src0, src1)) { |
| 6095 | tmp = ggml_repeat_backcxx . . $ ggml_repeat_back(590e8193bb8aebeb).(ctx, tmp, src1); |
| 6096 | } |
| 6097 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, tmp); |
| 6098 | } |
| 6099 | } break; |
| 6100 | case GGML_OP_DIV: { |
| 6101 | if (src0_needs_grads) { |
| 6102 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_divcxx . . $ ggml_div(590e8193bb8aebeb).(ctx, grad, src1)); |
| 6103 | } |
| 6104 | if (src1_needs_grads) { |
| 6105 | ggml_sub_or_setcxx . . $ ggml_sub_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, ggml_divcxx . . $ ggml_div(590e8193bb8aebeb).(ctx, tensor, src1))); |
| 6106 | } |
| 6107 | } break; |
| 6108 | case GGML_OP_SQR: { |
| 6109 | if (src0_needs_grads) { |
| 6110 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_scalecxx . . $ ggml_scale(2b9396bfe07630bc).(ctx, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, src0, grad), 2.0f)); |
| 6111 | } |
| 6112 | } break; |
| 6113 | case GGML_OP_SQRT: { |
| 6114 | if (src0_needs_grads) { |
| 6115 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_scalecxx . . $ ggml_scale(2b9396bfe07630bc).(ctx, ggml_divcxx . . $ ggml_div(590e8193bb8aebeb).(ctx, grad, tensor), 0.5f)); |
| 6116 | } |
| 6117 | } break; |
| 6118 | case GGML_OP_LOG: { |
| 6119 | if (src0_needs_grads) { |
| 6120 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_divcxx . . $ ggml_div(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6121 | } |
| 6122 | } break; |
| 6123 | case GGML_OP_SIN: { |
| 6124 | if (src0_needs_grads) { |
| 6125 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, ggml_coscxx . . $ ggml_cos(71a7fa2ddee25242).(ctx, src0))); |
| 6126 | } |
| 6127 | } break; |
| 6128 | case GGML_OP_COS: { |
| 6129 | if (src0_needs_grads) { |
| 6130 | ggml_sub_or_setcxx . . $ ggml_sub_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, ggml_sincxx . . $ ggml_sin(71a7fa2ddee25242).(ctx, src0))); |
| 6131 | } |
| 6132 | } break; |
| 6133 | case GGML_OP_SUM: { |
| 6134 | if (src0_needs_grads) { |
| 6135 | ggml_add1_or_setcxx . . $ ggml_add1_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6136 | } |
| 6137 | } break; |
| 6138 | case GGML_OP_SUM_ROWS: { |
| 6139 | if (src0_needs_grads) { |
| 6140 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_repeatcxx . . $ ggml_repeat(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6141 | } |
| 6142 | } break; |
| 6143 | case GGML_OP_MEAN: { |
| 6144 | if (src0_needs_grads) { |
| 6145 | ggml_add1_or_setcxx . . $ ggml_add1_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).(ctx, grad, 1.0f/src0->ne[0], 0.0, false)); |
| 6146 | } |
| 6147 | } break; |
| 6148 | case GGML_OP_REPEAT: { |
| 6149 | if (src0_needs_grads) { |
| 6150 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_repeat_backcxx . . $ ggml_repeat_back(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6151 | } |
| 6152 | } break; |
| 6153 | case GGML_OP_REPEAT_BACK: { |
| 6154 | if (src0_needs_grads) { |
| 6155 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_repeatcxx . . $ ggml_repeat(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6156 | } |
| 6157 | } break; |
| 6158 | case GGML_OP_RMS_NORM: { |
| 6159 | if (src0_needs_grads) { |
| 6160 | float eps; |
| 6161 | memcpy(&eps, tensor->op_params, sizeof(float)); |
| 6162 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_rms_norm_backcxx . . $ ggml_rms_norm_back(e71eeb674f62ec63).(ctx, grad, src0, eps)); |
| 6163 | } |
| 6164 | } break; |
| 6165 | case GGML_OP_MUL_MAT: { |
| 6166 | // https://cs231n.github.io/optimization-2/#staged |
| 6167 | // # forward pass |
| 6168 | // s0 = np.random.randn(5, 10) |
| 6169 | // s1 = np.random.randn(10, 3) |
| 6170 | // t = s0.dot(s1) |
| 6171 | |
| 6172 | // # now suppose we had the gradient on t from above in the circuit |
| 6173 | // dt = np.random.randn(*t.shape) # same shape as t |
| 6174 | // ds0 = dt.dot(s1.T) #.T gives the transpose of the matrix |
| 6175 | // ds1 = t.T.dot(dt) |
| 6176 | |
| 6177 | // tensor.shape [m,p,qq,rr] |
| 6178 | // src0.shape [n,m,q1,r1] |
| 6179 | // src1.shape [n,p,qq,rr] |
| 6180 | |
| 6181 | if (src0_needs_grads) { |
| 6182 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(grad->ne[2] == src1->ne[2]); |
| 6183 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(grad->ne[3] == src1->ne[3]); |
| 6184 | struct ggml_tensor * tmp = |
| 6185 | ggml_out_prodcxx . . $ ggml_out_prod(590e8193bb8aebeb).(ctx, // [n,m,qq,rr] |
| 6186 | src1, // [n,p,qq,rr] |
| 6187 | grad); // [m,p,qq,rr] |
| 6188 | if (!ggml_are_same_shapecxx . . $ ggml_are_same_shape(3bd891636d1661b7).(tmp, src0)) { |
| 6189 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tmp->ne[0] == src0->ne[0]); |
| 6190 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tmp->ne[1] == src0->ne[1]); |
| 6191 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tmp->ne[3] == 1); |
| 6192 | |
| 6193 | const int64_tcxx . . $ int64_t# nr2 = tmp->ne[2] / src0->ne[2]; |
| 6194 | const size_t nb2 = tmp->nb[2] * nr2; |
| 6195 | const size_t nb3 = tmp->nb[2]; |
| 6196 | |
| 6197 | tmp = ggml_view_4dcxx . . $ ggml_view_4d(57a2df61c58fa26c).(ctx, tmp, src0->ne[0], src0->ne[1], src0->ne[2], nr2, tmp->nb[1], nb2, nb3, 0); |
| 6198 | tmp = ggml_repeat_backcxx . . $ ggml_repeat_back(590e8193bb8aebeb).(ctx, tmp, src0); |
| 6199 | } |
| 6200 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, tmp); |
| 6201 | } |
| 6202 | if (src1_needs_grads) { |
| 6203 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, |
| 6204 | // ggml_mul_mat(ctx, // [n,p,qq,rr] |
| 6205 | // ggml_cont(ctx, // [m,n,q1,r1] |
| 6206 | // ggml_transpose(ctx, src0)), // [m,n,q1,r1] |
| 6207 | // grad), // [m,p,qq,rr] |
| 6208 | |
| 6209 | // when src0 is bigger than tensor->grad (this is mostly the case in llama), |
| 6210 | // avoid transpose of src0, rather transpose smaller tensor->grad |
| 6211 | // and then use ggml_out_prod |
| 6212 | ggml_out_prodcxx . . $ ggml_out_prod(590e8193bb8aebeb).(ctx, // [n,p,qq,rr] |
| 6213 | src0, // [n,m,q1,r1] |
| 6214 | ggml_transposecxx . . $ ggml_transpose(71a7fa2ddee25242).(ctx, // [p,m,qq,rr] |
| 6215 | grad))); // [m,p,qq,rr] |
| 6216 | } |
| 6217 | } break; |
| 6218 | case GGML_OP_SCALE: { |
| 6219 | if (src0_needs_grads) { |
| 6220 | float s; |
| 6221 | memcpy(&s, tensor->op_params, sizeof(float)); |
| 6222 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_scale_implcxx . . $ ggml_scale_impl(4cddb4148e1beb7e).(ctx, grad, s, 0.0, false)); |
| 6223 | } |
| 6224 | } break; |
| 6225 | case GGML_OP_SET: { |
| 6226 | const size_t nb1 = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[0]; |
| 6227 | const size_t nb2 = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[1]; |
| 6228 | const size_t nb3 = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[2]; |
| 6229 | const size_t offset = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[3]; |
| 6230 | |
| 6231 | struct ggml_tensor * tensor_grad_view = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 6232 | |
| 6233 | if (src0_needs_grads || src1_needs_grads) { |
| 6234 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(src0->type == tensor->type); |
| 6235 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!cgraph->grads[isrc0] || cgraph->grads[isrc0]->type == grad->type); |
| 6236 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!cgraph->grads[isrc1] || !src1_needs_grads || cgraph->grads[isrc1]->type == grad->type); |
| 6237 | |
| 6238 | tensor_grad_view = ggml_view_4dcxx . . $ ggml_view_4d(57a2df61c58fa26c).(ctx, |
| 6239 | grad, src1->ne[0], src1->ne[1], src1->ne[2], src1->ne[3], |
| 6240 | nb1, nb2, nb3, offset); |
| 6241 | } |
| 6242 | |
| 6243 | if (src0_needs_grads) { |
| 6244 | struct ggml_tensor * tmp = ggml_negcxx . . $ ggml_neg(71a7fa2ddee25242).(ctx, tensor_grad_view); |
| 6245 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_acc_implcxx . . $ ggml_acc_impl(5043d0b8ee1f0fa6).(ctx, grad, tmp, nb1, nb2, nb3, offset, false)); |
| 6246 | } |
| 6247 | |
| 6248 | if (src1_needs_grads) { |
| 6249 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, ggml_reshapecxx . . $ ggml_reshape(590e8193bb8aebeb).(ctx, ggml_contcxx . . $ ggml_cont(71a7fa2ddee25242).(ctx, tensor_grad_view), src1)); |
| 6250 | } |
| 6251 | } break; |
| 6252 | case GGML_OP_CPY: { |
| 6253 | // cpy overwrites value of src1 by src0 and returns view(src1) |
| 6254 | // the overwriting is mathematically equivalent to: |
| 6255 | // tensor = src0 * 1 + src1 * 0 |
| 6256 | if (src0_needs_grads) { |
| 6257 | // dsrc0 = dtensor * 1 |
| 6258 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_reshapecxx . . $ ggml_reshape(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6259 | } |
| 6260 | if (src1_needs_grads) { |
| 6261 | // dsrc1 = dtensor * 0 -> noop |
| 6262 | } |
| 6263 | } break; |
| 6264 | case GGML_OP_CONT: { |
| 6265 | // same as cpy |
| 6266 | if (src0_needs_grads) { |
| 6267 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!cgraph->grads[isrc0] || ggml_is_contiguous(cgraph->grads[isrc0])); |
| 6268 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_contiguous(grad)); |
| 6269 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_nelements(tensor) == ggml_nelements(src0)); |
| 6270 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, |
| 6271 | ggml_are_same_shapecxx . . $ ggml_are_same_shape(3bd891636d1661b7).(tensor, src0) ? grad : ggml_reshapecxx . . $ ggml_reshape(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6272 | } |
| 6273 | } break; |
| 6274 | case GGML_OP_RESHAPE: { |
| 6275 | if (src0_needs_grads) { |
| 6276 | struct ggml_tensor * grad_cont = ggml_is_contiguouscxx . . $ ggml_is_contiguous(8fa73a561a000eab).(grad) ? grad : ggml_contcxx . . $ ggml_cont(71a7fa2ddee25242).(ctx, grad); |
| 6277 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_reshapecxx . . $ ggml_reshape(590e8193bb8aebeb).(ctx, grad_cont, src0)); |
| 6278 | } |
| 6279 | } break; |
| 6280 | case GGML_OP_VIEW: { |
| 6281 | if (src0_needs_grads) { |
| 6282 | size_t offset; |
| 6283 | |
| 6284 | memcpy(&offset, tensor->op_params, sizeof(offset)); |
| 6285 | |
| 6286 | size_t nb1 = tensor->nb[1]; |
| 6287 | size_t nb2 = tensor->nb[2]; |
| 6288 | size_t nb3 = tensor->nb[3]; |
| 6289 | |
| 6290 | if (cgraph->grads[isrc0] && src0->type != cgraph->grads[isrc0]->type) { |
| 6291 | // gradient is typically F32, but src0 could be other type |
| 6292 | size_t ng = ggml_element_sizecxx . . $ ggml_element_size(7f354dd711c66cf7).(cgraph->grads[isrc0]); |
| 6293 | size_t n0 = ggml_element_sizecxx . . $ ggml_element_size(7f354dd711c66cf7).(src0); |
| 6294 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(offset % n0 == 0); |
| 6295 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(nb1 % n0 == 0); |
| 6296 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(nb2 % n0 == 0); |
| 6297 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(nb3 % n0 == 0); |
| 6298 | offset = (offset / n0) * ng; |
| 6299 | nb1 = (nb1 / n0) * ng; |
| 6300 | nb2 = (nb2 / n0) * ng; |
| 6301 | nb3 = (nb3 / n0) * ng; |
| 6302 | } |
| 6303 | |
| 6304 | ggml_acc_or_setcxx . . $ ggml_acc_or_set(c21f677098863802).(ctx, cgraph, isrc0, grad, nb1, nb2, nb3, offset); |
| 6305 | } |
| 6306 | } break; |
| 6307 | case GGML_OP_PERMUTE: { |
| 6308 | if (src0_needs_grads) { |
| 6309 | const int32_tcxx . . $ int32_t# * axes = (const int32_tcxx . . $ int32_t# *) tensor->op_params; |
| 6310 | const int axis0 = axes[0] & 0x3; |
| 6311 | const int axis1 = axes[1] & 0x3; |
| 6312 | const int axis2 = axes[2] & 0x3; |
| 6313 | const int axis3 = axes[3] & 0x3; |
| 6314 | int axb[4] = {0,0,0,0}; // axes backward |
| 6315 | axb[axis0] = 0; |
| 6316 | axb[axis1] = 1; |
| 6317 | axb[axis2] = 2; |
| 6318 | axb[axis3] = 3; |
| 6319 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_permutecxx . . $ ggml_permute(1642edaa96518f7e).(ctx, grad, axb[0], axb[1], axb[2], axb[3])); |
| 6320 | } |
| 6321 | } break; |
| 6322 | case GGML_OP_TRANSPOSE: { |
| 6323 | if (src0_needs_grads) { |
| 6324 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_transposecxx . . $ ggml_transpose(71a7fa2ddee25242).(ctx, grad)); |
| 6325 | } |
| 6326 | } break; |
| 6327 | case GGML_OP_GET_ROWS: { |
| 6328 | if (src0_needs_grads) { |
| 6329 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_get_rows_backcxx . . $ ggml_get_rows_back(28fd2ad14bf2989).(ctx, grad, src1, src0)); |
| 6330 | } |
| 6331 | if (src1_needs_grads) { |
| 6332 | // noop |
| 6333 | } |
| 6334 | } break; |
| 6335 | case GGML_OP_DIAG_MASK_INF: { |
| 6336 | if (src0_needs_grads) { |
| 6337 | /* ggml_diag_mask_inf_impl() shouldn't be here */ |
| 6338 | /* ref: https://github.com/ggml-org/llama.cpp/pull/4203#discussion_r1412377992 */ |
| 6339 | const int n_past = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[0]; |
| 6340 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_diag_mask_zero_implcxx . . $ ggml_diag_mask_zero_impl(4cd2a9fe5c83eb9e).(ctx, grad, n_past, false)); |
| 6341 | } |
| 6342 | } break; |
| 6343 | case GGML_OP_DIAG_MASK_ZERO: { |
| 6344 | if (src0_needs_grads) { |
| 6345 | const int n_past = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[0]; |
| 6346 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_diag_mask_zero_implcxx . . $ ggml_diag_mask_zero_impl(4cd2a9fe5c83eb9e).(ctx, grad, n_past, false)); |
| 6347 | } |
| 6348 | } break; |
| 6349 | case GGML_OP_SOFT_MAX: { |
| 6350 | if (src0_needs_grads) { |
| 6351 | float scale = 1.0f; |
| 6352 | float max_bias = 0.0f; |
| 6353 | |
| 6354 | memcpy(&scale, (const float *) tensor->op_params + 0, sizeof(float)); |
| 6355 | memcpy(&max_bias, (const float *) tensor->op_params + 1, sizeof(float)); |
| 6356 | |
| 6357 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_soft_max_ext_backcxx . . $ ggml_soft_max_ext_back(815f2d07c0da5a9c).(ctx, grad, tensor, scale, max_bias)); |
| 6358 | } |
| 6359 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((!src1 || !src1_needs_grads) && "backward pass for softmax mask not implemented"); |
| 6360 | } break; |
| 6361 | case GGML_OP_ROPE: { |
| 6362 | if (src0_needs_grads) { |
| 6363 | //const int n_past = ((int32_t *) tensor->op_params)[0]; |
| 6364 | const int n_dims = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[1]; |
| 6365 | const int mode = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[2]; |
| 6366 | //const int n_ctx = ((int32_t *) tensor->op_params)[3]; |
| 6367 | const int n_ctx_orig = ((const int32_tcxx . . $ int32_t# *) tensor->op_params)[4]; |
| 6368 | float freq_base, freq_scale, ext_factor, attn_factor, beta_fast, beta_slow; |
| 6369 | int sections[4] = {0, 0, 0, 0}; |
| 6370 | |
| 6371 | memcpy(&freq_base, (const float *) tensor->op_params + 5, sizeof(float)); |
| 6372 | memcpy(&freq_scale, (const float *) tensor->op_params + 6, sizeof(float)); |
| 6373 | memcpy(&ext_factor, (const float *) tensor->op_params + 7, sizeof(float)); |
| 6374 | memcpy(&attn_factor, (const float *) tensor->op_params + 8, sizeof(float)); |
| 6375 | memcpy(&beta_fast, (const float *) tensor->op_params + 9, sizeof(float)); |
| 6376 | memcpy(&beta_slow, (const float *) tensor->op_params + 10, sizeof(float)); |
| 6377 | memcpy(§ions, tensor->op_params + 11, sizeof(sections)); |
| 6378 | |
| 6379 | struct ggml_tensor * rope_back = grad->ne[2] == src1->ne[0] ? |
| 6380 | ggml_rope_ext_backcxx . . $ ggml_rope_ext_back(da69a26837edcf2d).(ctx, grad, src1, src2, n_dims, |
| 6381 | mode, n_ctx_orig, freq_base, freq_scale, ext_factor, attn_factor, beta_fast, beta_slow) : |
| 6382 | ggml_rope_multi_backcxx . . $ ggml_rope_multi_back(f619456346d7ed7e).(ctx, grad, src1, src2, n_dims, sections, |
| 6383 | mode, n_ctx_orig, freq_base, freq_scale, ext_factor, attn_factor, beta_fast, beta_slow); |
| 6384 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, rope_back); |
| 6385 | } |
| 6386 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!((!src2 || !src2_needs_grads) && "gradients for freq factors not implemented"); |
| 6387 | } break; |
| 6388 | case GGML_OP_IM2COL: { |
| 6389 | if (src1_needs_grads) { |
| 6390 | const int32_tcxx . . $ int32_t# s0 = ggml_get_op_params_i32(tensor, 0); |
| 6391 | const int32_tcxx . . $ int32_t# s1 = ggml_get_op_params_i32(tensor, 1); |
| 6392 | const int32_tcxx . . $ int32_t# p0 = ggml_get_op_params_i32(tensor, 2); |
| 6393 | const int32_tcxx . . $ int32_t# p1 = ggml_get_op_params_i32(tensor, 3); |
| 6394 | const int32_tcxx . . $ int32_t# d0 = ggml_get_op_params_i32(tensor, 4); |
| 6395 | const int32_tcxx . . $ int32_t# d1 = ggml_get_op_params_i32(tensor, 5); |
| 6396 | const bool is_2D = ggml_get_op_params_i32(tensor, 6) == 1; |
| 6397 | |
| 6398 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, ggml_im2col_backcxx . . $ ggml_im2col_back(e0dc01b407788623).(ctx, grad, src0, src1->ne, s0, s1, p0, p1, d0, d1, is_2D)); |
| 6399 | } |
| 6400 | } break; |
| 6401 | case GGML_OP_POOL_2D: { |
| 6402 | if (src0_needs_grads) { |
| 6403 | const enum ggml_op_pool op = (enum ggml_op_pool) ggml_get_op_params_i32(tensor, 0); |
| 6404 | const int32_tcxx . . $ int32_t# k0 = ggml_get_op_params_i32(tensor, 1); |
| 6405 | const int32_tcxx . . $ int32_t# k1 = ggml_get_op_params_i32(tensor, 2); |
| 6406 | const int32_tcxx . . $ int32_t# s0 = ggml_get_op_params_i32(tensor, 3); |
| 6407 | const int32_tcxx . . $ int32_t# s1 = ggml_get_op_params_i32(tensor, 4); |
| 6408 | const int32_tcxx . . $ int32_t# p0 = ggml_get_op_params_i32(tensor, 5); |
| 6409 | const int32_tcxx . . $ int32_t# p1 = ggml_get_op_params_i32(tensor, 6); |
| 6410 | |
| 6411 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_pool_2d_backcxx . . $ ggml_pool_2d_back(6f799d6eb64995c2).(ctx, grad, src0, op, k0, k1, s0, s1, p0, p1)); |
| 6412 | } |
| 6413 | } break; |
| 6414 | case GGML_OP_WIN_PART: |
| 6415 | case GGML_OP_WIN_UNPART: |
| 6416 | case GGML_OP_UNARY: { |
| 6417 | switch (ggml_get_unary_opcxx . . $ ggml_get_unary_op(cb5a4dbbb5018590).(tensor)) { |
| 6418 | case GGML_UNARY_OP_ABS: { |
| 6419 | if (src0_needs_grads) { |
| 6420 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, ggml_sgncxx . . $ ggml_sgn(71a7fa2ddee25242).(ctx, src0), grad)); |
| 6421 | } |
| 6422 | } break; |
| 6423 | case GGML_UNARY_OP_SGN: { |
| 6424 | // noop |
| 6425 | } break; |
| 6426 | case GGML_UNARY_OP_NEG: { |
| 6427 | if (src0_needs_grads) { |
| 6428 | ggml_sub_or_setcxx . . $ ggml_sub_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, grad); |
| 6429 | } |
| 6430 | } break; |
| 6431 | case GGML_UNARY_OP_STEP: { |
| 6432 | // noop |
| 6433 | } break; |
| 6434 | case GGML_UNARY_OP_RELU: { |
| 6435 | if (src0_needs_grads) { |
| 6436 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, ggml_stepcxx . . $ ggml_step(71a7fa2ddee25242).(ctx, src0), grad)); |
| 6437 | } |
| 6438 | } break; |
| 6439 | case GGML_UNARY_OP_SILU: { |
| 6440 | if (src0_needs_grads) { |
| 6441 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_silu_backcxx . . $ ggml_silu_back(590e8193bb8aebeb).(ctx, grad, src0)); |
| 6442 | } |
| 6443 | } break; |
| 6444 | case GGML_UNARY_OP_EXP: { |
| 6445 | if (src0_needs_grads) { |
| 6446 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, tensor, grad)); |
| 6447 | } |
| 6448 | } break; |
| 6449 | case GGML_UNARY_OP_EXPM1: { |
| 6450 | if (src0_needs_grads) { |
| 6451 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, ggml_expcxx . . $ ggml_exp(71a7fa2ddee25242).(ctx, src0))); |
| 6452 | } |
| 6453 | } break; |
| 6454 | case GGML_UNARY_OP_SOFTPLUS: { |
| 6455 | if (src0_needs_grads) { |
| 6456 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, ggml_sigmoidcxx . . $ ggml_sigmoid(71a7fa2ddee25242).(ctx, src0))); |
| 6457 | } |
| 6458 | } break; |
| 6459 | default: { |
| 6460 | fprintf(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unsupported unary op for backward pass: %s\n", |
| 6461 | __func__, ggml_unary_op_namecxx . . $ ggml_unary_op_name(6193ecfe3adce77e).(ggml_get_unary_opcxx . . $ ggml_get_unary_op(cb5a4dbbb5018590).(tensor))); |
| 6462 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("fatal error"); |
| 6463 | } //break; |
| 6464 | } |
| 6465 | } break; |
| 6466 | case GGML_OP_CROSS_ENTROPY_LOSS: { |
| 6467 | if (src0_needs_grads) { |
| 6468 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_cross_entropy_loss_backcxx . . $ ggml_cross_entropy_loss_back(28fd2ad14bf2989).(ctx, grad, src0, src1)); |
| 6469 | } |
| 6470 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!src1_needs_grads && "backward pass for labels not implemented"); |
| 6471 | } break; |
| 6472 | case GGML_OP_GLU: { |
| 6473 | switch (ggml_get_glu_opcxx . . $ ggml_get_glu_op(cad6722f31ecc9b4).(tensor)) { |
| 6474 | case GGML_GLU_OP_SWIGLU: { |
| 6475 | if (src0_needs_grads) { |
| 6476 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(src1 && "backward pass only implemented for split swiglu"); |
| 6477 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc0, ggml_silu_backcxx . . $ ggml_silu_back(590e8193bb8aebeb).(ctx, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, grad, src1), src0)); |
| 6478 | } |
| 6479 | if (src1_needs_grads) { |
| 6480 | ggml_add_or_setcxx . . $ ggml_add_or_set(5a8dd03e61f01a29).(ctx, cgraph, isrc1, ggml_mulcxx . . $ ggml_mul(590e8193bb8aebeb).(ctx, ggml_silucxx . . $ ggml_silu(71a7fa2ddee25242).(ctx, src0), grad)); |
| 6481 | } |
| 6482 | } break; |
| 6483 | default: { |
| 6484 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("unsupported glu op for backward pass: %s", ggml_glu_op_name(ggml_get_glu_op(tensor))); |
| 6485 | } //break; |
| 6486 | } |
| 6487 | } break; |
| 6488 | case GGML_OP_NONE: { |
| 6489 | // noop |
| 6490 | } break; |
| 6491 | case GGML_OP_COUNT: |
| 6492 | default: { |
| 6493 | GGML_ABORTcxx . . $ `external/whispercpp/ggml.h:299:9`!("%s: unsupported ggml op for backward pass: %s\n", __func__, ggml_op_name(tensor->op)); |
| 6494 | } //break; |
| 6495 | } |
| 6496 | |
| 6497 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!src0_needs_grads || ggml_are_same_shape(src0, cgraph->grads[isrc0])); |
| 6498 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!src1_needs_grads || ggml_are_same_shape(src1, cgraph->grads[isrc1])); |
| 6499 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!src2_needs_grads || ggml_are_same_shape(src2, cgraph->grads[isrc2])); |
| 6500 | } |
| 6501 | |
| 6502 | static size_t ggml_visit_parents_graphcxx . . $ ggml_visit_parents_graph(378478e3e9312d95).(struct ggml_cgraph * cgraph, struct ggml_tensor * node, bool compute) { |
| 6503 | if (node->op != GGML_OP_NONE && compute) { |
| 6504 | node->flags |= GGML_TENSOR_FLAG_COMPUTE; |
| 6505 | } |
| 6506 | |
| 6507 | const size_t node_hash_pos = ggml_hash_find(&cgraph->visited_hash_set, node); |
| 6508 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(node_hash_pos != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`!); |
| 6509 | |
| 6510 | if (ggml_bitset_get(cgraph->visited_hash_set.used, node_hash_pos)) { |
| 6511 | // already visited |
| 6512 | |
| 6513 | if (compute) { |
| 6514 | // update the compute flag regardless |
| 6515 | for (int i = 0; i < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!; ++i) { |
| 6516 | struct ggml_tensor * src = node->src[i]; |
| 6517 | if (src && ((src->flags & GGML_TENSOR_FLAG_COMPUTE) == 0)) { |
| 6518 | ggml_visit_parents_graphcxx . . $ ggml_visit_parents_graph(378478e3e9312d95).(cgraph, src, true); |
| 6519 | } |
| 6520 | } |
| 6521 | } |
| 6522 | |
| 6523 | return node_hash_pos; |
| 6524 | } |
| 6525 | |
| 6526 | // This is the first time we see this node in the current graph. |
| 6527 | cgraph->visited_hash_set.keys[node_hash_pos] = node; |
| 6528 | ggml_bitset_set(cgraph->visited_hash_set.used, node_hash_pos); |
| 6529 | cgraph->use_counts[node_hash_pos] = 0; |
| 6530 | |
| 6531 | for (int i = 0; i < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!; ++i) { |
| 6532 | const int k = |
| 6533 | (cgraph->order == GGML_CGRAPH_EVAL_ORDER_LEFT_TO_RIGHT) ? i : |
| 6534 | (cgraph->order == GGML_CGRAPH_EVAL_ORDER_RIGHT_TO_LEFT) ? (GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!-1-i) : |
| 6535 | /* unknown order, just fall back to using i */ i; |
| 6536 | |
| 6537 | struct ggml_tensor * src = node->src[k]; |
| 6538 | if (src) { |
| 6539 | const size_t src_hash_pos = ggml_visit_parents_graphcxx . . $ ggml_visit_parents_graph(378478e3e9312d95).(cgraph, src, compute); |
| 6540 | |
| 6541 | // Update the use count for this operand. |
| 6542 | cgraph->use_counts[src_hash_pos]++; |
| 6543 | } |
| 6544 | } |
| 6545 | |
| 6546 | if (node->op == GGML_OP_NONE && !(node->flags & GGML_TENSOR_FLAG_PARAM)) { |
| 6547 | // reached a leaf node, not part of the gradient graph (e.g. a constant) |
| 6548 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->n_leafs < cgraph->size); |
| 6549 | |
| 6550 | if (strlen(node->name) == 0) { |
| 6551 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(node, "leaf_%d", cgraph->n_leafs); |
| 6552 | } |
| 6553 | |
| 6554 | cgraph->leafs[cgraph->n_leafs] = node; |
| 6555 | cgraph->n_leafs++; |
| 6556 | } else { |
| 6557 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->n_nodes < cgraph->size); |
| 6558 | |
| 6559 | if (strlen(node->name) == 0) { |
| 6560 | ggml_format_namecxx . . $ ggml_format_name(56668fa2bbf1299d).(node, "node_%d", cgraph->n_nodes); |
| 6561 | } |
| 6562 | |
| 6563 | cgraph->nodes[cgraph->n_nodes] = node; |
| 6564 | cgraph->n_nodes++; |
| 6565 | } |
| 6566 | |
| 6567 | return node_hash_pos; |
| 6568 | } |
| 6569 | |
| 6570 | static void ggml_build_forward_implcxx . . $ ggml_build_forward_impl(d48a6446d296e2ba).(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor, bool expand, bool compute) { |
| 6571 | if (!expand) { |
| 6572 | // TODO: this branch isn't accessible anymore, maybe move this to ggml_build_forward_expand |
| 6573 | ggml_graph_clear(cgraph); |
| 6574 | } |
| 6575 | |
| 6576 | const int n_old = cgraph->n_nodes; |
| 6577 | |
| 6578 | ggml_visit_parents_graphcxx . . $ ggml_visit_parents_graph(378478e3e9312d95).(cgraph, tensor, compute); |
| 6579 | |
| 6580 | const int n_new = cgraph->n_nodes - n_old; |
| 6581 | GGML_PRINT_DEBUGcxx . . $ `external/whispercpp/ggml-impl.h:128:9`!("%s: visited %d new nodes\n", __func__, n_new); |
| 6582 | |
| 6583 | if (n_new > 0) { |
| 6584 | // the last added node should always be starting point |
| 6585 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->nodes[cgraph->n_nodes - 1] == tensor); |
| 6586 | } |
| 6587 | } |
| 6588 | |
| 6589 | struct ggml_tensor * ggml_build_forward_selectcxx . . $ ggml_build_forward_select(b671db83e20b45cb).( |
| 6590 | struct ggml_cgraph * cgraph, |
| 6591 | struct ggml_tensor ** tensors, |
| 6592 | int n_tensors, |
| 6593 | int idx) { |
| 6594 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(idx >= 0 && idx < n_tensors); |
| 6595 | |
| 6596 | for (int i = 0; i < n_tensors; i++) { |
| 6597 | ggml_build_forward_implcxx . . $ ggml_build_forward_impl(d48a6446d296e2ba).(cgraph, tensors[i], true, i == idx ? true : false); |
| 6598 | } |
| 6599 | |
| 6600 | return tensors[idx]; |
| 6601 | } |
| 6602 | |
| 6603 | void ggml_build_forward_expandcxx . . $ ggml_build_forward_expand(9f1cb93022eb6b10).(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor) { |
| 6604 | ggml_build_forward_implcxx . . $ ggml_build_forward_impl(d48a6446d296e2ba).(cgraph, tensor, true, true); |
| 6605 | } |
| 6606 | |
| 6607 | void ggml_build_backward_expandcxx . . $ ggml_build_backward_expand(c9ed8590a5205c7a).( |
| 6608 | struct ggml_contextcxx . . $ ggml_context# * ctx, |
| 6609 | struct ggml_cgraph * cgraph, |
| 6610 | struct ggml_tensor ** grad_accs) { |
| 6611 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->n_nodes > 0); |
| 6612 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->grads); |
| 6613 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->grad_accs); |
| 6614 | |
| 6615 | const int n_nodes_f = cgraph->n_nodes; |
| 6616 | |
| 6617 | memset(cgraph->grads, 0, cgraph->visited_hash_set.size*sizeof(struct ggml_tensor *)); |
| 6618 | memset(cgraph->grad_accs, 0, cgraph->visited_hash_set.size*sizeof(struct ggml_tensor *)); |
| 6619 | bool * grads_needed = (bool *) GGML_CALLOCcxx . . $ `external/whispercpp/ggml.cpp:263:9`!(cgraph->visited_hash_set.size, sizeof(bool)); |
| 6620 | |
| 6621 | { |
| 6622 | bool any_params = false; |
| 6623 | bool any_loss = false; |
| 6624 | for (int i = 0; i < n_nodes_f; ++i) { |
| 6625 | struct ggml_tensor * node = cgraph->nodes[i]; |
| 6626 | any_params = any_params || (node->flags & GGML_TENSOR_FLAG_PARAM); |
| 6627 | any_loss = any_loss || (node->flags & GGML_TENSOR_FLAG_LOSS); |
| 6628 | } |
| 6629 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(any_params && "no trainable parameters found, did you forget to call ggml_set_param?"); |
| 6630 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(any_loss && "no training loss found, did you forget to call ggml_set_loss?"); |
| 6631 | } |
| 6632 | |
| 6633 | for (int i = 0; i < n_nodes_f; ++i) { |
| 6634 | struct ggml_tensor * node = cgraph->nodes[i]; |
| 6635 | |
| 6636 | if (node->type == GGML_TYPE_I32) { |
| 6637 | continue; |
| 6638 | } |
| 6639 | |
| 6640 | bool node_needs_grad = (node->flags & GGML_TENSOR_FLAG_PARAM) || (node->flags & GGML_TENSOR_FLAG_LOSS); |
| 6641 | bool ignore_src[GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!] = {false}; |
| 6642 | switch (node->op) { |
| 6643 | // gradients in node->src[0] for one reason or another have no effect on output gradients |
| 6644 | case GGML_OP_IM2COL: // only used for its shape |
| 6645 | case GGML_OP_IM2COL_BACK: // same as IM2COL |
| 6646 | ignore_src[0] = true; |
| 6647 | break; |
| 6648 | case GGML_OP_UNARY: { |
| 6649 | const enum ggml_unary_op uop = ggml_get_unary_opcxx . . $ ggml_get_unary_op(cb5a4dbbb5018590).(node); |
| 6650 | // SGN and STEP unary ops are piecewise constant |
| 6651 | if (uop == GGML_UNARY_OP_SGN || uop == GGML_UNARY_OP_STEP) { |
| 6652 | ignore_src[0] = true; |
| 6653 | } |
| 6654 | } break; |
| 6655 | |
| 6656 | // gradients in node->src[1] for one reason or another have no effect on output gradients |
| 6657 | case GGML_OP_CPY: // gradients in CPY target are irrelevant |
| 6658 | case GGML_OP_GET_ROWS: // row indices not differentiable |
| 6659 | case GGML_OP_GET_ROWS_BACK: // same as for GET_ROWS |
| 6660 | case GGML_OP_ROPE: // positions not differentiable |
| 6661 | ignore_src[1] = true; |
| 6662 | break; |
| 6663 | |
| 6664 | default: |
| 6665 | break; |
| 6666 | } |
| 6667 | for (int j = 0; j < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!; ++j) { |
| 6668 | if (!node->src[j] || ignore_src[j] || !grads_needed[ggml_hash_find(&cgraph->visited_hash_set, node->src[j])]) { |
| 6669 | continue; |
| 6670 | } |
| 6671 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(node->src[j]->type == GGML_TYPE_F32 || node->src[j]->type == GGML_TYPE_F16); |
| 6672 | node_needs_grad = true; |
| 6673 | break; |
| 6674 | } |
| 6675 | if (!node_needs_grad) { |
| 6676 | continue; |
| 6677 | } |
| 6678 | |
| 6679 | // inplace operations are currently not supported |
| 6680 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(!node->view_src || node->op == GGML_OP_CPY || node->op == GGML_OP_VIEW || |
| 6681 | node->op == GGML_OP_RESHAPE || node->op == GGML_OP_PERMUTE || node->op == GGML_OP_TRANSPOSE); |
| 6682 | |
| 6683 | const size_t ihash = ggml_hash_find(&cgraph->visited_hash_set, node); |
| 6684 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ihash != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`!); |
| 6685 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_bitset_get(cgraph->visited_hash_set.used, ihash)); |
| 6686 | if (grad_accs && grad_accs[i]) { |
| 6687 | cgraph->grad_accs[ihash] = grad_accs[i]; |
| 6688 | cgraph->grads[ihash] = cgraph->grad_accs[ihash]; |
| 6689 | } else if (node->flags & GGML_TENSOR_FLAG_LOSS) { |
| 6690 | // loss tensors always need a gradient accumulator |
| 6691 | cgraph->grad_accs[ihash] = ggml_new_tensorcxx . . $ ggml_new_tensor(ae09282da6049145).(ctx, GGML_TYPE_F32, GGML_MAX_DIMScxx . . $ `external/whispercpp/ggml.h:234:9`!, node->ne); |
| 6692 | cgraph->grads[ihash] = cgraph->grad_accs[ihash]; |
| 6693 | } |
| 6694 | grads_needed[ihash] = true; |
| 6695 | } |
| 6696 | |
| 6697 | for (int i = n_nodes_f - 1; i >= 0; --i) { |
| 6698 | // inplace operations to add gradients are not created by ggml_compute_backward except for gradient accumulation |
| 6699 | // use allocator to automatically make inplace operations |
| 6700 | ggml_compute_backwardcxx . . $ ggml_compute_backward(e4625cee5d1fb532).(ctx, cgraph, i, grads_needed); |
| 6701 | } |
| 6702 | |
| 6703 | GGML_FREEcxx . . $ `external/whispercpp/ggml.cpp:264:9`!(grads_needed); |
| 6704 | } |
| 6705 | |
| 6706 | static void * incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(void ** p, size_t size, size_t align) { |
| 6707 | void * ptr = *p; |
| 6708 | ptr = (void *) GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!((uintptr_t) ptr, align); |
| 6709 | *p = (void *) ((char *) ptr + size); |
| 6710 | return ptr; |
| 6711 | } |
| 6712 | |
| 6713 | static size_t ggml_graph_nbytescxx . . $ ggml_graph_nbytes(8140e894f0656832).(size_t size, bool grads) { |
| 6714 | size_t hash_size = ggml_hash_sizecxx . . $ ggml_hash_size(ecdaa1632f49f591).(size * 2); |
| 6715 | void * p = 0; |
| 6716 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, sizeof(struct ggml_cgraph), 1); |
| 6717 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // nodes |
| 6718 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // leafs |
| 6719 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(int32_tcxx . . $ int32_t#), sizeof(int32_tcxx . . $ int32_t#)); // use_counts |
| 6720 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // hash keys |
| 6721 | if (grads) { |
| 6722 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // grads |
| 6723 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); // grad_accs |
| 6724 | } |
| 6725 | incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, ggml_bitset_size(hash_size) * sizeof(ggml_bitset_t), sizeof(ggml_bitset_t)); |
| 6726 | |
| 6727 | size_t nbytes = (size_t) p; |
| 6728 | return nbytes; |
| 6729 | } |
| 6730 | |
| 6731 | size_t ggml_graph_overhead_customcxx . . $ ggml_graph_overhead_custom(8140e894f0656832).(size_t size, bool grads) { |
| 6732 | return GGML_OBJECT_SIZEcxx . . $ GGML_OBJECT_SIZE. + GGML_PADcxx . . $ `external/whispercpp/ggml.h:279:9`!(ggml_graph_nbytes(size, grads), GGML_MEM_ALIGNcxx . . $ `external/whispercpp/ggml.h:255:13`!); |
| 6733 | } |
| 6734 | |
| 6735 | size_t ggml_graph_overheadcxx . . $ ggml_graph_overhead(f708dce9a8856c70).(void) { |
| 6736 | return ggml_graph_overhead_customcxx . . $ ggml_graph_overhead_custom(8140e894f0656832).(GGML_DEFAULT_GRAPH_SIZEcxx . . $ `external/whispercpp/ggml.h:245:9`!, false); |
| 6737 | } |
| 6738 | |
| 6739 | struct ggml_cgraph * ggml_new_graph_customcxx . . $ ggml_new_graph_custom(c0f43f8ef08527ab).(struct ggml_contextcxx . . $ ggml_context# * ctx, size_t size, bool grads) { |
| 6740 | const size_t obj_size = ggml_graph_nbytescxx . . $ ggml_graph_nbytes(8140e894f0656832).(size, grads); |
| 6741 | struct ggml_objectcxx . . $ ggml_object# * obj = ggml_new_objectcxx . . $ ggml_new_object(bf5a29193a5c97c).(ctx, GGML_OBJECT_TYPE_GRAPH, obj_size); |
| 6742 | struct ggml_cgraph * cgraph = (struct ggml_cgraph *) ((char *) ctx->mem_buffercxx . . $ ggml_context#mem_buffer. + obj->offscxx . . $ ggml_object#offs.); |
| 6743 | |
| 6744 | // the size of the hash table is doubled since it needs to hold both nodes and leafs |
| 6745 | size_t hash_size = ggml_hash_sizecxx . . $ ggml_hash_size(ecdaa1632f49f591).(size * 2); |
| 6746 | |
| 6747 | void * p = cgraph + 1; |
| 6748 | |
| 6749 | struct ggml_tensor ** nodes_ptr = (struct ggml_tensor **) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); |
| 6750 | struct ggml_tensor ** leafs_ptr = (struct ggml_tensor **) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); |
| 6751 | int32_tcxx . . $ int32_t# * use_counts_ptr = (int32_tcxx . . $ int32_t# *) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(int32_tcxx . . $ int32_t#), sizeof(int32_tcxx . . $ int32_t#)); |
| 6752 | struct ggml_tensor ** hash_keys_ptr = (struct ggml_tensor **) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)); |
| 6753 | struct ggml_tensor ** grads_ptr = grads ? (struct ggml_tensor **) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 6754 | struct ggml_tensor ** grad_accs_ptr = grads ? (struct ggml_tensor **) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, hash_size * sizeof(struct ggml_tensor *), sizeof(struct ggml_tensor *)) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 6755 | |
| 6756 | ggml_bitset_t * hash_used = (ggml_bitset_t *) incr_ptr_alignedcxx . . $ incr_ptr_aligned(3bab819d1f50df18).(&p, ggml_bitset_size(hash_size) * sizeof(ggml_bitset_t), sizeof(ggml_bitset_t)); |
| 6757 | |
| 6758 | // check that we allocated the correct amount of memory |
| 6759 | assertcxx . . $ `/usr/include/assert.h:102:11`!(obj_size == (size_t)((char *)p - (char *)cgraph)); |
| 6760 | |
| 6761 | *cgraph = (struct ggml_cgraph) { |
| 6762 | /*.size =*/ (int) size, |
| 6763 | /*.n_nodes =*/ 0, |
| 6764 | /*.n_leafs =*/ 0, |
| 6765 | /*.nodes =*/ nodes_ptr, |
| 6766 | /*.grads =*/ grads_ptr, |
| 6767 | /*.grad_accs =*/ grad_accs_ptr, |
| 6768 | /*.leafs =*/ leafs_ptr, |
| 6769 | /*.use_counts =*/ use_counts_ptr, |
| 6770 | /*.hash_table =*/ { hash_size, hash_used, hash_keys_ptr }, |
| 6771 | /*.order =*/ GGML_CGRAPH_EVAL_ORDER_LEFT_TO_RIGHT, |
| 6772 | }; |
| 6773 | |
| 6774 | ggml_hash_set_resetcxx . . $ ggml_hash_set_reset(3b8f2cbb4a532df6).(&cgraph->visited_hash_set); |
| 6775 | if (grads) { |
| 6776 | memset(cgraph->grads, 0, hash_size*sizeof(struct ggml_tensor *)); |
| 6777 | memset(cgraph->grad_accs, 0, hash_size*sizeof(struct ggml_tensor *)); |
| 6778 | } |
| 6779 | |
| 6780 | return cgraph; |
| 6781 | } |
| 6782 | |
| 6783 | struct ggml_cgraph * ggml_new_graphcxx . . $ ggml_new_graph(69d7b3aaf19687ab).(struct ggml_contextcxx . . $ ggml_context# * ctx) { |
| 6784 | return ggml_new_graph_customcxx . . $ ggml_new_graph_custom(c0f43f8ef08527ab).(ctx, GGML_DEFAULT_GRAPH_SIZEcxx . . $ `external/whispercpp/ggml.h:245:9`!, false); |
| 6785 | } |
| 6786 | |
| 6787 | struct ggml_cgraph ggml_graph_viewcxx . . $ ggml_graph_view(10d4528099c9716e).(struct ggml_cgraph * cgraph0, int i0, int i1) { |
| 6788 | struct ggml_cgraph cgraph = { |
| 6789 | /*.size =*/ 0, |
| 6790 | /*.n_nodes =*/ i1 - i0, |
| 6791 | /*.n_leafs =*/ 0, |
| 6792 | /*.nodes =*/ cgraph0->nodes + i0, |
| 6793 | /*.grads =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, // gradients would need visited_hash_set |
| 6794 | /*.grad_accs =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 6795 | /*.leafs =*/ NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, |
| 6796 | /*.use_counts =*/ cgraph0->use_counts, |
| 6797 | /*.visited_hash_set =*/ cgraph0->visited_hash_set, |
| 6798 | /*.order =*/ cgraph0->order, |
| 6799 | }; |
| 6800 | |
| 6801 | return cgraph; |
| 6802 | } |
| 6803 | |
| 6804 | void ggml_graph_cpycxx . . $ ggml_graph_cpy(ff596566ff8f54a0).(struct ggml_cgraph * src, struct ggml_cgraph * dst) { |
| 6805 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dst->size >= src->n_leafs); |
| 6806 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dst->size >= src->n_nodes); |
| 6807 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dst->visited_hash_set.size >= src->visited_hash_set.size); |
| 6808 | |
| 6809 | dst->n_leafs = src->n_leafs; |
| 6810 | dst->n_nodes = src->n_nodes; |
| 6811 | dst->order = src->order; |
| 6812 | |
| 6813 | for (int i = 0; i < src->n_leafs; ++i) { |
| 6814 | dst->leafs[i] = src->leafs[i]; |
| 6815 | } |
| 6816 | |
| 6817 | for (int i = 0; i < src->n_nodes; ++i) { |
| 6818 | dst->nodes[i] = src->nodes[i]; |
| 6819 | } |
| 6820 | |
| 6821 | for (size_t i = 0; i < src->visited_hash_set.size; ++i) { |
| 6822 | // copy all hashset keys (tensors) that are in use |
| 6823 | if (ggml_bitset_get(src->visited_hash_set.used, i)) { |
| 6824 | size_t new_hash_pos = ggml_hash_insert(&dst->visited_hash_set, src->visited_hash_set.keys[i]); |
| 6825 | dst->use_counts[new_hash_pos] = src->use_counts[i]; |
| 6826 | } |
| 6827 | } |
| 6828 | |
| 6829 | if (dst->grads) { |
| 6830 | memset(dst->grads, 0, dst->visited_hash_set.size*sizeof(struct ggml_tensor *)); |
| 6831 | memset(dst->grad_accs, 0, dst->visited_hash_set.size*sizeof(struct ggml_tensor *)); |
| 6832 | } |
| 6833 | if (src->grads) { |
| 6834 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dst->grads != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 6835 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(dst->grad_accs != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 6836 | for (int i = 0; i < src->n_nodes; ++i) { |
| 6837 | const size_t igrad_src = ggml_hash_find(&src->visited_hash_set, src->nodes[i]); |
| 6838 | const size_t igrad_dst = ggml_hash_find(&dst->visited_hash_set, dst->nodes[i]); |
| 6839 | |
| 6840 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(igrad_src != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`!); |
| 6841 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_bitset_get(src->visited_hash_set.used, igrad_src)); |
| 6842 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(igrad_dst != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`!); |
| 6843 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_bitset_get(dst->visited_hash_set.used, igrad_dst)); |
| 6844 | |
| 6845 | dst->grads[igrad_dst] = src->grads[igrad_src]; |
| 6846 | dst->grad_accs[igrad_dst] = src->grad_accs[igrad_src]; |
| 6847 | } |
| 6848 | } |
| 6849 | } |
| 6850 | |
| 6851 | struct ggml_cgraph * ggml_graph_dupcxx . . $ ggml_graph_dup(885e08c098443985).(struct ggml_contextcxx . . $ ggml_context# * ctx, struct ggml_cgraph * cgraph, bool force_grads) { |
| 6852 | struct ggml_cgraph * result = ggml_new_graph_customcxx . . $ ggml_new_graph_custom(c0f43f8ef08527ab).(ctx, cgraph->size, cgraph->grads || force_grads); |
| 6853 | ggml_graph_cpycxx . . $ ggml_graph_cpy(ff596566ff8f54a0).(cgraph, result); |
| 6854 | return result; |
| 6855 | } |
| 6856 | |
| 6857 | struct ggml_tensor * ggml_set_zerocxx . . $ ggml_set_zero(3d36abdf32234c5).(struct ggml_tensor * tensor) { |
| 6858 | if (ggml_is_emptycxx . . $ ggml_is_empty(8fa73a561a000eab).(tensor)) { |
| 6859 | return tensor; |
| 6860 | } |
| 6861 | if (tensor->buffer) { |
| 6862 | ggml_backend_tensor_memset(tensor, 0, 0, ggml_nbytescxx . . $ ggml_nbytes(7f354dd711c66cf7).(tensor)); |
| 6863 | } else { |
| 6864 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tensor->data); |
| 6865 | memset(tensor->data, 0, ggml_nbytescxx . . $ ggml_nbytes(7f354dd711c66cf7).(tensor)); |
| 6866 | } |
| 6867 | return tensor; |
| 6868 | } |
| 6869 | |
| 6870 | void ggml_graph_resetcxx . . $ ggml_graph_reset(6abbbf094844e324).(struct ggml_cgraph * cgraph) { |
| 6871 | if (!cgraph) { |
| 6872 | return; |
| 6873 | } |
| 6874 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->grads != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 6875 | |
| 6876 | for (int i = 0; i < cgraph->n_nodes; i++) { |
| 6877 | struct ggml_tensor * node = cgraph->nodes[i]; |
| 6878 | struct ggml_tensor * grad_acc = ggml_graph_get_grad_acc(cgraph, node); |
| 6879 | |
| 6880 | if (node->op == GGML_OP_OPT_STEP_ADAMW) { |
| 6881 | // clear momenta |
| 6882 | ggml_set_zerocxx . . $ ggml_set_zero(3d36abdf32234c5).(node->src[2]); |
| 6883 | ggml_set_zerocxx . . $ ggml_set_zero(3d36abdf32234c5).(node->src[3]); |
| 6884 | } |
| 6885 | |
| 6886 | // initial gradients of loss should be 1, 0 otherwise |
| 6887 | if (grad_acc) { |
| 6888 | if (node->flags & GGML_TENSOR_FLAG_LOSS) { |
| 6889 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(grad_acc->type == GGML_TYPE_F32); |
| 6890 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_scalar(grad_acc)); |
| 6891 | |
| 6892 | const float onef = 1.0f; |
| 6893 | if (grad_acc->buffer) { |
| 6894 | ggml_backend_tensor_set(grad_acc, &onef, 0, sizeof(float)); |
| 6895 | } else { |
| 6896 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(grad_acc->data); |
| 6897 | *((float *) grad_acc->data) = onef; |
| 6898 | } |
| 6899 | } else { |
| 6900 | ggml_set_zerocxx . . $ ggml_set_zero(3d36abdf32234c5).(grad_acc); |
| 6901 | } |
| 6902 | } |
| 6903 | } |
| 6904 | } |
| 6905 | |
| 6906 | void ggml_graph_clearcxx . . $ ggml_graph_clear(6abbbf094844e324).(struct ggml_cgraph * cgraph) { |
| 6907 | cgraph->n_leafs = 0; |
| 6908 | cgraph->n_nodes = 0; |
| 6909 | ggml_hash_set_resetcxx . . $ ggml_hash_set_reset(3b8f2cbb4a532df6).(&cgraph->visited_hash_set); |
| 6910 | } |
| 6911 | |
| 6912 | int ggml_graph_sizecxx . . $ ggml_graph_size(559972b55ccb24ac).(struct ggml_cgraph * cgraph) { |
| 6913 | return cgraph->size; |
| 6914 | } |
| 6915 | |
| 6916 | struct ggml_tensor * ggml_graph_nodecxx . . $ ggml_graph_node(ce420dac12293551).(struct ggml_cgraph * cgraph, int i) { |
| 6917 | if (i < 0) { |
| 6918 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->n_nodes + i >= 0); |
| 6919 | return cgraph->nodes[cgraph->n_nodes + i]; |
| 6920 | } |
| 6921 | |
| 6922 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(i < cgraph->n_nodes); |
| 6923 | return cgraph->nodes[i]; |
| 6924 | } |
| 6925 | |
| 6926 | struct ggml_tensor ** ggml_graph_nodescxx . . $ ggml_graph_nodes(abdce851fe43a8d7).(struct ggml_cgraph * cgraph) { |
| 6927 | return cgraph->nodes; |
| 6928 | } |
| 6929 | |
| 6930 | int ggml_graph_n_nodescxx . . $ ggml_graph_n_nodes(559972b55ccb24ac).(struct ggml_cgraph * cgraph) { |
| 6931 | return cgraph->n_nodes; |
| 6932 | } |
| 6933 | |
| 6934 | void ggml_graph_add_nodecxx . . $ ggml_graph_add_node(9f1cb93022eb6b10).(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor) { |
| 6935 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph->size > cgraph->n_nodes); |
| 6936 | cgraph->nodes[cgraph->n_nodes] = tensor; |
| 6937 | cgraph->n_nodes++; |
| 6938 | } |
| 6939 | |
| 6940 | struct ggml_tensor * ggml_graph_get_tensorcxx . . $ ggml_graph_get_tensor(e66f057d3b5423e7).(const struct ggml_cgraph * cgraph, const char * name) { |
| 6941 | for (int i = 0; i < cgraph->n_leafs; i++) { |
| 6942 | struct ggml_tensor * leaf = cgraph->leafs[i]; |
| 6943 | |
| 6944 | if (strcmp(leaf->name, name) == 0) { |
| 6945 | return leaf; |
| 6946 | } |
| 6947 | } |
| 6948 | |
| 6949 | for (int i = 0; i < cgraph->n_nodes; i++) { |
| 6950 | struct ggml_tensor * node = cgraph->nodes[i]; |
| 6951 | |
| 6952 | if (strcmp(node->name, name) == 0) { |
| 6953 | return node; |
| 6954 | } |
| 6955 | } |
| 6956 | |
| 6957 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 6958 | } |
| 6959 | |
| 6960 | struct ggml_tensor * ggml_graph_get_gradcxx . . $ ggml_graph_get_grad(e28d8c4744f1de3d).(const struct ggml_cgraph * cgraph, const struct ggml_tensor * node) { |
| 6961 | const size_t igrad = ggml_hash_find(&cgraph->visited_hash_set, node); |
| 6962 | return igrad != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! && ggml_bitset_get(cgraph->visited_hash_set.used, igrad) && cgraph->grads ? cgraph->grads[igrad] : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 6963 | } |
| 6964 | |
| 6965 | struct ggml_tensor * ggml_graph_get_grad_acccxx . . $ ggml_graph_get_grad_acc(e28d8c4744f1de3d).(const struct ggml_cgraph * cgraph, const struct ggml_tensor * node) { |
| 6966 | const size_t igrad = ggml_hash_find(&cgraph->visited_hash_set, node); |
| 6967 | return igrad != GGML_HASHSET_FULLcxx . . $ `external/whispercpp/ggml-impl.h:221:9`! && ggml_bitset_get(cgraph->visited_hash_set.used, igrad) && cgraph->grad_accs ? cgraph->grad_accs[igrad] : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 6968 | } |
| 6969 | |
| 6970 | void ggml_graph_printcxx . . $ ggml_graph_print(13a63535c4cdd1ca).(const struct ggml_cgraph * cgraph) { |
| 6971 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("=== GRAPH ===\n"); |
| 6972 | |
| 6973 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("n_nodes = %d\n", cgraph->n_nodes); |
| 6974 | for (int i = 0; i < cgraph->n_nodes; i++) { |
| 6975 | struct ggml_tensor * node = cgraph->nodes[i]; |
| 6976 | |
| 6977 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!(" - %3d: [ %5" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %5" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %5" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! "] %16s %s\n", |
| 6978 | i, |
| 6979 | node->ne[0], node->ne[1], node->ne[2], |
| 6980 | ggml_op_name(node->op), (node->flags & GGML_TENSOR_FLAG_PARAM) ? "x" : |
| 6981 | ggml_graph_get_grad(cgraph, node) ? "g" : " "); |
| 6982 | } |
| 6983 | |
| 6984 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("n_leafs = %d\n", cgraph->n_leafs); |
| 6985 | for (int i = 0; i < cgraph->n_leafs; i++) { |
| 6986 | struct ggml_tensor * node = cgraph->leafs[i]; |
| 6987 | |
| 6988 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!(" - %3d: [ %5" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %5" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! "] %8s %16s\n", |
| 6989 | i, |
| 6990 | node->ne[0], node->ne[1], |
| 6991 | ggml_op_name(node->op), |
| 6992 | ggml_get_name(node)); |
| 6993 | } |
| 6994 | |
| 6995 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("========================================\n"); |
| 6996 | } |
| 6997 | |
| 6998 | static int ggml_node_list_find_tensorcxx . . $ ggml_node_list_find_tensor(16b20c3e0bc40a90).(const struct ggml_cgraph * cgraph, |
| 6999 | const int * idxs, |
| 7000 | int count, |
| 7001 | const struct ggml_tensor * tensor) { |
| 7002 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(cgraph && idxs); |
| 7003 | for (int i = 0; i < count; ++i) { |
| 7004 | const int node_idx = idxs[i]; |
| 7005 | |
| 7006 | if (node_idx >= cgraph->n_nodes) { |
| 7007 | return -1; |
| 7008 | } |
| 7009 | if (cgraph->nodes[node_idx] == tensor) { |
| 7010 | return i; |
| 7011 | } |
| 7012 | } |
| 7013 | return -1; |
| 7014 | } |
| 7015 | |
| 7016 | bool ggml_can_fuse_subgraph_extcxx . . $ ggml_can_fuse_subgraph_ext(2931c63e51fb5b9f).(const struct ggml_cgraph * cgraph, |
| 7017 | const int * node_idxs, |
| 7018 | int count, |
| 7019 | const enum ggml_op * ops, |
| 7020 | const int * outputs, |
| 7021 | int num_outputs) { |
| 7022 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(outputs && num_outputs > 0); |
| 7023 | |
| 7024 | for (int i = 0; i < count; ++i) { |
| 7025 | if (node_idxs[i] >= cgraph->n_nodes) { |
| 7026 | return false; |
| 7027 | } |
| 7028 | |
| 7029 | const struct ggml_tensor * node = cgraph->nodes[node_idxs[i]]; |
| 7030 | |
| 7031 | if (node->op != ops[i]) { |
| 7032 | return false; |
| 7033 | } |
| 7034 | |
| 7035 | if ((node->flags & GGML_TENSOR_FLAG_COMPUTE) == 0) { |
| 7036 | return false; |
| 7037 | } |
| 7038 | |
| 7039 | if (ggml_node_list_find_tensorcxx . . $ ggml_node_list_find_tensor(16b20c3e0bc40a90).(cgraph, outputs, num_outputs, node) != -1) { |
| 7040 | continue; |
| 7041 | } |
| 7042 | |
| 7043 | if (node->flags & GGML_TENSOR_FLAG_OUTPUT) { |
| 7044 | return false; |
| 7045 | } |
| 7046 | |
| 7047 | int subgraph_uses = 0; |
| 7048 | for (int j = i + 1; j < count; ++j) { |
| 7049 | const struct ggml_tensor * other_node = cgraph->nodes[node_idxs[j]]; |
| 7050 | for (int src_idx = 0; src_idx < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!; src_idx++) { |
| 7051 | if (other_node->src[src_idx] == node) { |
| 7052 | subgraph_uses++; |
| 7053 | } |
| 7054 | } |
| 7055 | } |
| 7056 | |
| 7057 | if (subgraph_uses != ggml_node_get_use_count(cgraph, node_idxs[i])) { |
| 7058 | return false; |
| 7059 | } |
| 7060 | |
| 7061 | // if node is a view, check if the view_src and all it's parent view_srcs are within the subgraph |
| 7062 | struct ggml_tensor * view_src = node->view_src; |
| 7063 | while (view_src) { |
| 7064 | if (ggml_node_list_find_tensorcxx . . $ ggml_node_list_find_tensor(16b20c3e0bc40a90).(cgraph, node_idxs, count, view_src) == -1) { |
| 7065 | return false; |
| 7066 | } |
| 7067 | view_src = view_src->view_src; |
| 7068 | } |
| 7069 | } |
| 7070 | |
| 7071 | return true; |
| 7072 | } |
| 7073 | |
| 7074 | // check if node is part of the graph |
| 7075 | static bool ggml_graph_findcxx . . $ ggml_graph_find(a40ee7de4d72acc3).(const struct ggml_cgraph * cgraph, const struct ggml_tensor * node) { |
| 7076 | if (cgraph == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 7077 | return true; |
| 7078 | } |
| 7079 | |
| 7080 | for (int i = 0; i < cgraph->n_nodes; i++) { |
| 7081 | if (cgraph->nodes[i] == node) { |
| 7082 | return true; |
| 7083 | } |
| 7084 | } |
| 7085 | |
| 7086 | return false; |
| 7087 | } |
| 7088 | |
| 7089 | static struct ggml_tensor * ggml_graph_get_parentcxx . . $ ggml_graph_get_parent(e28d8c4744f1de3d).(const struct ggml_cgraph * cgraph, const struct ggml_tensor * node) { |
| 7090 | for (int i = 0; i < cgraph->n_nodes; i++) { |
| 7091 | struct ggml_tensor * parent = cgraph->nodes[i]; |
| 7092 | struct ggml_tensor * grad = ggml_graph_get_gradcxx . . $ ggml_graph_get_grad(e28d8c4744f1de3d).(cgraph, parent); |
| 7093 | |
| 7094 | if (grad == node) { |
| 7095 | return parent; |
| 7096 | } |
| 7097 | } |
| 7098 | |
| 7099 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 7100 | } |
| 7101 | |
| 7102 | static void ggml_graph_dump_dot_node_edgecxx . . $ ggml_graph_dump_dot_node_edge(d6d204e191b7ace4).(FILE * fp, const struct ggml_cgraph * gb, struct ggml_tensor * node, struct ggml_tensor * parent, const char * label) { |
| 7103 | struct ggml_tensor * gparent = ggml_graph_get_parentcxx . . $ ggml_graph_get_parent(e28d8c4744f1de3d).(gb, node); |
| 7104 | struct ggml_tensor * gparent0 = ggml_graph_get_parentcxx . . $ ggml_graph_get_parent(e28d8c4744f1de3d).(gb, parent); |
| 7105 | fprintf(fp, " \"%p\" -> \"%p\" [ arrowhead = %s; style = %s; label = \"%s\"; ]\n", |
| 7106 | gparent0 ? (void *) gparent0 : (void *) parent, |
| 7107 | gparent ? (void *) gparent : (void *) node, |
| 7108 | gparent ? "empty" : "vee", |
| 7109 | gparent ? "dashed" : "solid", |
| 7110 | label); |
| 7111 | } |
| 7112 | |
| 7113 | static void ggml_graph_dump_dot_leaf_edgecxx . . $ ggml_graph_dump_dot_leaf_edge(2fcd156aef2e3358).(FILE * fp, struct ggml_tensor * node, struct ggml_tensor * parent, const char * label) { |
| 7114 | fprintf(fp, " \"%p\" -> \"%p\" [ label = \"%s\"; ]\n", |
| 7115 | (void *) parent, |
| 7116 | (void *) node, |
| 7117 | label); |
| 7118 | } |
| 7119 | |
| 7120 | void ggml_graph_dump_dotcxx . . $ ggml_graph_dump_dot(3e49490eef2c2318).(const struct ggml_cgraph * gb, const struct ggml_cgraph * cgraph, const char * filename) { |
| 7121 | char color[16]; |
| 7122 | |
| 7123 | FILE * fp = ggml_fopencxx . . $ ggml_fopen(82ec0787cd37e0a3).(filename, "w"); |
| 7124 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(fp); |
| 7125 | |
| 7126 | fprintf(fp, "digraph G {\n"); |
| 7127 | fprintf(fp, " newrank = true;\n"); |
| 7128 | fprintf(fp, " rankdir = TB;\n"); |
| 7129 | |
| 7130 | for (int i = 0; i < gb->n_nodes; i++) { |
| 7131 | struct ggml_tensor * node = gb->nodes[i]; |
| 7132 | struct ggml_tensor * grad = ggml_graph_get_gradcxx . . $ ggml_graph_get_grad(e28d8c4744f1de3d).(gb, node); |
| 7133 | |
| 7134 | if (ggml_graph_get_parentcxx . . $ ggml_graph_get_parent(e28d8c4744f1de3d).(gb, node) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 7135 | continue; |
| 7136 | } |
| 7137 | |
| 7138 | if (node->flags & GGML_TENSOR_FLAG_PARAM) { |
| 7139 | snprintf(color, sizeof(color), "yellow"); |
| 7140 | } else if (grad) { |
| 7141 | if (ggml_graph_findcxx . . $ ggml_graph_find(a40ee7de4d72acc3).(cgraph, node)) { |
| 7142 | snprintf(color, sizeof(color), "green"); |
| 7143 | } else { |
| 7144 | snprintf(color, sizeof(color), "lightblue"); |
| 7145 | } |
| 7146 | } else { |
| 7147 | snprintf(color, sizeof(color), "white"); |
| 7148 | } |
| 7149 | |
| 7150 | fprintf(fp, " \"%p\" [ " |
| 7151 | "style = filled; fillcolor = %s; shape = record; " |
| 7152 | "label=\"", |
| 7153 | (void *) node, color); |
| 7154 | |
| 7155 | if (strlen(node->name) > 0) { |
| 7156 | fprintf(fp, "%s (%s)|", node->name, ggml_type_namecxx . . $ ggml_type_name(46969943c907d743).(node->type)); |
| 7157 | } else { |
| 7158 | fprintf(fp, "(%s)|", ggml_type_namecxx . . $ ggml_type_name(46969943c907d743).(node->type)); |
| 7159 | } |
| 7160 | |
| 7161 | if (ggml_is_matrixcxx . . $ ggml_is_matrix(8fa73a561a000eab).(node)) { |
| 7162 | fprintf(fp, "%d [%" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! "] | <x>%s", i, node->ne[0], node->ne[1], ggml_op_symbolcxx . . $ ggml_op_symbol(5dcde7e02b3cf41e).(node->op)); |
| 7163 | } else { |
| 7164 | fprintf(fp, "%d [%" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! "] | <x>%s", i, node->ne[0], node->ne[1], node->ne[2], ggml_op_symbolcxx . . $ ggml_op_symbol(5dcde7e02b3cf41e).(node->op)); |
| 7165 | } |
| 7166 | |
| 7167 | if (grad) { |
| 7168 | fprintf(fp, " | <g>%s\"; ]\n", ggml_op_symbolcxx . . $ ggml_op_symbol(5dcde7e02b3cf41e).(grad->op)); |
| 7169 | } else { |
| 7170 | fprintf(fp, "\"; ]\n"); |
| 7171 | } |
| 7172 | } |
| 7173 | |
| 7174 | for (int i = 0; i < gb->n_leafs; i++) { |
| 7175 | struct ggml_tensor * node = gb->leafs[i]; |
| 7176 | |
| 7177 | snprintf(color, sizeof(color), "pink"); |
| 7178 | |
| 7179 | fprintf(fp, " \"%p\" [ " |
| 7180 | "style = filled; fillcolor = %s; shape = record; " |
| 7181 | "label=\"<x>", |
| 7182 | (void *) node, color); |
| 7183 | |
| 7184 | if (strlen(node->name) > 0) { |
| 7185 | fprintf(fp, "%s (%s)|", node->name, ggml_type_namecxx . . $ ggml_type_name(46969943c907d743).(node->type)); |
| 7186 | } else { |
| 7187 | fprintf(fp, "(%s)|", ggml_type_namecxx . . $ ggml_type_name(46969943c907d743).(node->type)); |
| 7188 | } |
| 7189 | |
| 7190 | fprintf(fp, "CONST %d [%" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! ", %" PRId64cxx . . $ `<external>/15933738808807975373/inttypes.h:57:10`! "]", i, node->ne[0], node->ne[1]); |
| 7191 | if (ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(node) < 5 && node->data != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 7192 | fprintf(fp, " | ("); |
| 7193 | for (int j = 0; j < ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(node); j++) { |
| 7194 | // FIXME: use ggml-backend to obtain the tensor data |
| 7195 | //if (node->type == GGML_TYPE_I8 || node->type == GGML_TYPE_I16 || node->type == GGML_TYPE_I32) { |
| 7196 | // fprintf(fp, "%d", ggml_get_i32_1d(node, j)); |
| 7197 | //} |
| 7198 | //else if (node->type == GGML_TYPE_F32 || |
| 7199 | // node->type == GGML_TYPE_F16 || |
| 7200 | // node->type == GGML_TYPE_BF16) { |
| 7201 | // fprintf(fp, "%.1e", (double)ggml_get_f32_1d(node, j)); |
| 7202 | //} |
| 7203 | //else |
| 7204 | { |
| 7205 | fprintf(fp, "#"); |
| 7206 | } |
| 7207 | if (j < ggml_nelementscxx . . $ ggml_nelements(1c1d1f12eaca9937).(node) - 1) { |
| 7208 | fprintf(fp, ", "); |
| 7209 | } |
| 7210 | } |
| 7211 | fprintf(fp, ")"); |
| 7212 | } |
| 7213 | fprintf(fp, "\"; ]\n"); |
| 7214 | } |
| 7215 | |
| 7216 | for (int i = 0; i < gb->n_nodes; i++) { |
| 7217 | struct ggml_tensor * node = gb->nodes[i]; |
| 7218 | |
| 7219 | for (int j = 0; j < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!; j++) { |
| 7220 | if (node->src[j]) { |
| 7221 | char label[16]; |
| 7222 | snprintf(label, sizeof(label), "src %d", j); |
| 7223 | ggml_graph_dump_dot_node_edgecxx . . $ ggml_graph_dump_dot_node_edge(d6d204e191b7ace4).(fp, gb, node, node->src[j], label); |
| 7224 | } |
| 7225 | } |
| 7226 | } |
| 7227 | |
| 7228 | for (int i = 0; i < gb->n_leafs; i++) { |
| 7229 | struct ggml_tensor * node = gb->leafs[i]; |
| 7230 | |
| 7231 | for (int j = 0; j < GGML_MAX_SRCcxx . . $ `external/whispercpp/ggml.h:236:9`!; j++) { |
| 7232 | if (node->src[j]) { |
| 7233 | char label[16]; |
| 7234 | snprintf(label, sizeof(label), "src %d", j); |
| 7235 | ggml_graph_dump_dot_leaf_edgecxx . . $ ggml_graph_dump_dot_leaf_edge(2fcd156aef2e3358).(fp, node, node->src[j], label); |
| 7236 | } |
| 7237 | } |
| 7238 | } |
| 7239 | |
| 7240 | fprintf(fp, "}\n"); |
| 7241 | |
| 7242 | fclose(fp); |
| 7243 | |
| 7244 | GGML_LOG_INFOcxx . . $ `external/whispercpp/ggml-impl.h:117:9`!("%s: dot -Tpng %s -o %s.png && open %s.png\n", __func__, filename, filename, filename); |
| 7245 | } |
| 7246 | |
| 7247 | //////////////////////////////////////////////////////////////////////////////// |
| 7248 | |
| 7249 | void ggml_set_inputcxx . . $ ggml_set_input(dbc185895e61a455).(struct ggml_tensor * tensor) { |
| 7250 | tensor->flags |= GGML_TENSOR_FLAG_INPUT; |
| 7251 | } |
| 7252 | |
| 7253 | void ggml_set_outputcxx . . $ ggml_set_output(dbc185895e61a455).(struct ggml_tensor * tensor) { |
| 7254 | tensor->flags |= GGML_TENSOR_FLAG_OUTPUT; |
| 7255 | } |
| 7256 | |
| 7257 | void ggml_set_paramcxx . . $ ggml_set_param(dbc185895e61a455).(struct ggml_tensor * tensor) { |
| 7258 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tensor->op == GGML_OP_NONE); |
| 7259 | tensor->flags |= GGML_TENSOR_FLAG_PARAM; |
| 7260 | } |
| 7261 | |
| 7262 | void ggml_set_losscxx . . $ ggml_set_loss(dbc185895e61a455).(struct ggml_tensor * tensor) { |
| 7263 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(ggml_is_scalar(tensor)); |
| 7264 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(tensor->type == GGML_TYPE_F32); |
| 7265 | tensor->flags |= GGML_TENSOR_FLAG_LOSS; |
| 7266 | } |
| 7267 | |
| 7268 | //////////////////////////////////////////////////////////////////////////////// |
| 7269 | |
| 7270 | void ggml_quantize_initcxx . . $ ggml_quantize_init(9bc8e8e504d13637).(enum ggml_type type) { |
| 7271 | ggml_critical_section_start(); |
| 7272 | |
| 7273 | switch (type) { |
| 7274 | case GGML_TYPE_IQ2_XXS: |
| 7275 | case GGML_TYPE_IQ2_XS: |
| 7276 | case GGML_TYPE_IQ2_S: |
| 7277 | case GGML_TYPE_IQ1_S: |
| 7278 | case GGML_TYPE_IQ1_M: iq2xs_init_impl(type); break; |
| 7279 | case GGML_TYPE_IQ3_XXS: iq3xs_init_impl(256); break; |
| 7280 | case GGML_TYPE_IQ3_S: iq3xs_init_impl(512); break; |
| 7281 | default: // nothing |
| 7282 | break; |
| 7283 | } |
| 7284 | |
| 7285 | ggml_critical_section_end(); |
| 7286 | } |
| 7287 | |
| 7288 | void ggml_quantize_freecxx . . $ ggml_quantize_free(49f6e7a06ebc5aa8).(void) { |
| 7289 | ggml_critical_section_start(); |
| 7290 | |
| 7291 | iq2xs_free_impl(GGML_TYPE_IQ2_XXS); |
| 7292 | iq2xs_free_impl(GGML_TYPE_IQ2_XS); |
| 7293 | iq2xs_free_impl(GGML_TYPE_IQ2_S); |
| 7294 | iq2xs_free_impl(GGML_TYPE_IQ1_S); |
| 7295 | iq2xs_free_impl(GGML_TYPE_IQ1_M); |
| 7296 | iq3xs_free_impl(256); |
| 7297 | iq3xs_free_impl(512); |
| 7298 | |
| 7299 | ggml_critical_section_end(); |
| 7300 | } |
| 7301 | |
| 7302 | bool ggml_quantize_requires_imatrixcxx . . $ ggml_quantize_requires_imatrix(f198bb166f543519).(enum ggml_type type) { |
| 7303 | return |
| 7304 | type == GGML_TYPE_IQ2_XXS || |
| 7305 | type == GGML_TYPE_IQ2_XS || |
| 7306 | type == GGML_TYPE_IQ1_S;// || |
| 7307 | //type == GGML_TYPE_IQ1_M; |
| 7308 | } |
| 7309 | |
| 7310 | size_t ggml_quantize_chunkcxx . . $ ggml_quantize_chunk(9e2e34b2f9a0ee7f).( |
| 7311 | enum ggml_type type, |
| 7312 | const float * src, |
| 7313 | void * dst, |
| 7314 | int64_tcxx . . $ int64_t# start, |
| 7315 | int64_tcxx . . $ int64_t# nrows, |
| 7316 | int64_tcxx . . $ int64_t# n_per_row, |
| 7317 | const float * imatrix) { |
| 7318 | const int64_tcxx . . $ int64_t# n = (int64_tcxx . . $ int64_t#) nrows * n_per_row; |
| 7319 | |
| 7320 | if (ggml_quantize_requires_imatrixcxx . . $ ggml_quantize_requires_imatrix(f198bb166f543519).(type)) { |
| 7321 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(imatrix != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 7322 | } |
| 7323 | |
| 7324 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(start % type_traits[type].blck_size == 0); |
| 7325 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(start % n_per_row == 0); |
| 7326 | |
| 7327 | ggml_quantize_initcxx . . $ ggml_quantize_init(9bc8e8e504d13637).(type); // this is noop if already initialized |
| 7328 | |
| 7329 | const size_t start_row = start / n_per_row; |
| 7330 | const size_t row_size = ggml_row_sizecxx . . $ ggml_row_size(cd72edd651ca704e).(type, n_per_row); |
| 7331 | |
| 7332 | size_t result = 0; |
| 7333 | |
| 7334 | switch (type) { |
| 7335 | case GGML_TYPE_Q4_0: result = quantize_q4_0(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7336 | case GGML_TYPE_Q4_1: result = quantize_q4_1(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7337 | case GGML_TYPE_Q5_0: result = quantize_q5_0(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7338 | case GGML_TYPE_Q5_1: result = quantize_q5_1(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7339 | case GGML_TYPE_Q8_0: result = quantize_q8_0(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7340 | case GGML_TYPE_MXFP4: result = quantize_mxfp4(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7341 | case GGML_TYPE_Q2_K: result = quantize_q2_K(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7342 | case GGML_TYPE_Q3_K: result = quantize_q3_K(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7343 | case GGML_TYPE_Q4_K: result = quantize_q4_K(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7344 | case GGML_TYPE_Q5_K: result = quantize_q5_K(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7345 | case GGML_TYPE_Q6_K: result = quantize_q6_K(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7346 | case GGML_TYPE_TQ1_0: result = quantize_tq1_0(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7347 | case GGML_TYPE_TQ2_0: result = quantize_tq2_0(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7348 | case GGML_TYPE_IQ2_XXS: result = quantize_iq2_xxs(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7349 | case GGML_TYPE_IQ2_XS: result = quantize_iq2_xs (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7350 | case GGML_TYPE_IQ3_XXS: result = quantize_iq3_xxs(src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7351 | case GGML_TYPE_IQ3_S: result = quantize_iq3_s (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7352 | case GGML_TYPE_IQ2_S: result = quantize_iq2_s (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7353 | case GGML_TYPE_IQ1_S: result = quantize_iq1_s (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7354 | case GGML_TYPE_IQ1_M: result = quantize_iq1_m (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7355 | case GGML_TYPE_IQ4_NL: result = quantize_iq4_nl (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7356 | case GGML_TYPE_IQ4_XS: result = quantize_iq4_xs (src + start, (char *) dst + start_row * row_size, nrows, n_per_row, imatrix); break; |
| 7357 | case GGML_TYPE_F16: |
| 7358 | { |
| 7359 | size_t elemsize = sizeof(ggml_fp16_t); |
| 7360 | ggml_fp32_to_fp16_rowcxx . . $ ggml_fp32_to_fp16_row(d0bddba7da29e34c).(src + start, (ggml_fp16_t *)dst + start, n); |
| 7361 | result = n * elemsize; |
| 7362 | } break; |
| 7363 | case GGML_TYPE_BF16: |
| 7364 | { |
| 7365 | size_t elemsize = sizeof(ggml_bf16_t); |
| 7366 | ggml_fp32_to_bf16_row_refcxx . . $ ggml_fp32_to_bf16_row_ref(391ac1fe44da9fcc).(src + start, (ggml_bf16_t *)dst + start, n); |
| 7367 | result = n * elemsize; |
| 7368 | } break; |
| 7369 | case GGML_TYPE_F32: |
| 7370 | { |
| 7371 | size_t elemsize = sizeof(float); |
| 7372 | result = n * elemsize; |
| 7373 | memcpy((uint8_tcxx . . $ uint8_t# *)dst + start * elemsize, src + start, result); |
| 7374 | } break; |
| 7375 | default: |
| 7376 | assertcxx . . $ `/usr/include/assert.h:102:11`!(false); |
| 7377 | } |
| 7378 | |
| 7379 | GGML_ASSERTcxx . . $ `external/whispercpp/ggml.h:300:9`!(result == nrows * row_size); |
| 7380 | |
| 7381 | return result; |
| 7382 | } |
| 7383 | |
| 7384 | //////////////////////////////////////////////////////////////////////////////// |
| 7385 | |
| 7386 | void ggml_log_getcxx . . $ ggml_log_get(55d0615b4606e433).(ggml_log_callback * log_callback, void ** user_data) { |
| 7387 | *log_callback = g_logger_statecxx . . $ g_logger_state..log_callbackcxx . . $ ggml_logger_state#log_callback.; |
| 7388 | *user_data = g_logger_statecxx . . $ g_logger_state..log_callback_user_datacxx . . $ ggml_logger_state#log_callback_user_data.; |
| 7389 | } |
| 7390 | |
| 7391 | void ggml_log_setcxx . . $ ggml_log_set(c04e1b17d4a16110).(ggml_log_callback log_callback, void * user_data) { |
| 7392 | g_logger_statecxx . . $ g_logger_state..log_callbackcxx . . $ ggml_logger_state#log_callback. = log_callback ? log_callback : ggml_log_callback_defaultcxx . . $ ggml_log_callback_default(1235eb62ccdaecf6).; |
| 7393 | g_logger_statecxx . . $ g_logger_state..log_callback_user_datacxx . . $ ggml_logger_state#log_callback_user_data. = user_data; |
| 7394 | } |
| 7395 | |
| 7396 | void ggml_threadpool_params_initcxx . . $ ggml_threadpool_params_init(df9b29d59a699c9).(struct ggml_threadpool_params * p, int n_threads) { |
| 7397 | p->n_threads = n_threads; |
| 7398 | p->prio = (enum ggml_sched_priority) 0; // default priority (usually means normal or inherited) |
| 7399 | p->poll = 50; // hybrid-polling enabled |
| 7400 | p->strict_cpu = false; // no strict placement (all threads share same cpumask) |
| 7401 | p->paused = false; // threads are ready to go |
| 7402 | memset(p->cpumask, 0, GGML_MAX_N_THREADScxx . . $ `external/whispercpp/ggml.h:237:9`!); // all-zero means use the default affinity (usually inherited) |
| 7403 | } |
| 7404 | |
| 7405 | struct ggml_threadpool_params ggml_threadpool_params_defaultcxx . . $ ggml_threadpool_params_default(65a42c97722d69c1).(int n_threads) { |
| 7406 | struct ggml_threadpool_params p; |
| 7407 | ggml_threadpool_params_initcxx . . $ ggml_threadpool_params_init(df9b29d59a699c9).(&p, n_threads); |
| 7408 | return p; |
| 7409 | } |
| 7410 | |
| 7411 | bool ggml_threadpool_params_matchcxx . . $ ggml_threadpool_params_match(c9293e44a540df53).(const struct ggml_threadpool_params * p0, const struct ggml_threadpool_params * p1) { |
| 7412 | if (p0->n_threads != p1->n_threads ) return false; |
| 7413 | if (p0->prio != p1->prio ) return false; |
| 7414 | if (p0->poll != p1->poll ) return false; |
| 7415 | if (p0->strict_cpu != p1->strict_cpu ) return false; |
| 7416 | return memcmp(p0->cpumask, p1->cpumask, GGML_MAX_N_THREADScxx . . $ `external/whispercpp/ggml.h:237:9`!) == 0; |
| 7417 | } |