@agency-lang/whisper-local 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (643) hide show
  1. package/CMakeLists.txt +51 -0
  2. package/README.md +145 -0
  3. package/build/Release/whisper_addon.node +0 -0
  4. package/dist/src/addon.d.ts +11 -0
  5. package/dist/src/addon.js +22 -0
  6. package/dist/src/cli.d.ts +2 -0
  7. package/dist/src/cli.js +117 -0
  8. package/dist/src/ffmpeg.d.ts +11 -0
  9. package/dist/src/ffmpeg.js +154 -0
  10. package/dist/src/handleCache.d.ts +9 -0
  11. package/dist/src/handleCache.js +83 -0
  12. package/dist/src/modelManager.d.ts +12 -0
  13. package/dist/src/modelManager.js +172 -0
  14. package/dist/src/packageRoot.d.ts +8 -0
  15. package/dist/src/packageRoot.js +21 -0
  16. package/dist/src/transcribe.d.ts +2 -0
  17. package/dist/src/transcribe.js +36 -0
  18. package/dist/src/types.d.ts +11 -0
  19. package/dist/src/types.js +17 -0
  20. package/index.agency +32 -0
  21. package/models.lock.json +55 -0
  22. package/package.json +52 -0
  23. package/vendor/whisper.cpp/CMakeLists.txt +251 -0
  24. package/vendor/whisper.cpp/LICENSE +21 -0
  25. package/vendor/whisper.cpp/UPSTREAM_SHA256 +1 -0
  26. package/vendor/whisper.cpp/VERSION +1 -0
  27. package/vendor/whisper.cpp/cmake/DefaultTargetOptions.cmake +16 -0
  28. package/vendor/whisper.cpp/cmake/FindFFmpeg.cmake +163 -0
  29. package/vendor/whisper.cpp/cmake/build-info.cmake +60 -0
  30. package/vendor/whisper.cpp/cmake/git-vars.cmake +22 -0
  31. package/vendor/whisper.cpp/cmake/whisper-config.cmake.in +65 -0
  32. package/vendor/whisper.cpp/cmake/whisper.pc.in +10 -0
  33. package/vendor/whisper.cpp/ggml/CMakeLists.txt +434 -0
  34. package/vendor/whisper.cpp/ggml/cmake/BuildTypes.cmake +54 -0
  35. package/vendor/whisper.cpp/ggml/cmake/GitVars.cmake +22 -0
  36. package/vendor/whisper.cpp/ggml/cmake/common.cmake +50 -0
  37. package/vendor/whisper.cpp/ggml/cmake/ggml-config.cmake.in +152 -0
  38. package/vendor/whisper.cpp/ggml/include/ggml-alloc.h +76 -0
  39. package/vendor/whisper.cpp/ggml/include/ggml-backend.h +354 -0
  40. package/vendor/whisper.cpp/ggml/include/ggml-blas.h +25 -0
  41. package/vendor/whisper.cpp/ggml/include/ggml-cann.h +123 -0
  42. package/vendor/whisper.cpp/ggml/include/ggml-cpp.h +39 -0
  43. package/vendor/whisper.cpp/ggml/include/ggml-cpu.h +143 -0
  44. package/vendor/whisper.cpp/ggml/include/ggml-cuda.h +47 -0
  45. package/vendor/whisper.cpp/ggml/include/ggml-kompute.h +50 -0
  46. package/vendor/whisper.cpp/ggml/include/ggml-metal.h +66 -0
  47. package/vendor/whisper.cpp/ggml/include/ggml-opencl.h +26 -0
  48. package/vendor/whisper.cpp/ggml/include/ggml-opt.h +237 -0
  49. package/vendor/whisper.cpp/ggml/include/ggml-rpc.h +33 -0
  50. package/vendor/whisper.cpp/ggml/include/ggml-sycl.h +49 -0
  51. package/vendor/whisper.cpp/ggml/include/ggml-vulkan.h +29 -0
  52. package/vendor/whisper.cpp/ggml/include/ggml.h +2221 -0
  53. package/vendor/whisper.cpp/ggml/include/gguf.h +202 -0
  54. package/vendor/whisper.cpp/ggml/src/CMakeLists.txt +404 -0
  55. package/vendor/whisper.cpp/ggml/src/ggml-alloc.c +1042 -0
  56. package/vendor/whisper.cpp/ggml/src/ggml-amx/CMakeLists.txt +107 -0
  57. package/vendor/whisper.cpp/ggml/src/ggml-amx/common.h +94 -0
  58. package/vendor/whisper.cpp/ggml/src/ggml-amx/ggml-amx.cpp +446 -0
  59. package/vendor/whisper.cpp/ggml/src/ggml-amx/mmq.cpp +2510 -0
  60. package/vendor/whisper.cpp/ggml/src/ggml-amx/mmq.h +17 -0
  61. package/vendor/whisper.cpp/ggml/src/ggml-backend-impl.h +255 -0
  62. package/vendor/whisper.cpp/ggml/src/ggml-backend-reg.cpp +591 -0
  63. package/vendor/whisper.cpp/ggml/src/ggml-backend.cpp +2016 -0
  64. package/vendor/whisper.cpp/ggml/src/ggml-blas/CMakeLists.txt +87 -0
  65. package/vendor/whisper.cpp/ggml/src/ggml-blas/ggml-blas.cpp +517 -0
  66. package/vendor/whisper.cpp/ggml/src/ggml-cann/CMakeLists.txt +75 -0
  67. package/vendor/whisper.cpp/ggml/src/ggml-cann/Doxyfile +2579 -0
  68. package/vendor/whisper.cpp/ggml/src/ggml-cann/acl_tensor.cpp +181 -0
  69. package/vendor/whisper.cpp/ggml/src/ggml-cann/acl_tensor.h +258 -0
  70. package/vendor/whisper.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +3193 -0
  71. package/vendor/whisper.cpp/ggml/src/ggml-cann/aclnn_ops.h +1125 -0
  72. package/vendor/whisper.cpp/ggml/src/ggml-cann/common.h +425 -0
  73. package/vendor/whisper.cpp/ggml/src/ggml-cann/ggml-cann.cpp +2630 -0
  74. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/CMakeLists.txt +30 -0
  75. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/ascendc_kernels.h +19 -0
  76. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/dup.cpp +234 -0
  77. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/get_row_f16.cpp +197 -0
  78. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/get_row_f32.cpp +190 -0
  79. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/get_row_q4_0.cpp +204 -0
  80. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/get_row_q8_0.cpp +191 -0
  81. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +218 -0
  82. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +216 -0
  83. package/vendor/whisper.cpp/ggml/src/ggml-cann/kernels/quantize_float_to_q4_0.cpp +295 -0
  84. package/vendor/whisper.cpp/ggml/src/ggml-common.h +1861 -0
  85. package/vendor/whisper.cpp/ggml/src/ggml-cpu/CMakeLists.txt +584 -0
  86. package/vendor/whisper.cpp/ggml/src/ggml-cpu/amx/amx.cpp +221 -0
  87. package/vendor/whisper.cpp/ggml/src/ggml-cpu/amx/amx.h +8 -0
  88. package/vendor/whisper.cpp/ggml/src/ggml-cpu/amx/common.h +91 -0
  89. package/vendor/whisper.cpp/ggml/src/ggml-cpu/amx/mmq.cpp +2511 -0
  90. package/vendor/whisper.cpp/ggml/src/ggml-cpu/amx/mmq.h +10 -0
  91. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
  92. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/arm/quants.c +4113 -0
  93. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/arm/repack.cpp +2162 -0
  94. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/loongarch/quants.c +2638 -0
  95. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
  96. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/powerpc/quants.c +2731 -0
  97. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/riscv/quants.c +2068 -0
  98. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/riscv/repack.cpp +396 -0
  99. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/s390/quants.c +1299 -0
  100. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/wasm/quants.c +1480 -0
  101. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
  102. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/x86/quants.c +4310 -0
  103. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch/x86/repack.cpp +3284 -0
  104. package/vendor/whisper.cpp/ggml/src/ggml-cpu/arch-fallback.h +184 -0
  105. package/vendor/whisper.cpp/ggml/src/ggml-cpu/binary-ops.cpp +158 -0
  106. package/vendor/whisper.cpp/ggml/src/ggml-cpu/binary-ops.h +16 -0
  107. package/vendor/whisper.cpp/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
  108. package/vendor/whisper.cpp/ggml/src/ggml-cpu/common.h +72 -0
  109. package/vendor/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu-impl.h +511 -0
  110. package/vendor/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu.c +3473 -0
  111. package/vendor/whisper.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +671 -0
  112. package/vendor/whisper.cpp/ggml/src/ggml-cpu/hbm.cpp +55 -0
  113. package/vendor/whisper.cpp/ggml/src/ggml-cpu/hbm.h +8 -0
  114. package/vendor/whisper.cpp/ggml/src/ggml-cpu/kleidiai/kernels.cpp +337 -0
  115. package/vendor/whisper.cpp/ggml/src/ggml-cpu/kleidiai/kernels.h +95 -0
  116. package/vendor/whisper.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +482 -0
  117. package/vendor/whisper.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
  118. package/vendor/whisper.cpp/ggml/src/ggml-cpu/llamafile/sgemm.cpp +3593 -0
  119. package/vendor/whisper.cpp/ggml/src/ggml-cpu/llamafile/sgemm.h +19 -0
  120. package/vendor/whisper.cpp/ggml/src/ggml-cpu/ops.cpp +9085 -0
  121. package/vendor/whisper.cpp/ggml/src/ggml-cpu/ops.h +111 -0
  122. package/vendor/whisper.cpp/ggml/src/ggml-cpu/quants.c +1157 -0
  123. package/vendor/whisper.cpp/ggml/src/ggml-cpu/quants.h +89 -0
  124. package/vendor/whisper.cpp/ggml/src/ggml-cpu/repack.cpp +1570 -0
  125. package/vendor/whisper.cpp/ggml/src/ggml-cpu/repack.h +98 -0
  126. package/vendor/whisper.cpp/ggml/src/ggml-cpu/simd-mappings.h +1006 -0
  127. package/vendor/whisper.cpp/ggml/src/ggml-cpu/traits.cpp +36 -0
  128. package/vendor/whisper.cpp/ggml/src/ggml-cpu/traits.h +38 -0
  129. package/vendor/whisper.cpp/ggml/src/ggml-cpu/unary-ops.cpp +186 -0
  130. package/vendor/whisper.cpp/ggml/src/ggml-cpu/unary-ops.h +28 -0
  131. package/vendor/whisper.cpp/ggml/src/ggml-cpu/vec.cpp +321 -0
  132. package/vendor/whisper.cpp/ggml/src/ggml-cpu/vec.h +973 -0
  133. package/vendor/whisper.cpp/ggml/src/ggml-cuda/CMakeLists.txt +184 -0
  134. package/vendor/whisper.cpp/ggml/src/ggml-cuda/acc.cu +61 -0
  135. package/vendor/whisper.cpp/ggml/src/ggml-cuda/acc.cuh +5 -0
  136. package/vendor/whisper.cpp/ggml/src/ggml-cuda/arange.cu +34 -0
  137. package/vendor/whisper.cpp/ggml/src/ggml-cuda/arange.cuh +5 -0
  138. package/vendor/whisper.cpp/ggml/src/ggml-cuda/argmax.cu +91 -0
  139. package/vendor/whisper.cpp/ggml/src/ggml-cuda/argmax.cuh +3 -0
  140. package/vendor/whisper.cpp/ggml/src/ggml-cuda/argsort.cu +104 -0
  141. package/vendor/whisper.cpp/ggml/src/ggml-cuda/argsort.cuh +3 -0
  142. package/vendor/whisper.cpp/ggml/src/ggml-cuda/binbcast.cu +363 -0
  143. package/vendor/whisper.cpp/ggml/src/ggml-cuda/binbcast.cuh +9 -0
  144. package/vendor/whisper.cpp/ggml/src/ggml-cuda/clamp.cu +45 -0
  145. package/vendor/whisper.cpp/ggml/src/ggml-cuda/clamp.cuh +5 -0
  146. package/vendor/whisper.cpp/ggml/src/ggml-cuda/common.cuh +812 -0
  147. package/vendor/whisper.cpp/ggml/src/ggml-cuda/concat.cu +221 -0
  148. package/vendor/whisper.cpp/ggml/src/ggml-cuda/concat.cuh +5 -0
  149. package/vendor/whisper.cpp/ggml/src/ggml-cuda/conv-transpose-1d.cu +89 -0
  150. package/vendor/whisper.cpp/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
  151. package/vendor/whisper.cpp/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
  152. package/vendor/whisper.cpp/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
  153. package/vendor/whisper.cpp/ggml/src/ggml-cuda/conv2d-transpose.cu +91 -0
  154. package/vendor/whisper.cpp/ggml/src/ggml-cuda/conv2d-transpose.cuh +4 -0
  155. package/vendor/whisper.cpp/ggml/src/ggml-cuda/convert.cu +730 -0
  156. package/vendor/whisper.cpp/ggml/src/ggml-cuda/convert.cuh +26 -0
  157. package/vendor/whisper.cpp/ggml/src/ggml-cuda/count-equal.cu +64 -0
  158. package/vendor/whisper.cpp/ggml/src/ggml-cuda/count-equal.cuh +5 -0
  159. package/vendor/whisper.cpp/ggml/src/ggml-cuda/cp-async.cuh +57 -0
  160. package/vendor/whisper.cpp/ggml/src/ggml-cuda/cpy.cu +705 -0
  161. package/vendor/whisper.cpp/ggml/src/ggml-cuda/cpy.cuh +11 -0
  162. package/vendor/whisper.cpp/ggml/src/ggml-cuda/cross-entropy-loss.cu +189 -0
  163. package/vendor/whisper.cpp/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
  164. package/vendor/whisper.cpp/ggml/src/ggml-cuda/dequantize.cuh +103 -0
  165. package/vendor/whisper.cpp/ggml/src/ggml-cuda/diagmask.cu +40 -0
  166. package/vendor/whisper.cpp/ggml/src/ggml-cuda/diagmask.cuh +5 -0
  167. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-common.cuh +881 -0
  168. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1474 -0
  169. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-tile-f16.cu +357 -0
  170. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-tile-f16.cuh +3 -0
  171. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-tile-f32.cu +365 -0
  172. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-tile-f32.cuh +3 -0
  173. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-vec-f16.cuh +482 -0
  174. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-vec-f32.cuh +472 -0
  175. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-wmma-f16.cu +634 -0
  176. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +3 -0
  177. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn.cu +346 -0
  178. package/vendor/whisper.cpp/ggml/src/ggml-cuda/fattn.cuh +3 -0
  179. package/vendor/whisper.cpp/ggml/src/ggml-cuda/getrows.cu +275 -0
  180. package/vendor/whisper.cpp/ggml/src/ggml-cuda/getrows.cuh +15 -0
  181. package/vendor/whisper.cpp/ggml/src/ggml-cuda/ggml-cuda.cu +3562 -0
  182. package/vendor/whisper.cpp/ggml/src/ggml-cuda/gla.cu +93 -0
  183. package/vendor/whisper.cpp/ggml/src/ggml-cuda/gla.cuh +3 -0
  184. package/vendor/whisper.cpp/ggml/src/ggml-cuda/im2col.cu +103 -0
  185. package/vendor/whisper.cpp/ggml/src/ggml-cuda/im2col.cuh +5 -0
  186. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mma.cuh +396 -0
  187. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mmq.cu +324 -0
  188. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mmq.cuh +3217 -0
  189. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mmv.cu +336 -0
  190. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mmv.cuh +12 -0
  191. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mmvq.cu +595 -0
  192. package/vendor/whisper.cpp/ggml/src/ggml-cuda/mmvq.cuh +12 -0
  193. package/vendor/whisper.cpp/ggml/src/ggml-cuda/norm.cu +458 -0
  194. package/vendor/whisper.cpp/ggml/src/ggml-cuda/norm.cuh +11 -0
  195. package/vendor/whisper.cpp/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
  196. package/vendor/whisper.cpp/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
  197. package/vendor/whisper.cpp/ggml/src/ggml-cuda/out-prod.cu +68 -0
  198. package/vendor/whisper.cpp/ggml/src/ggml-cuda/out-prod.cuh +3 -0
  199. package/vendor/whisper.cpp/ggml/src/ggml-cuda/pad.cu +49 -0
  200. package/vendor/whisper.cpp/ggml/src/ggml-cuda/pad.cuh +5 -0
  201. package/vendor/whisper.cpp/ggml/src/ggml-cuda/pool2d.cu +94 -0
  202. package/vendor/whisper.cpp/ggml/src/ggml-cuda/pool2d.cuh +5 -0
  203. package/vendor/whisper.cpp/ggml/src/ggml-cuda/quantize.cu +190 -0
  204. package/vendor/whisper.cpp/ggml/src/ggml-cuda/quantize.cuh +27 -0
  205. package/vendor/whisper.cpp/ggml/src/ggml-cuda/rope.cu +456 -0
  206. package/vendor/whisper.cpp/ggml/src/ggml-cuda/rope.cuh +7 -0
  207. package/vendor/whisper.cpp/ggml/src/ggml-cuda/scale.cu +31 -0
  208. package/vendor/whisper.cpp/ggml/src/ggml-cuda/scale.cuh +5 -0
  209. package/vendor/whisper.cpp/ggml/src/ggml-cuda/softmax.cu +283 -0
  210. package/vendor/whisper.cpp/ggml/src/ggml-cuda/softmax.cuh +7 -0
  211. package/vendor/whisper.cpp/ggml/src/ggml-cuda/ssm-conv.cu +148 -0
  212. package/vendor/whisper.cpp/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
  213. package/vendor/whisper.cpp/ggml/src/ggml-cuda/ssm-scan.cu +155 -0
  214. package/vendor/whisper.cpp/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
  215. package/vendor/whisper.cpp/ggml/src/ggml-cuda/sum.cu +45 -0
  216. package/vendor/whisper.cpp/ggml/src/ggml-cuda/sum.cuh +5 -0
  217. package/vendor/whisper.cpp/ggml/src/ggml-cuda/sumrows.cu +39 -0
  218. package/vendor/whisper.cpp/ggml/src/ggml-cuda/sumrows.cuh +5 -0
  219. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
  220. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +10 -0
  221. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
  222. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
  223. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +10 -0
  224. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
  225. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +10 -0
  226. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +10 -0
  227. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
  228. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
  229. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
  230. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
  231. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +10 -0
  232. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +10 -0
  233. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
  234. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
  235. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
  236. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +10 -0
  237. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +10 -0
  238. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-f16.cu +5 -0
  239. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q4_0.cu +5 -0
  240. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q4_1.cu +5 -0
  241. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q5_0.cu +5 -0
  242. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q5_1.cu +5 -0
  243. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q8_0.cu +5 -0
  244. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-f16.cu +5 -0
  245. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q4_0.cu +5 -0
  246. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q4_1.cu +5 -0
  247. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q5_0.cu +5 -0
  248. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q5_1.cu +5 -0
  249. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q8_0.cu +5 -0
  250. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-f16.cu +5 -0
  251. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q4_0.cu +5 -0
  252. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q4_1.cu +5 -0
  253. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q5_0.cu +5 -0
  254. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q5_1.cu +5 -0
  255. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q8_0.cu +5 -0
  256. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-f16.cu +5 -0
  257. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q4_0.cu +5 -0
  258. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q4_1.cu +5 -0
  259. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q5_0.cu +5 -0
  260. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q5_1.cu +5 -0
  261. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q8_0.cu +5 -0
  262. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-f16.cu +5 -0
  263. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q4_0.cu +5 -0
  264. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q4_1.cu +5 -0
  265. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q5_0.cu +5 -0
  266. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q5_1.cu +5 -0
  267. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q8_0.cu +5 -0
  268. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-f16.cu +5 -0
  269. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q4_0.cu +5 -0
  270. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q4_1.cu +5 -0
  271. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q5_0.cu +5 -0
  272. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q5_1.cu +5 -0
  273. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q8_0.cu +5 -0
  274. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs256-f16-f16.cu +5 -0
  275. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-f16.cu +5 -0
  276. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q4_0.cu +5 -0
  277. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q4_1.cu +5 -0
  278. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q5_0.cu +5 -0
  279. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q5_1.cu +5 -0
  280. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q8_0.cu +5 -0
  281. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-f16.cu +5 -0
  282. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q4_0.cu +5 -0
  283. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q4_1.cu +5 -0
  284. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q5_0.cu +5 -0
  285. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q5_1.cu +5 -0
  286. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q8_0.cu +5 -0
  287. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-f16.cu +5 -0
  288. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q4_0.cu +5 -0
  289. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q4_1.cu +5 -0
  290. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q5_0.cu +5 -0
  291. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q5_1.cu +5 -0
  292. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q8_0.cu +5 -0
  293. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-f16.cu +5 -0
  294. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q4_0.cu +5 -0
  295. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q4_1.cu +5 -0
  296. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q5_0.cu +5 -0
  297. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q5_1.cu +5 -0
  298. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q8_0.cu +5 -0
  299. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-f16.cu +5 -0
  300. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q4_0.cu +5 -0
  301. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q4_1.cu +5 -0
  302. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q5_0.cu +5 -0
  303. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q5_1.cu +5 -0
  304. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q8_0.cu +5 -0
  305. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-f16.cu +5 -0
  306. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q4_0.cu +5 -0
  307. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q4_1.cu +5 -0
  308. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q5_0.cu +5 -0
  309. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q5_1.cu +5 -0
  310. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q8_0.cu +5 -0
  311. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-f16.cu +5 -0
  312. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q4_0.cu +5 -0
  313. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q4_1.cu +5 -0
  314. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q5_0.cu +5 -0
  315. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q5_1.cu +5 -0
  316. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q8_0.cu +5 -0
  317. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs256-f16-f16.cu +5 -0
  318. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-f16.cu +5 -0
  319. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q4_0.cu +5 -0
  320. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q4_1.cu +5 -0
  321. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q5_0.cu +5 -0
  322. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q5_1.cu +5 -0
  323. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q8_0.cu +5 -0
  324. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/generate_cu_files.py +78 -0
  325. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
  326. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
  327. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
  328. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
  329. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
  330. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
  331. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
  332. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
  333. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
  334. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
  335. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
  336. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
  337. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
  338. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
  339. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
  340. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
  341. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
  342. package/vendor/whisper.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
  343. package/vendor/whisper.cpp/ggml/src/ggml-cuda/tsembd.cu +47 -0
  344. package/vendor/whisper.cpp/ggml/src/ggml-cuda/tsembd.cuh +5 -0
  345. package/vendor/whisper.cpp/ggml/src/ggml-cuda/unary.cu +289 -0
  346. package/vendor/whisper.cpp/ggml/src/ggml-cuda/unary.cuh +59 -0
  347. package/vendor/whisper.cpp/ggml/src/ggml-cuda/upscale.cu +51 -0
  348. package/vendor/whisper.cpp/ggml/src/ggml-cuda/upscale.cuh +5 -0
  349. package/vendor/whisper.cpp/ggml/src/ggml-cuda/vecdotq.cuh +1135 -0
  350. package/vendor/whisper.cpp/ggml/src/ggml-cuda/vendors/cuda.h +15 -0
  351. package/vendor/whisper.cpp/ggml/src/ggml-cuda/vendors/hip.h +243 -0
  352. package/vendor/whisper.cpp/ggml/src/ggml-cuda/vendors/musa.h +140 -0
  353. package/vendor/whisper.cpp/ggml/src/ggml-cuda/wkv.cu +199 -0
  354. package/vendor/whisper.cpp/ggml/src/ggml-cuda/wkv.cuh +7 -0
  355. package/vendor/whisper.cpp/ggml/src/ggml-hip/CMakeLists.txt +135 -0
  356. package/vendor/whisper.cpp/ggml/src/ggml-impl.h +603 -0
  357. package/vendor/whisper.cpp/ggml/src/ggml-kompute/CMakeLists.txt +166 -0
  358. package/vendor/whisper.cpp/ggml/src/ggml-kompute/ggml-kompute.cpp +2251 -0
  359. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/common.comp +112 -0
  360. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_add.comp +58 -0
  361. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_addrow.comp +25 -0
  362. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f16_f16.comp +52 -0
  363. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f16_f32.comp +52 -0
  364. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f32_f16.comp +52 -0
  365. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f32_f32.comp +52 -0
  366. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_diagmask.comp +30 -0
  367. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_gelu.comp +22 -0
  368. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows.comp +17 -0
  369. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_f16.comp +31 -0
  370. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_f32.comp +31 -0
  371. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q4_0.comp +38 -0
  372. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q4_1.comp +39 -0
  373. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q6_k.comp +44 -0
  374. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul.comp +52 -0
  375. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_f16.comp +69 -0
  376. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_mat_f32.comp +51 -0
  377. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_0.comp +33 -0
  378. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_1.comp +35 -0
  379. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_k.comp +140 -0
  380. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q6_k.comp +106 -0
  381. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q8_0.comp +73 -0
  382. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mv_q_n.comp +52 -0
  383. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mv_q_n_pre.comp +28 -0
  384. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_norm.comp +84 -0
  385. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_relu.comp +21 -0
  386. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rmsnorm.comp +53 -0
  387. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_neox_f16.comp +52 -0
  388. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_neox_f32.comp +52 -0
  389. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_norm_f16.comp +52 -0
  390. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_norm_f32.comp +52 -0
  391. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_scale.comp +19 -0
  392. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_scale_8.comp +23 -0
  393. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_silu.comp +22 -0
  394. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/op_softmax.comp +72 -0
  395. package/vendor/whisper.cpp/ggml/src/ggml-kompute/kompute-shaders/rope_common.comp +71 -0
  396. package/vendor/whisper.cpp/ggml/src/ggml-metal/CMakeLists.txt +121 -0
  397. package/vendor/whisper.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +622 -0
  398. package/vendor/whisper.cpp/ggml/src/ggml-metal/ggml-metal.m +6023 -0
  399. package/vendor/whisper.cpp/ggml/src/ggml-metal/ggml-metal.metal +7124 -0
  400. package/vendor/whisper.cpp/ggml/src/ggml-musa/CMakeLists.txt +113 -0
  401. package/vendor/whisper.cpp/ggml/src/ggml-musa/mudnn.cu +112 -0
  402. package/vendor/whisper.cpp/ggml/src/ggml-musa/mudnn.cuh +12 -0
  403. package/vendor/whisper.cpp/ggml/src/ggml-opencl/CMakeLists.txt +109 -0
  404. package/vendor/whisper.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +6665 -0
  405. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/add.cl +83 -0
  406. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/argsort.cl +86 -0
  407. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/clamp.cl +20 -0
  408. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/concat.cl +109 -0
  409. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/cpy.cl +184 -0
  410. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/cvt.cl +118 -0
  411. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/diag_mask_inf.cl +58 -0
  412. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/div.cl +72 -0
  413. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/embed_kernel.py +26 -0
  414. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/gelu.cl +62 -0
  415. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/gemv_noshuffle.cl +268 -0
  416. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/gemv_noshuffle_general.cl +274 -0
  417. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/get_rows.cl +163 -0
  418. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/group_norm.cl +72 -0
  419. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/im2col_f16.cl +57 -0
  420. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/im2col_f32.cl +57 -0
  421. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul.cl +79 -0
  422. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mat_Ab_Bi_8x4.cl +139 -0
  423. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_f16_f16.cl +118 -0
  424. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32.cl +118 -0
  425. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_1row.cl +94 -0
  426. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +84 -0
  427. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_f32_f32.cl +118 -0
  428. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_id_q4_0_f32_8x_flat.cl +283 -0
  429. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32.cl +192 -0
  430. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_1d_16x_flat.cl +307 -0
  431. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_1d_8x_flat.cl +265 -0
  432. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_8x_flat.cl +272 -0
  433. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_v.cl +254 -0
  434. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/mul_mv_q6_k.cl +190 -0
  435. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/norm.cl +81 -0
  436. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/pad.cl +30 -0
  437. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/relu.cl +16 -0
  438. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/repeat.cl +39 -0
  439. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/rms_norm.cl +96 -0
  440. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/rope.cl +721 -0
  441. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/scale.cl +16 -0
  442. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/sigmoid.cl +29 -0
  443. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/silu.cl +30 -0
  444. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/softmax_4_f16.cl +87 -0
  445. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/softmax_4_f32.cl +87 -0
  446. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/softmax_f16.cl +86 -0
  447. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/softmax_f32.cl +86 -0
  448. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/sub.cl +72 -0
  449. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/sum_rows.cl +39 -0
  450. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/tanh.cl +63 -0
  451. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/transpose.cl +84 -0
  452. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/tsembd.cl +48 -0
  453. package/vendor/whisper.cpp/ggml/src/ggml-opencl/kernels/upscale.cl +121 -0
  454. package/vendor/whisper.cpp/ggml/src/ggml-opt.cpp +1037 -0
  455. package/vendor/whisper.cpp/ggml/src/ggml-quants.c +5230 -0
  456. package/vendor/whisper.cpp/ggml/src/ggml-quants.h +100 -0
  457. package/vendor/whisper.cpp/ggml/src/ggml-rpc/CMakeLists.txt +9 -0
  458. package/vendor/whisper.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +1816 -0
  459. package/vendor/whisper.cpp/ggml/src/ggml-sycl/CMakeLists.txt +189 -0
  460. package/vendor/whisper.cpp/ggml/src/ggml-sycl/backend.hpp +37 -0
  461. package/vendor/whisper.cpp/ggml/src/ggml-sycl/binbcast.cpp +344 -0
  462. package/vendor/whisper.cpp/ggml/src/ggml-sycl/binbcast.hpp +39 -0
  463. package/vendor/whisper.cpp/ggml/src/ggml-sycl/common.cpp +83 -0
  464. package/vendor/whisper.cpp/ggml/src/ggml-sycl/common.hpp +584 -0
  465. package/vendor/whisper.cpp/ggml/src/ggml-sycl/concat.cpp +182 -0
  466. package/vendor/whisper.cpp/ggml/src/ggml-sycl/concat.hpp +20 -0
  467. package/vendor/whisper.cpp/ggml/src/ggml-sycl/conv.cpp +95 -0
  468. package/vendor/whisper.cpp/ggml/src/ggml-sycl/conv.hpp +20 -0
  469. package/vendor/whisper.cpp/ggml/src/ggml-sycl/convert.cpp +575 -0
  470. package/vendor/whisper.cpp/ggml/src/ggml-sycl/convert.hpp +34 -0
  471. package/vendor/whisper.cpp/ggml/src/ggml-sycl/cpy.cpp +839 -0
  472. package/vendor/whisper.cpp/ggml/src/ggml-sycl/cpy.hpp +11 -0
  473. package/vendor/whisper.cpp/ggml/src/ggml-sycl/dequantize.hpp +823 -0
  474. package/vendor/whisper.cpp/ggml/src/ggml-sycl/dmmv.cpp +1144 -0
  475. package/vendor/whisper.cpp/ggml/src/ggml-sycl/dmmv.hpp +27 -0
  476. package/vendor/whisper.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +2987 -0
  477. package/vendor/whisper.cpp/ggml/src/ggml-sycl/element_wise.cpp +1511 -0
  478. package/vendor/whisper.cpp/ggml/src/ggml-sycl/element_wise.hpp +77 -0
  479. package/vendor/whisper.cpp/ggml/src/ggml-sycl/gemm.hpp +102 -0
  480. package/vendor/whisper.cpp/ggml/src/ggml-sycl/getrows.cpp +212 -0
  481. package/vendor/whisper.cpp/ggml/src/ggml-sycl/getrows.hpp +20 -0
  482. package/vendor/whisper.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +4608 -0
  483. package/vendor/whisper.cpp/ggml/src/ggml-sycl/gla.cpp +106 -0
  484. package/vendor/whisper.cpp/ggml/src/ggml-sycl/gla.hpp +8 -0
  485. package/vendor/whisper.cpp/ggml/src/ggml-sycl/im2col.cpp +136 -0
  486. package/vendor/whisper.cpp/ggml/src/ggml-sycl/im2col.hpp +21 -0
  487. package/vendor/whisper.cpp/ggml/src/ggml-sycl/mmq.cpp +3010 -0
  488. package/vendor/whisper.cpp/ggml/src/ggml-sycl/mmq.hpp +33 -0
  489. package/vendor/whisper.cpp/ggml/src/ggml-sycl/mmvq.cpp +1065 -0
  490. package/vendor/whisper.cpp/ggml/src/ggml-sycl/mmvq.hpp +27 -0
  491. package/vendor/whisper.cpp/ggml/src/ggml-sycl/norm.cpp +482 -0
  492. package/vendor/whisper.cpp/ggml/src/ggml-sycl/norm.hpp +26 -0
  493. package/vendor/whisper.cpp/ggml/src/ggml-sycl/outprod.cpp +47 -0
  494. package/vendor/whisper.cpp/ggml/src/ggml-sycl/outprod.hpp +10 -0
  495. package/vendor/whisper.cpp/ggml/src/ggml-sycl/presets.hpp +74 -0
  496. package/vendor/whisper.cpp/ggml/src/ggml-sycl/quants.hpp +111 -0
  497. package/vendor/whisper.cpp/ggml/src/ggml-sycl/rope.cpp +472 -0
  498. package/vendor/whisper.cpp/ggml/src/ggml-sycl/rope.hpp +20 -0
  499. package/vendor/whisper.cpp/ggml/src/ggml-sycl/softmax.cpp +261 -0
  500. package/vendor/whisper.cpp/ggml/src/ggml-sycl/softmax.hpp +20 -0
  501. package/vendor/whisper.cpp/ggml/src/ggml-sycl/sycl_hw.cpp +13 -0
  502. package/vendor/whisper.cpp/ggml/src/ggml-sycl/sycl_hw.hpp +23 -0
  503. package/vendor/whisper.cpp/ggml/src/ggml-sycl/tsembd.cpp +67 -0
  504. package/vendor/whisper.cpp/ggml/src/ggml-sycl/tsembd.hpp +20 -0
  505. package/vendor/whisper.cpp/ggml/src/ggml-sycl/vecdotq.hpp +1307 -0
  506. package/vendor/whisper.cpp/ggml/src/ggml-sycl/wkv.cpp +289 -0
  507. package/vendor/whisper.cpp/ggml/src/ggml-sycl/wkv.hpp +10 -0
  508. package/vendor/whisper.cpp/ggml/src/ggml-threading.cpp +12 -0
  509. package/vendor/whisper.cpp/ggml/src/ggml-threading.h +14 -0
  510. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +189 -0
  511. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/cmake/host-toolchain.cmake.in +15 -0
  512. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +10937 -0
  513. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +27 -0
  514. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/acc.comp +29 -0
  515. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/add.comp +29 -0
  516. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/argmax.comp +51 -0
  517. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/argsort.comp +69 -0
  518. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +17 -0
  519. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/concat.comp +41 -0
  520. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/contig_copy.comp +49 -0
  521. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_dw.comp +105 -0
  522. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/conv_transpose_1d.comp +98 -0
  523. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/copy.comp +23 -0
  524. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/copy_from_quant.comp +51 -0
  525. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/copy_to_quant.comp +242 -0
  526. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +17 -0
  527. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/count_equal.comp +31 -0
  528. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_f32.comp +20 -0
  529. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs.comp +462 -0
  530. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs_cm2.comp +699 -0
  531. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_head.comp +13 -0
  532. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq1_m.comp +42 -0
  533. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq1_s.comp +35 -0
  534. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_s.comp +44 -0
  535. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_xs.comp +43 -0
  536. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_xxs.comp +48 -0
  537. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq3_s.comp +39 -0
  538. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq3_xxs.comp +49 -0
  539. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq4_nl.comp +32 -0
  540. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq4_xs.comp +34 -0
  541. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q2_k.comp +34 -0
  542. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q3_k.comp +42 -0
  543. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_0.comp +30 -0
  544. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_1.comp +32 -0
  545. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_k.comp +68 -0
  546. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_0.comp +34 -0
  547. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_1.comp +35 -0
  548. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_k.comp +70 -0
  549. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q6_k.comp +33 -0
  550. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q8_0.comp +31 -0
  551. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/diag_mask_inf.comp +34 -0
  552. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/div.comp +27 -0
  553. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +337 -0
  554. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_base.comp +162 -0
  555. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +360 -0
  556. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp +267 -0
  557. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_split_k_reduce.comp +59 -0
  558. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +25 -0
  559. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +23 -0
  560. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/generic_binary_head.comp +64 -0
  561. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/generic_head.comp +9 -0
  562. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.comp +76 -0
  563. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/get_rows.comp +33 -0
  564. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_quant.comp +41 -0
  565. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/group_norm.comp +66 -0
  566. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/im2col.comp +100 -0
  567. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +41 -0
  568. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +22 -0
  569. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul.comp +27 -0
  570. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_split_k_reduce.comp +48 -0
  571. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec.comp +169 -0
  572. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_base.comp +118 -0
  573. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq1_m.comp +82 -0
  574. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq1_s.comp +79 -0
  575. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_s.comp +90 -0
  576. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_xs.comp +87 -0
  577. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_xxs.comp +87 -0
  578. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq3_s.comp +90 -0
  579. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq3_xxs.comp +88 -0
  580. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_nc.comp +118 -0
  581. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_p021.comp +154 -0
  582. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q2_k.comp +130 -0
  583. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q3_k.comp +132 -0
  584. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q4_k.comp +136 -0
  585. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q5_k.comp +167 -0
  586. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q6_k.comp +130 -0
  587. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +868 -0
  588. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +441 -0
  589. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq.comp +442 -0
  590. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq_funcs.comp +99 -0
  591. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +44 -0
  592. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/opt_step_adamw.comp +42 -0
  593. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/pad.comp +28 -0
  594. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/pool2d.comp +74 -0
  595. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/quantize_q8_1.comp +77 -0
  596. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +21 -0
  597. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/repeat.comp +26 -0
  598. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +37 -0
  599. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +52 -0
  600. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm_back.comp +55 -0
  601. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_head.comp +58 -0
  602. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_multi.comp +60 -0
  603. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_neox.comp +43 -0
  604. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp +43 -0
  605. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_vision.comp +47 -0
  606. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/scale.comp +24 -0
  607. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +20 -0
  608. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +22 -0
  609. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/silu_back.comp +26 -0
  610. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +17 -0
  611. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp +173 -0
  612. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_back.comp +50 -0
  613. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +17 -0
  614. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/sub.comp +29 -0
  615. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/sum_rows.comp +37 -0
  616. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +20 -0
  617. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/test_bfloat16_support.comp +7 -0
  618. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/test_coopmat2_support.comp +7 -0
  619. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/test_coopmat_support.comp +7 -0
  620. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/test_integer_dot_support.comp +7 -0
  621. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/timestep_embedding.comp +41 -0
  622. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/types.comp +1373 -0
  623. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/upscale.comp +36 -0
  624. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +753 -0
  625. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/wkv6.comp +87 -0
  626. package/vendor/whisper.cpp/ggml/src/ggml-vulkan/vulkan-shaders/wkv7.comp +91 -0
  627. package/vendor/whisper.cpp/ggml/src/ggml.c +6601 -0
  628. package/vendor/whisper.cpp/ggml/src/ggml.cpp +26 -0
  629. package/vendor/whisper.cpp/ggml/src/gguf.cpp +1347 -0
  630. package/vendor/whisper.cpp/include/whisper.h +738 -0
  631. package/vendor/whisper.cpp/src/CMakeLists.txt +145 -0
  632. package/vendor/whisper.cpp/src/coreml/whisper-compat.h +10 -0
  633. package/vendor/whisper.cpp/src/coreml/whisper-compat.m +35 -0
  634. package/vendor/whisper.cpp/src/coreml/whisper-decoder-impl.h +158 -0
  635. package/vendor/whisper.cpp/src/coreml/whisper-decoder-impl.m +227 -0
  636. package/vendor/whisper.cpp/src/coreml/whisper-encoder-impl.h +154 -0
  637. package/vendor/whisper.cpp/src/coreml/whisper-encoder-impl.m +223 -0
  638. package/vendor/whisper.cpp/src/coreml/whisper-encoder.h +26 -0
  639. package/vendor/whisper.cpp/src/coreml/whisper-encoder.mm +73 -0
  640. package/vendor/whisper.cpp/src/openvino/whisper-openvino-encoder.cpp +108 -0
  641. package/vendor/whisper.cpp/src/openvino/whisper-openvino-encoder.h +31 -0
  642. package/vendor/whisper.cpp/src/whisper-arch.h +197 -0
  643. package/vendor/whisper.cpp/src/whisper.cpp +8969 -0
@@ -0,0 +1,2221 @@
1
+ #pragma once
2
+
3
+ //
4
+ // GGML Tensor Library
5
+ //
6
+ // This documentation is still a work in progress.
7
+ // If you wish some specific topics to be covered, feel free to drop a comment:
8
+ //
9
+ // https://github.com/ggerganov/whisper.cpp/issues/40
10
+ //
11
+ // ## Overview
12
+ //
13
+ // This library implements:
14
+ //
15
+ // - a set of tensor operations
16
+ // - automatic differentiation
17
+ // - basic optimization algorithms
18
+ //
19
+ // The aim of this library is to provide a minimalistic approach for various machine learning tasks. This includes,
20
+ // but is not limited to, the following:
21
+ //
22
+ // - linear regression
23
+ // - support vector machines
24
+ // - neural networks
25
+ //
26
+ // The library allows the user to define a certain function using the available tensor operations. This function
27
+ // definition is represented internally via a computation graph. Each tensor operation in the function definition
28
+ // corresponds to a node in the graph. Having the computation graph defined, the user can choose to compute the
29
+ // function's value and/or its gradient with respect to the input variables. Optionally, the function can be optimized
30
+ // using one of the available optimization algorithms.
31
+ //
32
+ // For example, here we define the function: f(x) = a*x^2 + b
33
+ //
34
+ // {
35
+ // struct ggml_init_params params = {
36
+ // .mem_size = 16*1024*1024,
37
+ // .mem_buffer = NULL,
38
+ // };
39
+ //
40
+ // // memory allocation happens here
41
+ // struct ggml_context * ctx = ggml_init(params);
42
+ //
43
+ // struct ggml_tensor * x = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 1);
44
+ //
45
+ // ggml_set_param(ctx, x); // x is an input variable
46
+ //
47
+ // struct ggml_tensor * a = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 1);
48
+ // struct ggml_tensor * b = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, 1);
49
+ // struct ggml_tensor * x2 = ggml_mul(ctx, x, x);
50
+ // struct ggml_tensor * f = ggml_add(ctx, ggml_mul(ctx, a, x2), b);
51
+ //
52
+ // ...
53
+ // }
54
+ //
55
+ // Notice that the function definition above does not involve any actual computation. The computation is performed only
56
+ // when the user explicitly requests it. For example, to compute the function's value at x = 2.0:
57
+ //
58
+ // {
59
+ // ...
60
+ //
61
+ // struct ggml_cgraph * gf = ggml_new_graph(ctx);
62
+ // ggml_build_forward_expand(gf, f);
63
+ //
64
+ // // set the input variable and parameter values
65
+ // ggml_set_f32(x, 2.0f);
66
+ // ggml_set_f32(a, 3.0f);
67
+ // ggml_set_f32(b, 4.0f);
68
+ //
69
+ // ggml_graph_compute_with_ctx(ctx, &gf, n_threads);
70
+ //
71
+ // printf("f = %f\n", ggml_get_f32_1d(f, 0));
72
+ //
73
+ // ...
74
+ // }
75
+ //
76
+ // The actual computation is performed in the ggml_graph_compute() function.
77
+ //
78
+ // The ggml_new_tensor_...() functions create new tensors. They are allocated in the memory buffer provided to the
79
+ // ggml_init() function. You have to be careful not to exceed the memory buffer size. Therefore, you have to know
80
+ // in advance how much memory you need for your computation. Alternatively, you can allocate a large enough memory
81
+ // and after defining the computation graph, call the ggml_used_mem() function to find out how much memory was
82
+ // actually needed.
83
+ //
84
+ // The ggml_set_param() function marks a tensor as an input variable. This is used by the automatic
85
+ // differentiation and optimization algorithms.
86
+ //
87
+ // The described approach allows to define the function graph once and then compute its forward or backward graphs
88
+ // multiple times. All computations will use the same memory buffer allocated in the ggml_init() function. This way
89
+ // the user can avoid the memory allocation overhead at runtime.
90
+ //
91
+ // The library supports multi-dimensional tensors - up to 4 dimensions. The FP16 and FP32 data types are first class
92
+ // citizens, but in theory the library can be extended to support FP8 and integer data types.
93
+ //
94
+ // Each tensor operation produces a new tensor. Initially the library was envisioned to support only the use of unary
95
+ // and binary operations. Most of the available operations fall into one of these two categories. With time, it became
96
+ // clear that the library needs to support more complex operations. The way to support these operations is not clear
97
+ // yet, but a few examples are demonstrated in the following operations:
98
+ //
99
+ // - ggml_permute()
100
+ // - ggml_conv_1d_1s()
101
+ // - ggml_conv_1d_2s()
102
+ //
103
+ // For each tensor operator, the library implements a forward and backward computation function. The forward function
104
+ // computes the output tensor value given the input tensor values. The backward function computes the adjoint of the
105
+ // input tensors given the adjoint of the output tensor. For a detailed explanation of what this means, take a
106
+ // calculus class, or watch the following video:
107
+ //
108
+ // What is Automatic Differentiation?
109
+ // https://www.youtube.com/watch?v=wG_nF1awSSY
110
+ //
111
+ //
112
+ // ## Tensor data (struct ggml_tensor)
113
+ //
114
+ // The tensors are stored in memory via the ggml_tensor struct. The structure provides information about the size of
115
+ // the tensor, the data type, and the memory buffer where the tensor data is stored. Additionally, it contains
116
+ // pointers to the "source" tensors - i.e. the tensors that were used to compute the current tensor. For example:
117
+ //
118
+ // {
119
+ // struct ggml_tensor * c = ggml_add(ctx, a, b);
120
+ //
121
+ // assert(c->src[0] == a);
122
+ // assert(c->src[1] == b);
123
+ // }
124
+ //
125
+ // The multi-dimensional tensors are stored in row-major order. The ggml_tensor struct contains fields for the
126
+ // number of elements in each dimension ("ne") as well as the number of bytes ("nb", a.k.a. stride). This allows
127
+ // to store tensors that are not contiguous in memory, which is useful for operations such as transposition and
128
+ // permutation. All tensor operations have to take the stride into account and not assume that the tensor is
129
+ // contiguous in memory.
130
+ //
131
+ // The data of the tensor is accessed via the "data" pointer. For example:
132
+ //
133
+ // {
134
+ // const int nx = 2;
135
+ // const int ny = 3;
136
+ //
137
+ // struct ggml_tensor * a = ggml_new_tensor_2d(ctx, GGML_TYPE_F32, nx, ny);
138
+ //
139
+ // for (int y = 0; y < ny; y++) {
140
+ // for (int x = 0; x < nx; x++) {
141
+ // *(float *) ((char *) a->data + y*a->nb[1] + x*a->nb[0]) = x + y;
142
+ // }
143
+ // }
144
+ //
145
+ // ...
146
+ // }
147
+ //
148
+ // Alternatively, there are helper functions, such as ggml_get_f32_1d() and ggml_set_f32_1d() that can be used.
149
+ //
150
+ // ## The matrix multiplication operator (ggml_mul_mat)
151
+ //
152
+ // TODO
153
+ //
154
+ //
155
+ // ## Multi-threading
156
+ //
157
+ // TODO
158
+ //
159
+ //
160
+ // ## Overview of ggml.c
161
+ //
162
+ // TODO
163
+ //
164
+ //
165
+ // ## SIMD optimizations
166
+ //
167
+ // TODO
168
+ //
169
+ //
170
+ // ## Debugging ggml
171
+ //
172
+ // TODO
173
+ //
174
+ //
175
+
176
+ #ifdef GGML_SHARED
177
+ # if defined(_WIN32) && !defined(__MINGW32__)
178
+ # ifdef GGML_BUILD
179
+ # define GGML_API __declspec(dllexport) extern
180
+ # else
181
+ # define GGML_API __declspec(dllimport) extern
182
+ # endif
183
+ # else
184
+ # define GGML_API __attribute__ ((visibility ("default"))) extern
185
+ # endif
186
+ #else
187
+ # define GGML_API extern
188
+ #endif
189
+
190
+ // TODO: support for clang
191
+ #ifdef __GNUC__
192
+ # define GGML_DEPRECATED(func, hint) func __attribute__((deprecated(hint)))
193
+ #elif defined(_MSC_VER)
194
+ # define GGML_DEPRECATED(func, hint) __declspec(deprecated(hint)) func
195
+ #else
196
+ # define GGML_DEPRECATED(func, hint) func
197
+ #endif
198
+
199
+ #ifndef __GNUC__
200
+ # define GGML_ATTRIBUTE_FORMAT(...)
201
+ #elif defined(__MINGW32__) && !defined(__clang__)
202
+ # define GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
203
+ #else
204
+ # define GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(printf, __VA_ARGS__)))
205
+ #endif
206
+
207
+ #include <stdbool.h>
208
+ #include <stddef.h>
209
+ #include <stdint.h>
210
+ #include <stdio.h>
211
+
212
+ #define GGML_FILE_MAGIC 0x67676d6c // "ggml"
213
+ #define GGML_FILE_VERSION 2
214
+
215
+ #define GGML_QNT_VERSION 2 // bump this on quantization format changes
216
+ #define GGML_QNT_VERSION_FACTOR 1000 // do not change this
217
+
218
+ #define GGML_MAX_DIMS 4
219
+ #define GGML_MAX_PARAMS 2048
220
+ #define GGML_MAX_SRC 10
221
+ #define GGML_MAX_N_THREADS 512
222
+ #define GGML_MAX_OP_PARAMS 64
223
+
224
+ #ifndef GGML_MAX_NAME
225
+ # define GGML_MAX_NAME 64
226
+ #endif
227
+
228
+ #define GGML_DEFAULT_N_THREADS 4
229
+ #define GGML_DEFAULT_GRAPH_SIZE 2048
230
+
231
+ #if UINTPTR_MAX == 0xFFFFFFFF
232
+ #define GGML_MEM_ALIGN 4
233
+ #else
234
+ #define GGML_MEM_ALIGN 16
235
+ #endif
236
+
237
+ #define GGML_EXIT_SUCCESS 0
238
+ #define GGML_EXIT_ABORTED 1
239
+
240
+ #define GGML_ROPE_TYPE_NEOX 2
241
+ #define GGML_ROPE_TYPE_MROPE 8
242
+ #define GGML_ROPE_TYPE_VISION 24
243
+
244
+ #define GGML_UNUSED(x) (void)(x)
245
+
246
+ #define GGML_PAD(x, n) (((x) + (n) - 1) & ~((n) - 1))
247
+
248
+ #ifndef NDEBUG
249
+ # define GGML_UNREACHABLE() do { fprintf(stderr, "statement should be unreachable\n"); abort(); } while(0)
250
+ #elif defined(__GNUC__)
251
+ # define GGML_UNREACHABLE() __builtin_unreachable()
252
+ #elif defined(_MSC_VER)
253
+ # define GGML_UNREACHABLE() __assume(0)
254
+ #else
255
+ # define GGML_UNREACHABLE() ((void) 0)
256
+ #endif
257
+
258
+ #ifdef __cplusplus
259
+ # define GGML_NORETURN [[noreturn]]
260
+ #elif defined(_MSC_VER)
261
+ # define GGML_NORETURN __declspec(noreturn)
262
+ #else
263
+ # define GGML_NORETURN _Noreturn
264
+ #endif
265
+
266
+ #define GGML_ABORT(...) ggml_abort(__FILE__, __LINE__, __VA_ARGS__)
267
+ #define GGML_ASSERT(x) if (!(x)) GGML_ABORT("GGML_ASSERT(%s) failed", #x)
268
+
269
+ // used to copy the number of elements and stride in bytes of tensors into local variables.
270
+ // main purpose is to reduce code duplication and improve readability.
271
+ //
272
+ // example:
273
+ //
274
+ // GGML_TENSOR_LOCALS(int64_t, ne1, src1, ne);
275
+ // GGML_TENSOR_LOCALS(size_t, nb1, src1, nb);
276
+ //
277
+ #define GGML_TENSOR_LOCALS_1(type, prefix, pointer, array) \
278
+ const type prefix##0 = (pointer)->array[0]; \
279
+ GGML_UNUSED(prefix##0);
280
+ #define GGML_TENSOR_LOCALS_2(type, prefix, pointer, array) \
281
+ GGML_TENSOR_LOCALS_1 (type, prefix, pointer, array) \
282
+ const type prefix##1 = (pointer)->array[1]; \
283
+ GGML_UNUSED(prefix##1);
284
+ #define GGML_TENSOR_LOCALS_3(type, prefix, pointer, array) \
285
+ GGML_TENSOR_LOCALS_2 (type, prefix, pointer, array) \
286
+ const type prefix##2 = (pointer)->array[2]; \
287
+ GGML_UNUSED(prefix##2);
288
+ #define GGML_TENSOR_LOCALS(type, prefix, pointer, array) \
289
+ GGML_TENSOR_LOCALS_3 (type, prefix, pointer, array) \
290
+ const type prefix##3 = (pointer)->array[3]; \
291
+ GGML_UNUSED(prefix##3);
292
+
293
+ #define GGML_TENSOR_UNARY_OP_LOCALS \
294
+ GGML_TENSOR_LOCALS(int64_t, ne0, src0, ne) \
295
+ GGML_TENSOR_LOCALS(size_t, nb0, src0, nb) \
296
+ GGML_TENSOR_LOCALS(int64_t, ne, dst, ne) \
297
+ GGML_TENSOR_LOCALS(size_t, nb, dst, nb)
298
+
299
+ #define GGML_TENSOR_BINARY_OP_LOCALS \
300
+ GGML_TENSOR_LOCALS(int64_t, ne0, src0, ne) \
301
+ GGML_TENSOR_LOCALS(size_t, nb0, src0, nb) \
302
+ GGML_TENSOR_LOCALS(int64_t, ne1, src1, ne) \
303
+ GGML_TENSOR_LOCALS(size_t, nb1, src1, nb) \
304
+ GGML_TENSOR_LOCALS(int64_t, ne, dst, ne) \
305
+ GGML_TENSOR_LOCALS(size_t, nb, dst, nb)
306
+
307
+ #define GGML_TENSOR_BINARY_OP_LOCALS01 \
308
+ GGML_TENSOR_LOCALS(int64_t, ne0, src0, ne) \
309
+ GGML_TENSOR_LOCALS(size_t, nb0, src0, nb) \
310
+ GGML_TENSOR_LOCALS(int64_t, ne1, src1, ne) \
311
+ GGML_TENSOR_LOCALS(size_t, nb1, src1, nb)
312
+
313
+ #ifdef __cplusplus
314
+ extern "C" {
315
+ #endif
316
+
317
+ GGML_NORETURN GGML_ATTRIBUTE_FORMAT(3, 4)
318
+ GGML_API void ggml_abort(const char * file, int line, const char * fmt, ...);
319
+
320
+ enum ggml_status {
321
+ GGML_STATUS_ALLOC_FAILED = -2,
322
+ GGML_STATUS_FAILED = -1,
323
+ GGML_STATUS_SUCCESS = 0,
324
+ GGML_STATUS_ABORTED = 1,
325
+ };
326
+
327
+ // get ggml_status name string
328
+ GGML_API const char * ggml_status_to_string(enum ggml_status status);
329
+
330
+ // ieee 754-2008 half-precision float16
331
+ // todo: make this not an integral type
332
+ typedef uint16_t ggml_fp16_t;
333
+ GGML_API float ggml_fp16_to_fp32(ggml_fp16_t);
334
+ GGML_API ggml_fp16_t ggml_fp32_to_fp16(float);
335
+ GGML_API void ggml_fp16_to_fp32_row(const ggml_fp16_t *, float *, int64_t);
336
+ GGML_API void ggml_fp32_to_fp16_row(const float *, ggml_fp16_t *, int64_t);
337
+
338
+ // google brain half-precision bfloat16
339
+ typedef struct { uint16_t bits; } ggml_bf16_t;
340
+ GGML_API ggml_bf16_t ggml_fp32_to_bf16(float);
341
+ GGML_API float ggml_bf16_to_fp32(ggml_bf16_t); // consider just doing << 16
342
+ GGML_API void ggml_bf16_to_fp32_row(const ggml_bf16_t *, float *, int64_t);
343
+ GGML_API void ggml_fp32_to_bf16_row_ref(const float *, ggml_bf16_t *, int64_t);
344
+ GGML_API void ggml_fp32_to_bf16_row(const float *, ggml_bf16_t *, int64_t);
345
+
346
+ struct ggml_object;
347
+ struct ggml_context;
348
+ struct ggml_cgraph;
349
+
350
+ // NOTE: always add types at the end of the enum to keep backward compatibility
351
+ enum ggml_type {
352
+ GGML_TYPE_F32 = 0,
353
+ GGML_TYPE_F16 = 1,
354
+ GGML_TYPE_Q4_0 = 2,
355
+ GGML_TYPE_Q4_1 = 3,
356
+ // GGML_TYPE_Q4_2 = 4, support has been removed
357
+ // GGML_TYPE_Q4_3 = 5, support has been removed
358
+ GGML_TYPE_Q5_0 = 6,
359
+ GGML_TYPE_Q5_1 = 7,
360
+ GGML_TYPE_Q8_0 = 8,
361
+ GGML_TYPE_Q8_1 = 9,
362
+ GGML_TYPE_Q2_K = 10,
363
+ GGML_TYPE_Q3_K = 11,
364
+ GGML_TYPE_Q4_K = 12,
365
+ GGML_TYPE_Q5_K = 13,
366
+ GGML_TYPE_Q6_K = 14,
367
+ GGML_TYPE_Q8_K = 15,
368
+ GGML_TYPE_IQ2_XXS = 16,
369
+ GGML_TYPE_IQ2_XS = 17,
370
+ GGML_TYPE_IQ3_XXS = 18,
371
+ GGML_TYPE_IQ1_S = 19,
372
+ GGML_TYPE_IQ4_NL = 20,
373
+ GGML_TYPE_IQ3_S = 21,
374
+ GGML_TYPE_IQ2_S = 22,
375
+ GGML_TYPE_IQ4_XS = 23,
376
+ GGML_TYPE_I8 = 24,
377
+ GGML_TYPE_I16 = 25,
378
+ GGML_TYPE_I32 = 26,
379
+ GGML_TYPE_I64 = 27,
380
+ GGML_TYPE_F64 = 28,
381
+ GGML_TYPE_IQ1_M = 29,
382
+ GGML_TYPE_BF16 = 30,
383
+ // GGML_TYPE_Q4_0_4_4 = 31, support has been removed from gguf files
384
+ // GGML_TYPE_Q4_0_4_8 = 32,
385
+ // GGML_TYPE_Q4_0_8_8 = 33,
386
+ GGML_TYPE_TQ1_0 = 34,
387
+ GGML_TYPE_TQ2_0 = 35,
388
+ // GGML_TYPE_IQ4_NL_4_4 = 36,
389
+ // GGML_TYPE_IQ4_NL_4_8 = 37,
390
+ // GGML_TYPE_IQ4_NL_8_8 = 38,
391
+ GGML_TYPE_COUNT = 39,
392
+ };
393
+
394
+ // precision
395
+ enum ggml_prec {
396
+ GGML_PREC_DEFAULT = 0, // stored as ggml_tensor.op_params, 0 by default
397
+ GGML_PREC_F32 = 10,
398
+ };
399
+
400
+ // model file types
401
+ enum ggml_ftype {
402
+ GGML_FTYPE_UNKNOWN = -1,
403
+ GGML_FTYPE_ALL_F32 = 0,
404
+ GGML_FTYPE_MOSTLY_F16 = 1, // except 1d tensors
405
+ GGML_FTYPE_MOSTLY_Q4_0 = 2, // except 1d tensors
406
+ GGML_FTYPE_MOSTLY_Q4_1 = 3, // except 1d tensors
407
+ GGML_FTYPE_MOSTLY_Q4_1_SOME_F16 = 4, // tok_embeddings.weight and output.weight are F16
408
+ GGML_FTYPE_MOSTLY_Q8_0 = 7, // except 1d tensors
409
+ GGML_FTYPE_MOSTLY_Q5_0 = 8, // except 1d tensors
410
+ GGML_FTYPE_MOSTLY_Q5_1 = 9, // except 1d tensors
411
+ GGML_FTYPE_MOSTLY_Q2_K = 10, // except 1d tensors
412
+ GGML_FTYPE_MOSTLY_Q3_K = 11, // except 1d tensors
413
+ GGML_FTYPE_MOSTLY_Q4_K = 12, // except 1d tensors
414
+ GGML_FTYPE_MOSTLY_Q5_K = 13, // except 1d tensors
415
+ GGML_FTYPE_MOSTLY_Q6_K = 14, // except 1d tensors
416
+ GGML_FTYPE_MOSTLY_IQ2_XXS = 15, // except 1d tensors
417
+ GGML_FTYPE_MOSTLY_IQ2_XS = 16, // except 1d tensors
418
+ GGML_FTYPE_MOSTLY_IQ3_XXS = 17, // except 1d tensors
419
+ GGML_FTYPE_MOSTLY_IQ1_S = 18, // except 1d tensors
420
+ GGML_FTYPE_MOSTLY_IQ4_NL = 19, // except 1d tensors
421
+ GGML_FTYPE_MOSTLY_IQ3_S = 20, // except 1d tensors
422
+ GGML_FTYPE_MOSTLY_IQ2_S = 21, // except 1d tensors
423
+ GGML_FTYPE_MOSTLY_IQ4_XS = 22, // except 1d tensors
424
+ GGML_FTYPE_MOSTLY_IQ1_M = 23, // except 1d tensors
425
+ GGML_FTYPE_MOSTLY_BF16 = 24, // except 1d tensors
426
+ };
427
+
428
+ // available tensor operations:
429
+ enum ggml_op {
430
+ GGML_OP_NONE = 0,
431
+
432
+ GGML_OP_DUP,
433
+ GGML_OP_ADD,
434
+ GGML_OP_ADD1,
435
+ GGML_OP_ACC,
436
+ GGML_OP_SUB,
437
+ GGML_OP_MUL,
438
+ GGML_OP_DIV,
439
+ GGML_OP_SQR,
440
+ GGML_OP_SQRT,
441
+ GGML_OP_LOG,
442
+ GGML_OP_SIN,
443
+ GGML_OP_COS,
444
+ GGML_OP_SUM,
445
+ GGML_OP_SUM_ROWS,
446
+ GGML_OP_MEAN,
447
+ GGML_OP_ARGMAX,
448
+ GGML_OP_COUNT_EQUAL,
449
+ GGML_OP_REPEAT,
450
+ GGML_OP_REPEAT_BACK,
451
+ GGML_OP_CONCAT,
452
+ GGML_OP_SILU_BACK,
453
+ GGML_OP_NORM, // normalize
454
+ GGML_OP_RMS_NORM,
455
+ GGML_OP_RMS_NORM_BACK,
456
+ GGML_OP_GROUP_NORM,
457
+ GGML_OP_L2_NORM,
458
+
459
+ GGML_OP_MUL_MAT,
460
+ GGML_OP_MUL_MAT_ID,
461
+ GGML_OP_OUT_PROD,
462
+
463
+ GGML_OP_SCALE,
464
+ GGML_OP_SET,
465
+ GGML_OP_CPY,
466
+ GGML_OP_CONT,
467
+ GGML_OP_RESHAPE,
468
+ GGML_OP_VIEW,
469
+ GGML_OP_PERMUTE,
470
+ GGML_OP_TRANSPOSE,
471
+ GGML_OP_GET_ROWS,
472
+ GGML_OP_GET_ROWS_BACK,
473
+ GGML_OP_DIAG,
474
+ GGML_OP_DIAG_MASK_INF,
475
+ GGML_OP_DIAG_MASK_ZERO,
476
+ GGML_OP_SOFT_MAX,
477
+ GGML_OP_SOFT_MAX_BACK,
478
+ GGML_OP_ROPE,
479
+ GGML_OP_ROPE_BACK,
480
+ GGML_OP_CLAMP,
481
+ GGML_OP_CONV_TRANSPOSE_1D,
482
+ GGML_OP_IM2COL,
483
+ GGML_OP_IM2COL_BACK,
484
+ GGML_OP_CONV_2D_DW,
485
+ GGML_OP_CONV_TRANSPOSE_2D,
486
+ GGML_OP_POOL_1D,
487
+ GGML_OP_POOL_2D,
488
+ GGML_OP_POOL_2D_BACK,
489
+ GGML_OP_UPSCALE, // nearest interpolate
490
+ GGML_OP_PAD,
491
+ GGML_OP_PAD_REFLECT_1D,
492
+ GGML_OP_ROLL,
493
+ GGML_OP_ARANGE,
494
+ GGML_OP_TIMESTEP_EMBEDDING,
495
+ GGML_OP_ARGSORT,
496
+ GGML_OP_LEAKY_RELU,
497
+
498
+ GGML_OP_FLASH_ATTN_EXT,
499
+ GGML_OP_FLASH_ATTN_BACK,
500
+ GGML_OP_SSM_CONV,
501
+ GGML_OP_SSM_SCAN,
502
+ GGML_OP_WIN_PART,
503
+ GGML_OP_WIN_UNPART,
504
+ GGML_OP_GET_REL_POS,
505
+ GGML_OP_ADD_REL_POS,
506
+ GGML_OP_RWKV_WKV6,
507
+ GGML_OP_GATED_LINEAR_ATTN,
508
+ GGML_OP_RWKV_WKV7,
509
+
510
+ GGML_OP_UNARY,
511
+
512
+ GGML_OP_MAP_CUSTOM1,
513
+ GGML_OP_MAP_CUSTOM2,
514
+ GGML_OP_MAP_CUSTOM3,
515
+
516
+ GGML_OP_CUSTOM,
517
+
518
+ GGML_OP_CROSS_ENTROPY_LOSS,
519
+ GGML_OP_CROSS_ENTROPY_LOSS_BACK,
520
+ GGML_OP_OPT_STEP_ADAMW,
521
+
522
+ GGML_OP_COUNT,
523
+ };
524
+
525
+ enum ggml_unary_op {
526
+ GGML_UNARY_OP_ABS,
527
+ GGML_UNARY_OP_SGN,
528
+ GGML_UNARY_OP_NEG,
529
+ GGML_UNARY_OP_STEP,
530
+ GGML_UNARY_OP_TANH,
531
+ GGML_UNARY_OP_ELU,
532
+ GGML_UNARY_OP_RELU,
533
+ GGML_UNARY_OP_SIGMOID,
534
+ GGML_UNARY_OP_GELU,
535
+ GGML_UNARY_OP_GELU_QUICK,
536
+ GGML_UNARY_OP_SILU,
537
+ GGML_UNARY_OP_HARDSWISH,
538
+ GGML_UNARY_OP_HARDSIGMOID,
539
+ GGML_UNARY_OP_EXP,
540
+ GGML_UNARY_OP_GELU_ERF,
541
+
542
+ GGML_UNARY_OP_COUNT,
543
+ };
544
+
545
+ enum ggml_object_type {
546
+ GGML_OBJECT_TYPE_TENSOR,
547
+ GGML_OBJECT_TYPE_GRAPH,
548
+ GGML_OBJECT_TYPE_WORK_BUFFER
549
+ };
550
+
551
+ enum ggml_log_level {
552
+ GGML_LOG_LEVEL_NONE = 0,
553
+ GGML_LOG_LEVEL_DEBUG = 1,
554
+ GGML_LOG_LEVEL_INFO = 2,
555
+ GGML_LOG_LEVEL_WARN = 3,
556
+ GGML_LOG_LEVEL_ERROR = 4,
557
+ GGML_LOG_LEVEL_CONT = 5, // continue previous log
558
+ };
559
+
560
+ // this tensor...
561
+ enum ggml_tensor_flag {
562
+ GGML_TENSOR_FLAG_INPUT = 1, // ...is an input for the GGML compute graph
563
+ GGML_TENSOR_FLAG_OUTPUT = 2, // ...is an output for the GGML compute graph
564
+ GGML_TENSOR_FLAG_PARAM = 4, // ...contains trainable parameters
565
+ GGML_TENSOR_FLAG_LOSS = 8, // ...defines loss for numerical optimization (multiple loss tensors add up)
566
+ };
567
+
568
+ struct ggml_init_params {
569
+ // memory pool
570
+ size_t mem_size; // bytes
571
+ void * mem_buffer; // if NULL, memory will be allocated internally
572
+ bool no_alloc; // don't allocate memory for the tensor data
573
+ };
574
+
575
+ // n-dimensional tensor
576
+ struct ggml_tensor {
577
+ enum ggml_type type;
578
+
579
+ struct ggml_backend_buffer * buffer;
580
+
581
+ int64_t ne[GGML_MAX_DIMS]; // number of elements
582
+ size_t nb[GGML_MAX_DIMS]; // stride in bytes:
583
+ // nb[0] = ggml_type_size(type)
584
+ // nb[1] = nb[0] * (ne[0] / ggml_blck_size(type)) + padding
585
+ // nb[i] = nb[i-1] * ne[i-1]
586
+
587
+ // compute data
588
+ enum ggml_op op;
589
+
590
+ // op params - allocated as int32_t for alignment
591
+ int32_t op_params[GGML_MAX_OP_PARAMS / sizeof(int32_t)];
592
+
593
+ int32_t flags;
594
+
595
+ struct ggml_tensor * src[GGML_MAX_SRC];
596
+
597
+ // source tensor and offset for views
598
+ struct ggml_tensor * view_src;
599
+ size_t view_offs;
600
+
601
+ void * data;
602
+
603
+ char name[GGML_MAX_NAME];
604
+
605
+ void * extra; // extra things e.g. for ggml-cuda.cu
606
+
607
+ char padding[8];
608
+ };
609
+
610
+ static const size_t GGML_TENSOR_SIZE = sizeof(struct ggml_tensor);
611
+
612
+ // Abort callback
613
+ // If not NULL, called before ggml computation
614
+ // If it returns true, the computation is aborted
615
+ typedef bool (*ggml_abort_callback)(void * data);
616
+
617
+
618
+ //
619
+ // GUID
620
+ //
621
+
622
+ // GUID types
623
+ typedef uint8_t ggml_guid[16];
624
+ typedef ggml_guid * ggml_guid_t;
625
+
626
+ GGML_API bool ggml_guid_matches(ggml_guid_t guid_a, ggml_guid_t guid_b);
627
+
628
+ // misc
629
+
630
+ GGML_API void ggml_time_init(void); // call this once at the beginning of the program
631
+ GGML_API int64_t ggml_time_ms(void);
632
+ GGML_API int64_t ggml_time_us(void);
633
+ GGML_API int64_t ggml_cycles(void);
634
+ GGML_API int64_t ggml_cycles_per_ms(void);
635
+
636
+ // accepts a UTF-8 path, even on Windows
637
+ GGML_API FILE * ggml_fopen(const char * fname, const char * mode);
638
+
639
+ GGML_API void ggml_print_object (const struct ggml_object * obj);
640
+ GGML_API void ggml_print_objects(const struct ggml_context * ctx);
641
+
642
+ GGML_API int64_t ggml_nelements (const struct ggml_tensor * tensor);
643
+ GGML_API int64_t ggml_nrows (const struct ggml_tensor * tensor);
644
+ GGML_API size_t ggml_nbytes (const struct ggml_tensor * tensor);
645
+ GGML_API size_t ggml_nbytes_pad(const struct ggml_tensor * tensor); // same as ggml_nbytes() but padded to GGML_MEM_ALIGN
646
+
647
+ GGML_API int64_t ggml_blck_size(enum ggml_type type);
648
+ GGML_API size_t ggml_type_size(enum ggml_type type); // size in bytes for all elements in a block
649
+ GGML_API size_t ggml_row_size (enum ggml_type type, int64_t ne); // size in bytes for all elements in a row
650
+
651
+ GGML_DEPRECATED(
652
+ GGML_API double ggml_type_sizef(enum ggml_type type), // ggml_type_size()/ggml_blck_size() as float
653
+ "use ggml_row_size() instead");
654
+
655
+ GGML_API const char * ggml_type_name(enum ggml_type type);
656
+ GGML_API const char * ggml_op_name (enum ggml_op op);
657
+ GGML_API const char * ggml_op_symbol(enum ggml_op op);
658
+
659
+ GGML_API const char * ggml_unary_op_name(enum ggml_unary_op op);
660
+ GGML_API const char * ggml_op_desc(const struct ggml_tensor * t); // unary or op name
661
+
662
+ GGML_API size_t ggml_element_size(const struct ggml_tensor * tensor);
663
+
664
+ GGML_API bool ggml_is_quantized(enum ggml_type type);
665
+
666
+ // TODO: temporary until model loading of ggml examples is refactored
667
+ GGML_API enum ggml_type ggml_ftype_to_ggml_type(enum ggml_ftype ftype);
668
+
669
+ GGML_API bool ggml_is_transposed(const struct ggml_tensor * tensor);
670
+ GGML_API bool ggml_is_permuted (const struct ggml_tensor * tensor);
671
+ GGML_API bool ggml_is_empty (const struct ggml_tensor * tensor);
672
+ GGML_API bool ggml_is_scalar (const struct ggml_tensor * tensor);
673
+ GGML_API bool ggml_is_vector (const struct ggml_tensor * tensor);
674
+ GGML_API bool ggml_is_matrix (const struct ggml_tensor * tensor);
675
+ GGML_API bool ggml_is_3d (const struct ggml_tensor * tensor);
676
+ GGML_API int ggml_n_dims (const struct ggml_tensor * tensor); // returns 1 for scalars
677
+
678
+ // returns whether the tensor elements can be iterated over with a flattened index (no gaps, no permutation)
679
+ GGML_API bool ggml_is_contiguous (const struct ggml_tensor * tensor);
680
+ GGML_API bool ggml_is_contiguous_0(const struct ggml_tensor * tensor); // same as ggml_is_contiguous()
681
+ GGML_API bool ggml_is_contiguous_1(const struct ggml_tensor * tensor); // contiguous for dims >= 1
682
+ GGML_API bool ggml_is_contiguous_2(const struct ggml_tensor * tensor); // contiguous for dims >= 2
683
+
684
+ // returns whether the tensor elements are allocated as one contiguous block of memory (no gaps, but permutation ok)
685
+ GGML_API bool ggml_is_contiguously_allocated(const struct ggml_tensor * tensor);
686
+
687
+ // true for tensor that is stored in memory as CxWxHxN and has been permuted to WxHxCxN
688
+ GGML_API bool ggml_is_contiguous_channels(const struct ggml_tensor * tensor);
689
+
690
+ GGML_API bool ggml_are_same_shape (const struct ggml_tensor * t0, const struct ggml_tensor * t1);
691
+ GGML_API bool ggml_are_same_stride(const struct ggml_tensor * t0, const struct ggml_tensor * t1);
692
+
693
+ GGML_API bool ggml_can_repeat(const struct ggml_tensor * t0, const struct ggml_tensor * t1);
694
+
695
+ // use this to compute the memory overhead of a tensor
696
+ GGML_API size_t ggml_tensor_overhead(void);
697
+
698
+ GGML_API bool ggml_validate_row_data(enum ggml_type type, const void * data, size_t nbytes);
699
+
700
+ // main
701
+
702
+ GGML_API struct ggml_context * ggml_init (struct ggml_init_params params);
703
+ GGML_API void ggml_reset(struct ggml_context * ctx);
704
+ GGML_API void ggml_free (struct ggml_context * ctx);
705
+
706
+ GGML_API size_t ggml_used_mem(const struct ggml_context * ctx);
707
+
708
+ GGML_API bool ggml_get_no_alloc(struct ggml_context * ctx);
709
+ GGML_API void ggml_set_no_alloc(struct ggml_context * ctx, bool no_alloc);
710
+
711
+ GGML_API void * ggml_get_mem_buffer (const struct ggml_context * ctx);
712
+ GGML_API size_t ggml_get_mem_size (const struct ggml_context * ctx);
713
+ GGML_API size_t ggml_get_max_tensor_size(const struct ggml_context * ctx);
714
+
715
+ GGML_API struct ggml_tensor * ggml_new_tensor(
716
+ struct ggml_context * ctx,
717
+ enum ggml_type type,
718
+ int n_dims,
719
+ const int64_t *ne);
720
+
721
+ GGML_API struct ggml_tensor * ggml_new_tensor_1d(
722
+ struct ggml_context * ctx,
723
+ enum ggml_type type,
724
+ int64_t ne0);
725
+
726
+ GGML_API struct ggml_tensor * ggml_new_tensor_2d(
727
+ struct ggml_context * ctx,
728
+ enum ggml_type type,
729
+ int64_t ne0,
730
+ int64_t ne1);
731
+
732
+ GGML_API struct ggml_tensor * ggml_new_tensor_3d(
733
+ struct ggml_context * ctx,
734
+ enum ggml_type type,
735
+ int64_t ne0,
736
+ int64_t ne1,
737
+ int64_t ne2);
738
+
739
+ GGML_API struct ggml_tensor * ggml_new_tensor_4d(
740
+ struct ggml_context * ctx,
741
+ enum ggml_type type,
742
+ int64_t ne0,
743
+ int64_t ne1,
744
+ int64_t ne2,
745
+ int64_t ne3);
746
+
747
+ GGML_API void * ggml_new_buffer(struct ggml_context * ctx, size_t nbytes);
748
+
749
+ GGML_API struct ggml_tensor * ggml_dup_tensor (struct ggml_context * ctx, const struct ggml_tensor * src);
750
+ GGML_API struct ggml_tensor * ggml_view_tensor(struct ggml_context * ctx, struct ggml_tensor * src);
751
+
752
+ // Context tensor enumeration and lookup
753
+ GGML_API struct ggml_tensor * ggml_get_first_tensor(const struct ggml_context * ctx);
754
+ GGML_API struct ggml_tensor * ggml_get_next_tensor (const struct ggml_context * ctx, struct ggml_tensor * tensor);
755
+ GGML_API struct ggml_tensor * ggml_get_tensor(struct ggml_context * ctx, const char * name);
756
+
757
+ // Converts a flat index into coordinates
758
+ GGML_API void ggml_unravel_index(const struct ggml_tensor * tensor, int64_t i, int64_t * i0, int64_t * i1, int64_t * i2, int64_t * i3);
759
+
760
+ GGML_API enum ggml_unary_op ggml_get_unary_op(const struct ggml_tensor * tensor);
761
+
762
+ GGML_API void * ggml_get_data (const struct ggml_tensor * tensor);
763
+ GGML_API float * ggml_get_data_f32(const struct ggml_tensor * tensor);
764
+
765
+ GGML_API const char * ggml_get_name (const struct ggml_tensor * tensor);
766
+ GGML_API struct ggml_tensor * ggml_set_name ( struct ggml_tensor * tensor, const char * name);
767
+ GGML_ATTRIBUTE_FORMAT(2, 3)
768
+ GGML_API struct ggml_tensor * ggml_format_name( struct ggml_tensor * tensor, const char * fmt, ...);
769
+
770
+ // Tensor flags
771
+ GGML_API void ggml_set_input(struct ggml_tensor * tensor);
772
+ GGML_API void ggml_set_output(struct ggml_tensor * tensor);
773
+ GGML_API void ggml_set_param(struct ggml_tensor * tensor);
774
+ GGML_API void ggml_set_loss(struct ggml_tensor * tensor);
775
+
776
+ //
777
+ // operations on tensors with backpropagation
778
+ //
779
+
780
+ GGML_API struct ggml_tensor * ggml_dup(
781
+ struct ggml_context * ctx,
782
+ struct ggml_tensor * a);
783
+
784
+ // in-place, returns view(a)
785
+ GGML_API struct ggml_tensor * ggml_dup_inplace(
786
+ struct ggml_context * ctx,
787
+ struct ggml_tensor * a);
788
+
789
+ GGML_API struct ggml_tensor * ggml_add(
790
+ struct ggml_context * ctx,
791
+ struct ggml_tensor * a,
792
+ struct ggml_tensor * b);
793
+
794
+ GGML_API struct ggml_tensor * ggml_add_inplace(
795
+ struct ggml_context * ctx,
796
+ struct ggml_tensor * a,
797
+ struct ggml_tensor * b);
798
+
799
+ GGML_API struct ggml_tensor * ggml_add_cast(
800
+ struct ggml_context * ctx,
801
+ struct ggml_tensor * a,
802
+ struct ggml_tensor * b,
803
+ enum ggml_type type);
804
+
805
+ GGML_API struct ggml_tensor * ggml_add1(
806
+ struct ggml_context * ctx,
807
+ struct ggml_tensor * a,
808
+ struct ggml_tensor * b);
809
+
810
+ GGML_API struct ggml_tensor * ggml_add1_inplace(
811
+ struct ggml_context * ctx,
812
+ struct ggml_tensor * a,
813
+ struct ggml_tensor * b);
814
+
815
+ // dst = a
816
+ // view(dst, nb1, nb2, nb3, offset) += b
817
+ // return dst
818
+ GGML_API struct ggml_tensor * ggml_acc(
819
+ struct ggml_context * ctx,
820
+ struct ggml_tensor * a,
821
+ struct ggml_tensor * b,
822
+ size_t nb1,
823
+ size_t nb2,
824
+ size_t nb3,
825
+ size_t offset);
826
+
827
+ GGML_API struct ggml_tensor * ggml_acc_inplace(
828
+ struct ggml_context * ctx,
829
+ struct ggml_tensor * a,
830
+ struct ggml_tensor * b,
831
+ size_t nb1,
832
+ size_t nb2,
833
+ size_t nb3,
834
+ size_t offset);
835
+
836
+ GGML_API struct ggml_tensor * ggml_sub(
837
+ struct ggml_context * ctx,
838
+ struct ggml_tensor * a,
839
+ struct ggml_tensor * b);
840
+
841
+ GGML_API struct ggml_tensor * ggml_sub_inplace(
842
+ struct ggml_context * ctx,
843
+ struct ggml_tensor * a,
844
+ struct ggml_tensor * b);
845
+
846
+ GGML_API struct ggml_tensor * ggml_mul(
847
+ struct ggml_context * ctx,
848
+ struct ggml_tensor * a,
849
+ struct ggml_tensor * b);
850
+
851
+ GGML_API struct ggml_tensor * ggml_mul_inplace(
852
+ struct ggml_context * ctx,
853
+ struct ggml_tensor * a,
854
+ struct ggml_tensor * b);
855
+
856
+ GGML_API struct ggml_tensor * ggml_div(
857
+ struct ggml_context * ctx,
858
+ struct ggml_tensor * a,
859
+ struct ggml_tensor * b);
860
+
861
+ GGML_API struct ggml_tensor * ggml_div_inplace(
862
+ struct ggml_context * ctx,
863
+ struct ggml_tensor * a,
864
+ struct ggml_tensor * b);
865
+
866
+ GGML_API struct ggml_tensor * ggml_sqr(
867
+ struct ggml_context * ctx,
868
+ struct ggml_tensor * a);
869
+
870
+ GGML_API struct ggml_tensor * ggml_sqr_inplace(
871
+ struct ggml_context * ctx,
872
+ struct ggml_tensor * a);
873
+
874
+ GGML_API struct ggml_tensor * ggml_sqrt(
875
+ struct ggml_context * ctx,
876
+ struct ggml_tensor * a);
877
+
878
+ GGML_API struct ggml_tensor * ggml_sqrt_inplace(
879
+ struct ggml_context * ctx,
880
+ struct ggml_tensor * a);
881
+
882
+ GGML_API struct ggml_tensor * ggml_log(
883
+ struct ggml_context * ctx,
884
+ struct ggml_tensor * a);
885
+
886
+ GGML_API struct ggml_tensor * ggml_log_inplace(
887
+ struct ggml_context * ctx,
888
+ struct ggml_tensor * a);
889
+
890
+ GGML_API struct ggml_tensor * ggml_sin(
891
+ struct ggml_context * ctx,
892
+ struct ggml_tensor * a);
893
+
894
+ GGML_API struct ggml_tensor * ggml_sin_inplace(
895
+ struct ggml_context * ctx,
896
+ struct ggml_tensor * a);
897
+
898
+ GGML_API struct ggml_tensor * ggml_cos(
899
+ struct ggml_context * ctx,
900
+ struct ggml_tensor * a);
901
+
902
+ GGML_API struct ggml_tensor * ggml_cos_inplace(
903
+ struct ggml_context * ctx,
904
+ struct ggml_tensor * a);
905
+
906
+ // return scalar
907
+ GGML_API struct ggml_tensor * ggml_sum(
908
+ struct ggml_context * ctx,
909
+ struct ggml_tensor * a);
910
+
911
+ // sums along rows, with input shape [a,b,c,d] return shape [1,b,c,d]
912
+ GGML_API struct ggml_tensor * ggml_sum_rows(
913
+ struct ggml_context * ctx,
914
+ struct ggml_tensor * a);
915
+
916
+ // mean along rows
917
+ GGML_API struct ggml_tensor * ggml_mean(
918
+ struct ggml_context * ctx,
919
+ struct ggml_tensor * a);
920
+
921
+ // argmax along rows
922
+ GGML_API struct ggml_tensor * ggml_argmax(
923
+ struct ggml_context * ctx,
924
+ struct ggml_tensor * a);
925
+
926
+ // count number of equal elements in a and b
927
+ GGML_API struct ggml_tensor * ggml_count_equal(
928
+ struct ggml_context * ctx,
929
+ struct ggml_tensor * a,
930
+ struct ggml_tensor * b);
931
+
932
+ // if a is the same shape as b, and a is not parameter, return a
933
+ // otherwise, return a new tensor: repeat(a) to fit in b
934
+ GGML_API struct ggml_tensor * ggml_repeat(
935
+ struct ggml_context * ctx,
936
+ struct ggml_tensor * a,
937
+ struct ggml_tensor * b);
938
+
939
+ // repeat a to the specified shape
940
+ GGML_API struct ggml_tensor * ggml_repeat_4d(
941
+ struct ggml_context * ctx,
942
+ struct ggml_tensor * a,
943
+ int64_t ne0,
944
+ int64_t ne1,
945
+ int64_t ne2,
946
+ int64_t ne3);
947
+
948
+ // sums repetitions in a into shape of b
949
+ GGML_API struct ggml_tensor * ggml_repeat_back(
950
+ struct ggml_context * ctx,
951
+ struct ggml_tensor * a,
952
+ struct ggml_tensor * b); // sum up values that are adjacent in dims > 0 instead of repeated with same stride
953
+
954
+ // concat a and b along dim
955
+ // used in stable-diffusion
956
+ GGML_API struct ggml_tensor * ggml_concat(
957
+ struct ggml_context * ctx,
958
+ struct ggml_tensor * a,
959
+ struct ggml_tensor * b,
960
+ int dim);
961
+
962
+ GGML_API struct ggml_tensor * ggml_abs(
963
+ struct ggml_context * ctx,
964
+ struct ggml_tensor * a);
965
+
966
+ GGML_API struct ggml_tensor * ggml_abs_inplace(
967
+ struct ggml_context * ctx,
968
+ struct ggml_tensor * a);
969
+
970
+ GGML_API struct ggml_tensor * ggml_sgn(
971
+ struct ggml_context * ctx,
972
+ struct ggml_tensor * a);
973
+
974
+ GGML_API struct ggml_tensor * ggml_sgn_inplace(
975
+ struct ggml_context * ctx,
976
+ struct ggml_tensor * a);
977
+
978
+ GGML_API struct ggml_tensor * ggml_neg(
979
+ struct ggml_context * ctx,
980
+ struct ggml_tensor * a);
981
+
982
+ GGML_API struct ggml_tensor * ggml_neg_inplace(
983
+ struct ggml_context * ctx,
984
+ struct ggml_tensor * a);
985
+
986
+ GGML_API struct ggml_tensor * ggml_step(
987
+ struct ggml_context * ctx,
988
+ struct ggml_tensor * a);
989
+
990
+ GGML_API struct ggml_tensor * ggml_step_inplace(
991
+ struct ggml_context * ctx,
992
+ struct ggml_tensor * a);
993
+
994
+ GGML_API struct ggml_tensor * ggml_tanh(
995
+ struct ggml_context * ctx,
996
+ struct ggml_tensor * a);
997
+
998
+ GGML_API struct ggml_tensor * ggml_tanh_inplace(
999
+ struct ggml_context * ctx,
1000
+ struct ggml_tensor * a);
1001
+
1002
+ GGML_API struct ggml_tensor * ggml_elu(
1003
+ struct ggml_context * ctx,
1004
+ struct ggml_tensor * a);
1005
+
1006
+ GGML_API struct ggml_tensor * ggml_elu_inplace(
1007
+ struct ggml_context * ctx,
1008
+ struct ggml_tensor * a);
1009
+
1010
+ GGML_API struct ggml_tensor * ggml_relu(
1011
+ struct ggml_context * ctx,
1012
+ struct ggml_tensor * a);
1013
+
1014
+ GGML_API struct ggml_tensor * ggml_leaky_relu(
1015
+ struct ggml_context * ctx,
1016
+ struct ggml_tensor * a, float negative_slope, bool inplace);
1017
+
1018
+ GGML_API struct ggml_tensor * ggml_relu_inplace(
1019
+ struct ggml_context * ctx,
1020
+ struct ggml_tensor * a);
1021
+
1022
+ GGML_API struct ggml_tensor * ggml_sigmoid(
1023
+ struct ggml_context * ctx,
1024
+ struct ggml_tensor * a);
1025
+
1026
+ GGML_API struct ggml_tensor * ggml_sigmoid_inplace(
1027
+ struct ggml_context * ctx,
1028
+ struct ggml_tensor * a);
1029
+
1030
+ GGML_API struct ggml_tensor * ggml_gelu(
1031
+ struct ggml_context * ctx,
1032
+ struct ggml_tensor * a);
1033
+
1034
+ GGML_API struct ggml_tensor * ggml_gelu_inplace(
1035
+ struct ggml_context * ctx,
1036
+ struct ggml_tensor * a);
1037
+
1038
+ // GELU using erf (error function) when possible
1039
+ // some backends may fallback to approximation based on Abramowitz and Stegun formula
1040
+ GGML_API struct ggml_tensor * ggml_gelu_erf(
1041
+ struct ggml_context * ctx,
1042
+ struct ggml_tensor * a);
1043
+
1044
+ GGML_API struct ggml_tensor * ggml_gelu_erf_inplace(
1045
+ struct ggml_context * ctx,
1046
+ struct ggml_tensor * a);
1047
+
1048
+ GGML_API struct ggml_tensor * ggml_gelu_quick(
1049
+ struct ggml_context * ctx,
1050
+ struct ggml_tensor * a);
1051
+
1052
+ GGML_API struct ggml_tensor * ggml_gelu_quick_inplace(
1053
+ struct ggml_context * ctx,
1054
+ struct ggml_tensor * a);
1055
+
1056
+ GGML_API struct ggml_tensor * ggml_silu(
1057
+ struct ggml_context * ctx,
1058
+ struct ggml_tensor * a);
1059
+
1060
+ GGML_API struct ggml_tensor * ggml_silu_inplace(
1061
+ struct ggml_context * ctx,
1062
+ struct ggml_tensor * a);
1063
+
1064
+ // a - x
1065
+ // b - dy
1066
+ GGML_API struct ggml_tensor * ggml_silu_back(
1067
+ struct ggml_context * ctx,
1068
+ struct ggml_tensor * a,
1069
+ struct ggml_tensor * b);
1070
+
1071
+ // hardswish(x) = x * relu6(x + 3) / 6
1072
+ GGML_API struct ggml_tensor * ggml_hardswish(
1073
+ struct ggml_context * ctx,
1074
+ struct ggml_tensor * a);
1075
+
1076
+ // hardsigmoid(x) = relu6(x + 3) / 6
1077
+ GGML_API struct ggml_tensor * ggml_hardsigmoid(
1078
+ struct ggml_context * ctx,
1079
+ struct ggml_tensor * a);
1080
+
1081
+ GGML_API struct ggml_tensor * ggml_exp(
1082
+ struct ggml_context * ctx,
1083
+ struct ggml_tensor * a);
1084
+
1085
+ GGML_API struct ggml_tensor * ggml_exp_inplace(
1086
+ struct ggml_context * ctx,
1087
+ struct ggml_tensor * a);
1088
+
1089
+ // normalize along rows
1090
+ GGML_API struct ggml_tensor * ggml_norm(
1091
+ struct ggml_context * ctx,
1092
+ struct ggml_tensor * a,
1093
+ float eps);
1094
+
1095
+ GGML_API struct ggml_tensor * ggml_norm_inplace(
1096
+ struct ggml_context * ctx,
1097
+ struct ggml_tensor * a,
1098
+ float eps);
1099
+
1100
+ GGML_API struct ggml_tensor * ggml_rms_norm(
1101
+ struct ggml_context * ctx,
1102
+ struct ggml_tensor * a,
1103
+ float eps);
1104
+
1105
+ GGML_API struct ggml_tensor * ggml_rms_norm_inplace(
1106
+ struct ggml_context * ctx,
1107
+ struct ggml_tensor * a,
1108
+ float eps);
1109
+
1110
+ // group normalize along ne0*ne1*n_groups
1111
+ // used in stable-diffusion
1112
+ GGML_API struct ggml_tensor * ggml_group_norm(
1113
+ struct ggml_context * ctx,
1114
+ struct ggml_tensor * a,
1115
+ int n_groups,
1116
+ float eps);
1117
+
1118
+ GGML_API struct ggml_tensor * ggml_group_norm_inplace(
1119
+ struct ggml_context * ctx,
1120
+ struct ggml_tensor * a,
1121
+ int n_groups,
1122
+ float eps);
1123
+
1124
+ // l2 normalize along rows
1125
+ // used in rwkv v7
1126
+ GGML_API struct ggml_tensor * ggml_l2_norm(
1127
+ struct ggml_context * ctx,
1128
+ struct ggml_tensor * a,
1129
+ float eps);
1130
+
1131
+ GGML_API struct ggml_tensor * ggml_l2_norm_inplace(
1132
+ struct ggml_context * ctx,
1133
+ struct ggml_tensor * a,
1134
+ float eps);
1135
+
1136
+ // a - x
1137
+ // b - dy
1138
+ GGML_API struct ggml_tensor * ggml_rms_norm_back(
1139
+ struct ggml_context * ctx,
1140
+ struct ggml_tensor * a,
1141
+ struct ggml_tensor * b,
1142
+ float eps);
1143
+
1144
+ // A: k columns, n rows => [ne03, ne02, n, k]
1145
+ // B: k columns, m rows (i.e. we transpose it internally) => [ne03 * x, ne02 * y, m, k]
1146
+ // result is n columns, m rows => [ne03 * x, ne02 * y, m, n]
1147
+ GGML_API struct ggml_tensor * ggml_mul_mat(
1148
+ struct ggml_context * ctx,
1149
+ struct ggml_tensor * a,
1150
+ struct ggml_tensor * b);
1151
+
1152
+ // change the precision of a matrix multiplication
1153
+ // set to GGML_PREC_F32 for higher precision (useful for phi-2)
1154
+ GGML_API void ggml_mul_mat_set_prec(
1155
+ struct ggml_tensor * a,
1156
+ enum ggml_prec prec);
1157
+
1158
+ // indirect matrix multiplication
1159
+ GGML_API struct ggml_tensor * ggml_mul_mat_id(
1160
+ struct ggml_context * ctx,
1161
+ struct ggml_tensor * as,
1162
+ struct ggml_tensor * b,
1163
+ struct ggml_tensor * ids);
1164
+
1165
+ // A: m columns, n rows,
1166
+ // B: p columns, n rows,
1167
+ // result is m columns, p rows
1168
+ GGML_API struct ggml_tensor * ggml_out_prod(
1169
+ struct ggml_context * ctx,
1170
+ struct ggml_tensor * a,
1171
+ struct ggml_tensor * b);
1172
+
1173
+ //
1174
+ // operations on tensors without backpropagation
1175
+ //
1176
+
1177
+ GGML_API struct ggml_tensor * ggml_scale(
1178
+ struct ggml_context * ctx,
1179
+ struct ggml_tensor * a,
1180
+ float s);
1181
+
1182
+ // in-place, returns view(a)
1183
+ GGML_API struct ggml_tensor * ggml_scale_inplace(
1184
+ struct ggml_context * ctx,
1185
+ struct ggml_tensor * a,
1186
+ float s);
1187
+
1188
+ // b -> view(a,offset,nb1,nb2,3), return modified a
1189
+ GGML_API struct ggml_tensor * ggml_set(
1190
+ struct ggml_context * ctx,
1191
+ struct ggml_tensor * a,
1192
+ struct ggml_tensor * b,
1193
+ size_t nb1,
1194
+ size_t nb2,
1195
+ size_t nb3,
1196
+ size_t offset); // in bytes
1197
+
1198
+ // b -> view(a,offset,nb1,nb2,3), return view(a)
1199
+ GGML_API struct ggml_tensor * ggml_set_inplace(
1200
+ struct ggml_context * ctx,
1201
+ struct ggml_tensor * a,
1202
+ struct ggml_tensor * b,
1203
+ size_t nb1,
1204
+ size_t nb2,
1205
+ size_t nb3,
1206
+ size_t offset); // in bytes
1207
+
1208
+ GGML_API struct ggml_tensor * ggml_set_1d(
1209
+ struct ggml_context * ctx,
1210
+ struct ggml_tensor * a,
1211
+ struct ggml_tensor * b,
1212
+ size_t offset); // in bytes
1213
+
1214
+ GGML_API struct ggml_tensor * ggml_set_1d_inplace(
1215
+ struct ggml_context * ctx,
1216
+ struct ggml_tensor * a,
1217
+ struct ggml_tensor * b,
1218
+ size_t offset); // in bytes
1219
+
1220
+ // b -> view(a,offset,nb1,nb2,3), return modified a
1221
+ GGML_API struct ggml_tensor * ggml_set_2d(
1222
+ struct ggml_context * ctx,
1223
+ struct ggml_tensor * a,
1224
+ struct ggml_tensor * b,
1225
+ size_t nb1,
1226
+ size_t offset); // in bytes
1227
+
1228
+ // b -> view(a,offset,nb1,nb2,3), return view(a)
1229
+ GGML_API struct ggml_tensor * ggml_set_2d_inplace(
1230
+ struct ggml_context * ctx,
1231
+ struct ggml_tensor * a,
1232
+ struct ggml_tensor * b,
1233
+ size_t nb1,
1234
+ size_t offset); // in bytes
1235
+
1236
+ // a -> b, return view(b)
1237
+ GGML_API struct ggml_tensor * ggml_cpy(
1238
+ struct ggml_context * ctx,
1239
+ struct ggml_tensor * a,
1240
+ struct ggml_tensor * b);
1241
+
1242
+ GGML_API struct ggml_tensor * ggml_cast(
1243
+ struct ggml_context * ctx,
1244
+ struct ggml_tensor * a,
1245
+ enum ggml_type type);
1246
+
1247
+ // make contiguous
1248
+ GGML_API struct ggml_tensor * ggml_cont(
1249
+ struct ggml_context * ctx,
1250
+ struct ggml_tensor * a);
1251
+
1252
+ // make contiguous, with new shape
1253
+ GGML_API struct ggml_tensor * ggml_cont_1d(
1254
+ struct ggml_context * ctx,
1255
+ struct ggml_tensor * a,
1256
+ int64_t ne0);
1257
+
1258
+ GGML_API struct ggml_tensor * ggml_cont_2d(
1259
+ struct ggml_context * ctx,
1260
+ struct ggml_tensor * a,
1261
+ int64_t ne0,
1262
+ int64_t ne1);
1263
+
1264
+ GGML_API struct ggml_tensor * ggml_cont_3d(
1265
+ struct ggml_context * ctx,
1266
+ struct ggml_tensor * a,
1267
+ int64_t ne0,
1268
+ int64_t ne1,
1269
+ int64_t ne2);
1270
+
1271
+ GGML_API struct ggml_tensor * ggml_cont_4d(
1272
+ struct ggml_context * ctx,
1273
+ struct ggml_tensor * a,
1274
+ int64_t ne0,
1275
+ int64_t ne1,
1276
+ int64_t ne2,
1277
+ int64_t ne3);
1278
+
1279
+ // return view(a), b specifies the new shape
1280
+ // TODO: when we start computing gradient, make a copy instead of view
1281
+ GGML_API struct ggml_tensor * ggml_reshape(
1282
+ struct ggml_context * ctx,
1283
+ struct ggml_tensor * a,
1284
+ struct ggml_tensor * b);
1285
+
1286
+ // return view(a)
1287
+ // TODO: when we start computing gradient, make a copy instead of view
1288
+ GGML_API struct ggml_tensor * ggml_reshape_1d(
1289
+ struct ggml_context * ctx,
1290
+ struct ggml_tensor * a,
1291
+ int64_t ne0);
1292
+
1293
+ GGML_API struct ggml_tensor * ggml_reshape_2d(
1294
+ struct ggml_context * ctx,
1295
+ struct ggml_tensor * a,
1296
+ int64_t ne0,
1297
+ int64_t ne1);
1298
+
1299
+ // return view(a)
1300
+ // TODO: when we start computing gradient, make a copy instead of view
1301
+ GGML_API struct ggml_tensor * ggml_reshape_3d(
1302
+ struct ggml_context * ctx,
1303
+ struct ggml_tensor * a,
1304
+ int64_t ne0,
1305
+ int64_t ne1,
1306
+ int64_t ne2);
1307
+
1308
+ GGML_API struct ggml_tensor * ggml_reshape_4d(
1309
+ struct ggml_context * ctx,
1310
+ struct ggml_tensor * a,
1311
+ int64_t ne0,
1312
+ int64_t ne1,
1313
+ int64_t ne2,
1314
+ int64_t ne3);
1315
+
1316
+ // offset in bytes
1317
+ GGML_API struct ggml_tensor * ggml_view_1d(
1318
+ struct ggml_context * ctx,
1319
+ struct ggml_tensor * a,
1320
+ int64_t ne0,
1321
+ size_t offset);
1322
+
1323
+ GGML_API struct ggml_tensor * ggml_view_2d(
1324
+ struct ggml_context * ctx,
1325
+ struct ggml_tensor * a,
1326
+ int64_t ne0,
1327
+ int64_t ne1,
1328
+ size_t nb1, // row stride in bytes
1329
+ size_t offset);
1330
+
1331
+ GGML_API struct ggml_tensor * ggml_view_3d(
1332
+ struct ggml_context * ctx,
1333
+ struct ggml_tensor * a,
1334
+ int64_t ne0,
1335
+ int64_t ne1,
1336
+ int64_t ne2,
1337
+ size_t nb1, // row stride in bytes
1338
+ size_t nb2, // slice stride in bytes
1339
+ size_t offset);
1340
+
1341
+ GGML_API struct ggml_tensor * ggml_view_4d(
1342
+ struct ggml_context * ctx,
1343
+ struct ggml_tensor * a,
1344
+ int64_t ne0,
1345
+ int64_t ne1,
1346
+ int64_t ne2,
1347
+ int64_t ne3,
1348
+ size_t nb1, // row stride in bytes
1349
+ size_t nb2, // slice stride in bytes
1350
+ size_t nb3,
1351
+ size_t offset);
1352
+
1353
+ GGML_API struct ggml_tensor * ggml_permute(
1354
+ struct ggml_context * ctx,
1355
+ struct ggml_tensor * a,
1356
+ int axis0,
1357
+ int axis1,
1358
+ int axis2,
1359
+ int axis3);
1360
+
1361
+ // alias for ggml_permute(ctx, a, 1, 0, 2, 3)
1362
+ GGML_API struct ggml_tensor * ggml_transpose(
1363
+ struct ggml_context * ctx,
1364
+ struct ggml_tensor * a);
1365
+
1366
+ // supports 3D: a->ne[2] == b->ne[1]
1367
+ GGML_API struct ggml_tensor * ggml_get_rows(
1368
+ struct ggml_context * ctx,
1369
+ struct ggml_tensor * a, // data
1370
+ struct ggml_tensor * b); // row indices
1371
+
1372
+ GGML_API struct ggml_tensor * ggml_get_rows_back(
1373
+ struct ggml_context * ctx,
1374
+ struct ggml_tensor * a, // gradients of ggml_get_rows result
1375
+ struct ggml_tensor * b, // row indices
1376
+ struct ggml_tensor * c); // data for ggml_get_rows, only used for its shape
1377
+
1378
+ GGML_API struct ggml_tensor * ggml_diag(
1379
+ struct ggml_context * ctx,
1380
+ struct ggml_tensor * a);
1381
+
1382
+ // set elements above the diagonal to -INF
1383
+ GGML_API struct ggml_tensor * ggml_diag_mask_inf(
1384
+ struct ggml_context * ctx,
1385
+ struct ggml_tensor * a,
1386
+ int n_past);
1387
+
1388
+ // in-place, returns view(a)
1389
+ GGML_API struct ggml_tensor * ggml_diag_mask_inf_inplace(
1390
+ struct ggml_context * ctx,
1391
+ struct ggml_tensor * a,
1392
+ int n_past);
1393
+
1394
+ // set elements above the diagonal to 0
1395
+ GGML_API struct ggml_tensor * ggml_diag_mask_zero(
1396
+ struct ggml_context * ctx,
1397
+ struct ggml_tensor * a,
1398
+ int n_past);
1399
+
1400
+ // in-place, returns view(a)
1401
+ GGML_API struct ggml_tensor * ggml_diag_mask_zero_inplace(
1402
+ struct ggml_context * ctx,
1403
+ struct ggml_tensor * a,
1404
+ int n_past);
1405
+
1406
+ GGML_API struct ggml_tensor * ggml_soft_max(
1407
+ struct ggml_context * ctx,
1408
+ struct ggml_tensor * a);
1409
+
1410
+ // in-place, returns view(a)
1411
+ GGML_API struct ggml_tensor * ggml_soft_max_inplace(
1412
+ struct ggml_context * ctx,
1413
+ struct ggml_tensor * a);
1414
+
1415
+ // fused soft_max(a*scale + mask*(ALiBi slope))
1416
+ // mask is optional
1417
+ // max_bias = 0.0f for no ALiBi
1418
+ GGML_API struct ggml_tensor * ggml_soft_max_ext(
1419
+ struct ggml_context * ctx,
1420
+ struct ggml_tensor * a,
1421
+ struct ggml_tensor * mask,
1422
+ float scale,
1423
+ float max_bias);
1424
+
1425
+ GGML_API struct ggml_tensor * ggml_soft_max_ext_back(
1426
+ struct ggml_context * ctx,
1427
+ struct ggml_tensor * a,
1428
+ struct ggml_tensor * b,
1429
+ float scale,
1430
+ float max_bias);
1431
+
1432
+ // in-place, returns view(a)
1433
+ GGML_API struct ggml_tensor * ggml_soft_max_ext_back_inplace(
1434
+ struct ggml_context * ctx,
1435
+ struct ggml_tensor * a,
1436
+ struct ggml_tensor * b,
1437
+ float scale,
1438
+ float max_bias);
1439
+
1440
+ // rotary position embedding
1441
+ // if (mode & 1) - skip n_past elements (NOT SUPPORTED)
1442
+ // if (mode & GGML_ROPE_TYPE_NEOX) - GPT-NeoX style
1443
+ //
1444
+ // b is an int32 vector with size a->ne[2], it contains the positions
1445
+ GGML_API struct ggml_tensor * ggml_rope(
1446
+ struct ggml_context * ctx,
1447
+ struct ggml_tensor * a,
1448
+ struct ggml_tensor * b,
1449
+ int n_dims,
1450
+ int mode);
1451
+
1452
+ // in-place, returns view(a)
1453
+ GGML_API struct ggml_tensor * ggml_rope_inplace(
1454
+ struct ggml_context * ctx,
1455
+ struct ggml_tensor * a,
1456
+ struct ggml_tensor * b,
1457
+ int n_dims,
1458
+ int mode);
1459
+
1460
+ // custom RoPE
1461
+ // c is freq factors (e.g. phi3-128k), (optional)
1462
+ GGML_API struct ggml_tensor * ggml_rope_ext(
1463
+ struct ggml_context * ctx,
1464
+ struct ggml_tensor * a,
1465
+ struct ggml_tensor * b,
1466
+ struct ggml_tensor * c,
1467
+ int n_dims,
1468
+ int mode,
1469
+ int n_ctx_orig,
1470
+ float freq_base,
1471
+ float freq_scale,
1472
+ float ext_factor,
1473
+ float attn_factor,
1474
+ float beta_fast,
1475
+ float beta_slow);
1476
+
1477
+ GGML_API struct ggml_tensor * ggml_rope_multi(
1478
+ struct ggml_context * ctx,
1479
+ struct ggml_tensor * a,
1480
+ struct ggml_tensor * b,
1481
+ struct ggml_tensor * c,
1482
+ int n_dims,
1483
+ int sections[4],
1484
+ int mode,
1485
+ int n_ctx_orig,
1486
+ float freq_base,
1487
+ float freq_scale,
1488
+ float ext_factor,
1489
+ float attn_factor,
1490
+ float beta_fast,
1491
+ float beta_slow);
1492
+
1493
+ // in-place, returns view(a)
1494
+ GGML_API struct ggml_tensor * ggml_rope_ext_inplace(
1495
+ struct ggml_context * ctx,
1496
+ struct ggml_tensor * a,
1497
+ struct ggml_tensor * b,
1498
+ struct ggml_tensor * c,
1499
+ int n_dims,
1500
+ int mode,
1501
+ int n_ctx_orig,
1502
+ float freq_base,
1503
+ float freq_scale,
1504
+ float ext_factor,
1505
+ float attn_factor,
1506
+ float beta_fast,
1507
+ float beta_slow);
1508
+
1509
+ GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_rope_custom(
1510
+ struct ggml_context * ctx,
1511
+ struct ggml_tensor * a,
1512
+ struct ggml_tensor * b,
1513
+ int n_dims,
1514
+ int mode,
1515
+ int n_ctx_orig,
1516
+ float freq_base,
1517
+ float freq_scale,
1518
+ float ext_factor,
1519
+ float attn_factor,
1520
+ float beta_fast,
1521
+ float beta_slow),
1522
+ "use ggml_rope_ext instead");
1523
+
1524
+ GGML_DEPRECATED(GGML_API struct ggml_tensor * ggml_rope_custom_inplace(
1525
+ struct ggml_context * ctx,
1526
+ struct ggml_tensor * a,
1527
+ struct ggml_tensor * b,
1528
+ int n_dims,
1529
+ int mode,
1530
+ int n_ctx_orig,
1531
+ float freq_base,
1532
+ float freq_scale,
1533
+ float ext_factor,
1534
+ float attn_factor,
1535
+ float beta_fast,
1536
+ float beta_slow),
1537
+ "use ggml_rope_ext_inplace instead");
1538
+
1539
+ // compute correction dims for YaRN RoPE scaling
1540
+ GGML_API void ggml_rope_yarn_corr_dims(
1541
+ int n_dims, int n_ctx_orig, float freq_base, float beta_fast, float beta_slow, float dims[2]);
1542
+
1543
+ // rotary position embedding backward, i.e compute dx from dy
1544
+ // a - dy
1545
+ GGML_API struct ggml_tensor * ggml_rope_ext_back(
1546
+ struct ggml_context * ctx,
1547
+ struct ggml_tensor * a, // gradients of ggml_rope result
1548
+ struct ggml_tensor * b, // positions
1549
+ struct ggml_tensor * c, // freq factors
1550
+ int n_dims,
1551
+ int mode,
1552
+ int n_ctx_orig,
1553
+ float freq_base,
1554
+ float freq_scale,
1555
+ float ext_factor,
1556
+ float attn_factor,
1557
+ float beta_fast,
1558
+ float beta_slow);
1559
+
1560
+ GGML_API struct ggml_tensor * ggml_rope_multi_back(
1561
+ struct ggml_context * ctx,
1562
+ struct ggml_tensor * a,
1563
+ struct ggml_tensor * b,
1564
+ struct ggml_tensor * c,
1565
+ int n_dims,
1566
+ int sections[4],
1567
+ int mode,
1568
+ int n_ctx_orig,
1569
+ float freq_base,
1570
+ float freq_scale,
1571
+ float ext_factor,
1572
+ float attn_factor,
1573
+ float beta_fast,
1574
+ float beta_slow);
1575
+
1576
+
1577
+ // clamp
1578
+ // in-place, returns view(a)
1579
+ GGML_API struct ggml_tensor * ggml_clamp(
1580
+ struct ggml_context * ctx,
1581
+ struct ggml_tensor * a,
1582
+ float min,
1583
+ float max);
1584
+
1585
+ // im2col
1586
+ // converts data into a format that effectively results in a convolution when combined with matrix multiplication
1587
+ GGML_API struct ggml_tensor * ggml_im2col(
1588
+ struct ggml_context * ctx,
1589
+ struct ggml_tensor * a, // convolution kernel
1590
+ struct ggml_tensor * b, // data
1591
+ int s0, // stride dimension 0
1592
+ int s1, // stride dimension 1
1593
+ int p0, // padding dimension 0
1594
+ int p1, // padding dimension 1
1595
+ int d0, // dilation dimension 0
1596
+ int d1, // dilation dimension 1
1597
+ bool is_2D,
1598
+ enum ggml_type dst_type);
1599
+
1600
+ GGML_API struct ggml_tensor * ggml_im2col_back(
1601
+ struct ggml_context * ctx,
1602
+ struct ggml_tensor * a, // convolution kernel
1603
+ struct ggml_tensor * b, // gradient of im2col output
1604
+ int64_t * ne, // shape of im2col input
1605
+ int s0, // stride dimension 0
1606
+ int s1, // stride dimension 1
1607
+ int p0, // padding dimension 0
1608
+ int p1, // padding dimension 1
1609
+ int d0, // dilation dimension 0
1610
+ int d1, // dilation dimension 1
1611
+ bool is_2D);
1612
+
1613
+ GGML_API struct ggml_tensor * ggml_conv_1d(
1614
+ struct ggml_context * ctx,
1615
+ struct ggml_tensor * a, // convolution kernel
1616
+ struct ggml_tensor * b, // data
1617
+ int s0, // stride
1618
+ int p0, // padding
1619
+ int d0); // dilation
1620
+
1621
+ // conv_1d with padding = half
1622
+ // alias for ggml_conv_1d(a, b, s, a->ne[0]/2, d)
1623
+ GGML_API struct ggml_tensor* ggml_conv_1d_ph(
1624
+ struct ggml_context * ctx,
1625
+ struct ggml_tensor * a, // convolution kernel
1626
+ struct ggml_tensor * b, // data
1627
+ int s, // stride
1628
+ int d); // dilation
1629
+
1630
+ // depthwise
1631
+ // TODO: this is very likely wrong for some cases! - needs more testing
1632
+ GGML_API struct ggml_tensor * ggml_conv_1d_dw(
1633
+ struct ggml_context * ctx,
1634
+ struct ggml_tensor * a, // convolution kernel
1635
+ struct ggml_tensor * b, // data
1636
+ int s0, // stride
1637
+ int p0, // padding
1638
+ int d0); // dilation
1639
+
1640
+ GGML_API struct ggml_tensor * ggml_conv_1d_dw_ph(
1641
+ struct ggml_context * ctx,
1642
+ struct ggml_tensor * a, // convolution kernel
1643
+ struct ggml_tensor * b, // data
1644
+ int s0, // stride
1645
+ int d0); // dilation
1646
+
1647
+ GGML_API struct ggml_tensor * ggml_conv_transpose_1d(
1648
+ struct ggml_context * ctx,
1649
+ struct ggml_tensor * a, // convolution kernel
1650
+ struct ggml_tensor * b, // data
1651
+ int s0, // stride
1652
+ int p0, // padding
1653
+ int d0); // dilation
1654
+
1655
+ GGML_API struct ggml_tensor * ggml_conv_2d(
1656
+ struct ggml_context * ctx,
1657
+ struct ggml_tensor * a, // convolution kernel
1658
+ struct ggml_tensor * b, // data
1659
+ int s0, // stride dimension 0
1660
+ int s1, // stride dimension 1
1661
+ int p0, // padding dimension 0
1662
+ int p1, // padding dimension 1
1663
+ int d0, // dilation dimension 0
1664
+ int d1); // dilation dimension 1
1665
+
1666
+ // kernel size is a->ne[0] x a->ne[1]
1667
+ // stride is equal to kernel size
1668
+ // padding is zero
1669
+ // example:
1670
+ // a: 16 16 3 768
1671
+ // b: 1024 1024 3 1
1672
+ // res: 64 64 768 1
1673
+ // used in sam
1674
+ GGML_API struct ggml_tensor * ggml_conv_2d_sk_p0(
1675
+ struct ggml_context * ctx,
1676
+ struct ggml_tensor * a,
1677
+ struct ggml_tensor * b);
1678
+
1679
+ // kernel size is a->ne[0] x a->ne[1]
1680
+ // stride is 1
1681
+ // padding is half
1682
+ // example:
1683
+ // a: 3 3 256 256
1684
+ // b: 64 64 256 1
1685
+ // res: 64 64 256 1
1686
+ // used in sam
1687
+ GGML_API struct ggml_tensor * ggml_conv_2d_s1_ph(
1688
+ struct ggml_context * ctx,
1689
+ struct ggml_tensor * a,
1690
+ struct ggml_tensor * b);
1691
+
1692
+ // depthwise (via im2col and mul_mat)
1693
+ GGML_API struct ggml_tensor * ggml_conv_2d_dw(
1694
+ struct ggml_context * ctx,
1695
+ struct ggml_tensor * a, // convolution kernel
1696
+ struct ggml_tensor * b, // data
1697
+ int s0, // stride dimension 0
1698
+ int s1, // stride dimension 1
1699
+ int p0, // padding dimension 0
1700
+ int p1, // padding dimension 1
1701
+ int d0, // dilation dimension 0
1702
+ int d1); // dilation dimension 1
1703
+
1704
+ // Depthwise 2D convolution
1705
+ // may be faster than ggml_conv_2d_dw, but not available in all backends
1706
+ // a: KW KH 1 C convolution kernel
1707
+ // b: W H C N input data
1708
+ // res: W_out H_out C N
1709
+ GGML_API struct ggml_tensor * ggml_conv_2d_dw_direct(
1710
+ struct ggml_context * ctx,
1711
+ struct ggml_tensor * a,
1712
+ struct ggml_tensor * b,
1713
+ int stride0,
1714
+ int stride1,
1715
+ int pad0,
1716
+ int pad1,
1717
+ int dilation0,
1718
+ int dilation1);
1719
+
1720
+ GGML_API struct ggml_tensor * ggml_conv_transpose_2d_p0(
1721
+ struct ggml_context * ctx,
1722
+ struct ggml_tensor * a,
1723
+ struct ggml_tensor * b,
1724
+ int stride);
1725
+
1726
+ enum ggml_op_pool {
1727
+ GGML_OP_POOL_MAX,
1728
+ GGML_OP_POOL_AVG,
1729
+ GGML_OP_POOL_COUNT,
1730
+ };
1731
+
1732
+ GGML_API struct ggml_tensor * ggml_pool_1d(
1733
+ struct ggml_context * ctx,
1734
+ struct ggml_tensor * a,
1735
+ enum ggml_op_pool op,
1736
+ int k0, // kernel size
1737
+ int s0, // stride
1738
+ int p0); // padding
1739
+
1740
+ // the result will have 2*p0 padding for the first dimension
1741
+ // and 2*p1 padding for the second dimension
1742
+ GGML_API struct ggml_tensor * ggml_pool_2d(
1743
+ struct ggml_context * ctx,
1744
+ struct ggml_tensor * a,
1745
+ enum ggml_op_pool op,
1746
+ int k0,
1747
+ int k1,
1748
+ int s0,
1749
+ int s1,
1750
+ float p0,
1751
+ float p1);
1752
+
1753
+ GGML_API struct ggml_tensor * ggml_pool_2d_back(
1754
+ struct ggml_context * ctx,
1755
+ struct ggml_tensor * a,
1756
+ struct ggml_tensor * af, // "a"/input used in forward pass
1757
+ enum ggml_op_pool op,
1758
+ int k0,
1759
+ int k1,
1760
+ int s0,
1761
+ int s1,
1762
+ float p0,
1763
+ float p1);
1764
+
1765
+ enum ggml_scale_mode {
1766
+ GGML_SCALE_MODE_NEAREST = 0,
1767
+ GGML_SCALE_MODE_BILINEAR = 1,
1768
+ };
1769
+
1770
+ // interpolate
1771
+ // multiplies ne0 and ne1 by scale factor
1772
+ GGML_API struct ggml_tensor * ggml_upscale(
1773
+ struct ggml_context * ctx,
1774
+ struct ggml_tensor * a,
1775
+ int scale_factor,
1776
+ enum ggml_scale_mode mode);
1777
+
1778
+ // interpolate
1779
+ // interpolate scale to specified dimensions
1780
+ GGML_API struct ggml_tensor * ggml_upscale_ext(
1781
+ struct ggml_context * ctx,
1782
+ struct ggml_tensor * a,
1783
+ int ne0,
1784
+ int ne1,
1785
+ int ne2,
1786
+ int ne3,
1787
+ enum ggml_scale_mode mode);
1788
+
1789
+ // pad each dimension with zeros: [x, ..., x] -> [x, ..., x, 0, ..., 0]
1790
+ GGML_API struct ggml_tensor * ggml_pad(
1791
+ struct ggml_context * ctx,
1792
+ struct ggml_tensor * a,
1793
+ int p0,
1794
+ int p1,
1795
+ int p2,
1796
+ int p3);
1797
+
1798
+ // pad each dimension with reflection: [a, b, c, d] -> [b, a, b, c, d, c]
1799
+ GGML_API struct ggml_tensor * ggml_pad_reflect_1d(
1800
+ struct ggml_context * ctx,
1801
+ struct ggml_tensor * a,
1802
+ int p0,
1803
+ int p1);
1804
+
1805
+ // Move tensor elements by an offset given for each dimension. Elements that
1806
+ // are shifted beyond the last position are wrapped around to the beginning.
1807
+ GGML_API struct ggml_tensor * ggml_roll(
1808
+ struct ggml_context * ctx,
1809
+ struct ggml_tensor * a,
1810
+ int shift0,
1811
+ int shift1,
1812
+ int shift2,
1813
+ int shift3);
1814
+
1815
+
1816
+ // Ref: https://github.com/CompVis/stable-diffusion/blob/main/ldm/modules/diffusionmodules/util.py#L151
1817
+ // timesteps: [N,]
1818
+ // return: [N, dim]
1819
+ GGML_API struct ggml_tensor * ggml_timestep_embedding(
1820
+ struct ggml_context * ctx,
1821
+ struct ggml_tensor * timesteps,
1822
+ int dim,
1823
+ int max_period);
1824
+
1825
+ // sort rows
1826
+ enum ggml_sort_order {
1827
+ GGML_SORT_ORDER_ASC,
1828
+ GGML_SORT_ORDER_DESC,
1829
+ };
1830
+
1831
+ GGML_API struct ggml_tensor * ggml_argsort(
1832
+ struct ggml_context * ctx,
1833
+ struct ggml_tensor * a,
1834
+ enum ggml_sort_order order);
1835
+
1836
+ GGML_API struct ggml_tensor * ggml_arange(
1837
+ struct ggml_context * ctx,
1838
+ float start,
1839
+ float stop,
1840
+ float step);
1841
+
1842
+ // top k elements per row
1843
+ GGML_API struct ggml_tensor * ggml_top_k(
1844
+ struct ggml_context * ctx,
1845
+ struct ggml_tensor * a,
1846
+ int k);
1847
+
1848
+ #define GGML_KQ_MASK_PAD 64
1849
+
1850
+ // q: [n_embd_k, n_batch, n_head, 1]
1851
+ // k: [n_embd_k, n_kv, n_head_kv, 1]
1852
+ // v: [n_embd_v, n_kv, n_head_kv, 1] !! not transposed !!
1853
+ // mask: [n_kv, n_batch_pad, 1, 1] !! n_batch_pad = GGML_PAD(n_batch, GGML_KQ_MASK_PAD) !!
1854
+ // res: [n_embd_v, n_head, n_batch, 1] !! permuted !!
1855
+ GGML_API struct ggml_tensor * ggml_flash_attn_ext(
1856
+ struct ggml_context * ctx,
1857
+ struct ggml_tensor * q,
1858
+ struct ggml_tensor * k,
1859
+ struct ggml_tensor * v,
1860
+ struct ggml_tensor * mask,
1861
+ float scale,
1862
+ float max_bias,
1863
+ float logit_softcap);
1864
+
1865
+ GGML_API void ggml_flash_attn_ext_set_prec(
1866
+ struct ggml_tensor * a,
1867
+ enum ggml_prec prec);
1868
+
1869
+ GGML_API enum ggml_prec ggml_flash_attn_ext_get_prec(
1870
+ const struct ggml_tensor * a);
1871
+
1872
+ // TODO: needs to be adapted to ggml_flash_attn_ext
1873
+ GGML_API struct ggml_tensor * ggml_flash_attn_back(
1874
+ struct ggml_context * ctx,
1875
+ struct ggml_tensor * q,
1876
+ struct ggml_tensor * k,
1877
+ struct ggml_tensor * v,
1878
+ struct ggml_tensor * d,
1879
+ bool masked);
1880
+
1881
+ GGML_API struct ggml_tensor * ggml_ssm_conv(
1882
+ struct ggml_context * ctx,
1883
+ struct ggml_tensor * sx,
1884
+ struct ggml_tensor * c);
1885
+
1886
+ GGML_API struct ggml_tensor * ggml_ssm_scan(
1887
+ struct ggml_context * ctx,
1888
+ struct ggml_tensor * s,
1889
+ struct ggml_tensor * x,
1890
+ struct ggml_tensor * dt,
1891
+ struct ggml_tensor * A,
1892
+ struct ggml_tensor * B,
1893
+ struct ggml_tensor * C);
1894
+
1895
+ // partition into non-overlapping windows with padding if needed
1896
+ // example:
1897
+ // a: 768 64 64 1
1898
+ // w: 14
1899
+ // res: 768 14 14 25
1900
+ // used in sam
1901
+ GGML_API struct ggml_tensor * ggml_win_part(
1902
+ struct ggml_context * ctx,
1903
+ struct ggml_tensor * a,
1904
+ int w);
1905
+
1906
+ // reverse of ggml_win_part
1907
+ // used in sam
1908
+ GGML_API struct ggml_tensor * ggml_win_unpart(
1909
+ struct ggml_context * ctx,
1910
+ struct ggml_tensor * a,
1911
+ int w0,
1912
+ int h0,
1913
+ int w);
1914
+
1915
+ GGML_API struct ggml_tensor * ggml_unary(
1916
+ struct ggml_context * ctx,
1917
+ struct ggml_tensor * a,
1918
+ enum ggml_unary_op op);
1919
+
1920
+ GGML_API struct ggml_tensor * ggml_unary_inplace(
1921
+ struct ggml_context * ctx,
1922
+ struct ggml_tensor * a,
1923
+ enum ggml_unary_op op);
1924
+
1925
+ // used in sam
1926
+ GGML_API struct ggml_tensor * ggml_get_rel_pos(
1927
+ struct ggml_context * ctx,
1928
+ struct ggml_tensor * a,
1929
+ int qh,
1930
+ int kh);
1931
+
1932
+ // used in sam
1933
+ GGML_API struct ggml_tensor * ggml_add_rel_pos(
1934
+ struct ggml_context * ctx,
1935
+ struct ggml_tensor * a,
1936
+ struct ggml_tensor * pw,
1937
+ struct ggml_tensor * ph);
1938
+
1939
+ GGML_API struct ggml_tensor * ggml_add_rel_pos_inplace(
1940
+ struct ggml_context * ctx,
1941
+ struct ggml_tensor * a,
1942
+ struct ggml_tensor * pw,
1943
+ struct ggml_tensor * ph);
1944
+
1945
+ GGML_API struct ggml_tensor * ggml_rwkv_wkv6(
1946
+ struct ggml_context * ctx,
1947
+ struct ggml_tensor * k,
1948
+ struct ggml_tensor * v,
1949
+ struct ggml_tensor * r,
1950
+ struct ggml_tensor * tf,
1951
+ struct ggml_tensor * td,
1952
+ struct ggml_tensor * state);
1953
+
1954
+ GGML_API struct ggml_tensor * ggml_gated_linear_attn(
1955
+ struct ggml_context * ctx,
1956
+ struct ggml_tensor * k,
1957
+ struct ggml_tensor * v,
1958
+ struct ggml_tensor * q,
1959
+ struct ggml_tensor * g,
1960
+ struct ggml_tensor * state,
1961
+ float scale);
1962
+
1963
+ GGML_API struct ggml_tensor * ggml_rwkv_wkv7(
1964
+ struct ggml_context * ctx,
1965
+ struct ggml_tensor * r,
1966
+ struct ggml_tensor * w,
1967
+ struct ggml_tensor * k,
1968
+ struct ggml_tensor * v,
1969
+ struct ggml_tensor * a,
1970
+ struct ggml_tensor * b,
1971
+ struct ggml_tensor * state);
1972
+
1973
+ // custom operators
1974
+
1975
+ typedef void (*ggml_custom1_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, int ith, int nth, void * userdata);
1976
+ typedef void (*ggml_custom2_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, const struct ggml_tensor * b, int ith, int nth, void * userdata);
1977
+ typedef void (*ggml_custom3_op_t)(struct ggml_tensor * dst , const struct ggml_tensor * a, const struct ggml_tensor * b, const struct ggml_tensor * c, int ith, int nth, void * userdata);
1978
+
1979
+ #define GGML_N_TASKS_MAX (-1)
1980
+ // n_tasks == GGML_N_TASKS_MAX means to use max number of tasks
1981
+
1982
+ GGML_API struct ggml_tensor * ggml_map_custom1(
1983
+ struct ggml_context * ctx,
1984
+ struct ggml_tensor * a,
1985
+ ggml_custom1_op_t fun,
1986
+ int n_tasks,
1987
+ void * userdata);
1988
+
1989
+ GGML_API struct ggml_tensor * ggml_map_custom1_inplace(
1990
+ struct ggml_context * ctx,
1991
+ struct ggml_tensor * a,
1992
+ ggml_custom1_op_t fun,
1993
+ int n_tasks,
1994
+ void * userdata);
1995
+
1996
+ GGML_API struct ggml_tensor * ggml_map_custom2(
1997
+ struct ggml_context * ctx,
1998
+ struct ggml_tensor * a,
1999
+ struct ggml_tensor * b,
2000
+ ggml_custom2_op_t fun,
2001
+ int n_tasks,
2002
+ void * userdata);
2003
+
2004
+ GGML_API struct ggml_tensor * ggml_map_custom2_inplace(
2005
+ struct ggml_context * ctx,
2006
+ struct ggml_tensor * a,
2007
+ struct ggml_tensor * b,
2008
+ ggml_custom2_op_t fun,
2009
+ int n_tasks,
2010
+ void * userdata);
2011
+
2012
+ GGML_API struct ggml_tensor * ggml_map_custom3(
2013
+ struct ggml_context * ctx,
2014
+ struct ggml_tensor * a,
2015
+ struct ggml_tensor * b,
2016
+ struct ggml_tensor * c,
2017
+ ggml_custom3_op_t fun,
2018
+ int n_tasks,
2019
+ void * userdata);
2020
+
2021
+ GGML_API struct ggml_tensor * ggml_map_custom3_inplace(
2022
+ struct ggml_context * ctx,
2023
+ struct ggml_tensor * a,
2024
+ struct ggml_tensor * b,
2025
+ struct ggml_tensor * c,
2026
+ ggml_custom3_op_t fun,
2027
+ int n_tasks,
2028
+ void * userdata);
2029
+
2030
+ typedef void (*ggml_custom_op_t)(struct ggml_tensor * dst , int ith, int nth, void * userdata);
2031
+
2032
+ GGML_API struct ggml_tensor * ggml_custom_4d(
2033
+ struct ggml_context * ctx,
2034
+ enum ggml_type type,
2035
+ int64_t ne0,
2036
+ int64_t ne1,
2037
+ int64_t ne2,
2038
+ int64_t ne3,
2039
+ struct ggml_tensor ** args,
2040
+ int n_args,
2041
+ ggml_custom_op_t fun,
2042
+ int n_tasks,
2043
+ void * userdata);
2044
+
2045
+ GGML_API struct ggml_tensor * ggml_custom_inplace(
2046
+ struct ggml_context * ctx,
2047
+ struct ggml_tensor * a,
2048
+ struct ggml_tensor ** args,
2049
+ int n_args,
2050
+ ggml_custom_op_t fun,
2051
+ int n_tasks,
2052
+ void * userdata);
2053
+
2054
+ // loss function
2055
+
2056
+ GGML_API struct ggml_tensor * ggml_cross_entropy_loss(
2057
+ struct ggml_context * ctx,
2058
+ struct ggml_tensor * a, // logits
2059
+ struct ggml_tensor * b); // labels
2060
+
2061
+ GGML_API struct ggml_tensor * ggml_cross_entropy_loss_back(
2062
+ struct ggml_context * ctx,
2063
+ struct ggml_tensor * a, // logits
2064
+ struct ggml_tensor * b, // labels
2065
+ struct ggml_tensor * c); // gradients of cross_entropy_loss result
2066
+
2067
+ // AdamW optimizer step
2068
+ // Paper: https://arxiv.org/pdf/1711.05101v3.pdf
2069
+ // PyTorch: https://pytorch.org/docs/stable/generated/torch.optim.AdamW.html
2070
+ GGML_API struct ggml_tensor * ggml_opt_step_adamw(
2071
+ struct ggml_context * ctx,
2072
+ struct ggml_tensor * a,
2073
+ struct ggml_tensor * grad,
2074
+ struct ggml_tensor * m,
2075
+ struct ggml_tensor * v,
2076
+ struct ggml_tensor * adamw_params); // parameters such a the learning rate
2077
+
2078
+ //
2079
+ // automatic differentiation
2080
+ //
2081
+
2082
+ GGML_API void ggml_build_forward_expand(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor);
2083
+ GGML_API void ggml_build_backward_expand(
2084
+ struct ggml_context * ctx, // context for gradient computation
2085
+ struct ggml_cgraph * cgraph,
2086
+ struct ggml_tensor ** grad_accs);
2087
+
2088
+ // graph allocation in a context
2089
+ GGML_API struct ggml_cgraph * ggml_new_graph (struct ggml_context * ctx); // size = GGML_DEFAULT_GRAPH_SIZE, grads = false
2090
+ GGML_API struct ggml_cgraph * ggml_new_graph_custom(struct ggml_context * ctx, size_t size, bool grads);
2091
+ GGML_API struct ggml_cgraph * ggml_graph_dup (struct ggml_context * ctx, struct ggml_cgraph * cgraph, bool force_grads);
2092
+ GGML_API void ggml_graph_cpy (struct ggml_cgraph * src, struct ggml_cgraph * dst);
2093
+ GGML_API void ggml_graph_reset (struct ggml_cgraph * cgraph); // set regular grads + optimizer momenta to 0, set loss grad to 1
2094
+ GGML_API void ggml_graph_clear (struct ggml_cgraph * cgraph);
2095
+
2096
+ GGML_API int ggml_graph_size (struct ggml_cgraph * cgraph);
2097
+ GGML_API struct ggml_tensor * ggml_graph_node (struct ggml_cgraph * cgraph, int i); // if i < 0, returns nodes[n_nodes + i]
2098
+ GGML_API struct ggml_tensor ** ggml_graph_nodes (struct ggml_cgraph * cgraph);
2099
+ GGML_API int ggml_graph_n_nodes(struct ggml_cgraph * cgraph);
2100
+
2101
+ GGML_API void ggml_graph_add_node(struct ggml_cgraph * cgraph, struct ggml_tensor * tensor);
2102
+
2103
+ GGML_API size_t ggml_graph_overhead(void);
2104
+ GGML_API size_t ggml_graph_overhead_custom(size_t size, bool grads);
2105
+
2106
+ GGML_API struct ggml_tensor * ggml_graph_get_tensor (const struct ggml_cgraph * cgraph, const char * name);
2107
+ GGML_API struct ggml_tensor * ggml_graph_get_grad (const struct ggml_cgraph * cgraph, const struct ggml_tensor * node);
2108
+ GGML_API struct ggml_tensor * ggml_graph_get_grad_acc(const struct ggml_cgraph * cgraph, const struct ggml_tensor * node);
2109
+
2110
+ // print info and performance information for the graph
2111
+ GGML_API void ggml_graph_print(const struct ggml_cgraph * cgraph);
2112
+
2113
+ // dump the graph into a file using the dot format
2114
+ GGML_API void ggml_graph_dump_dot(const struct ggml_cgraph * gb, const struct ggml_cgraph * gf, const char * filename);
2115
+
2116
+ // TODO these functions were sandwiched in the old optimization interface, is there a better place for them?
2117
+ typedef void (*ggml_log_callback)(enum ggml_log_level level, const char * text, void * user_data);
2118
+
2119
+ // Set callback for all future logging events.
2120
+ // If this is not called, or NULL is supplied, everything is output on stderr.
2121
+ GGML_API void ggml_log_set(ggml_log_callback log_callback, void * user_data);
2122
+
2123
+ GGML_API struct ggml_tensor * ggml_set_zero(struct ggml_tensor * tensor);
2124
+
2125
+ //
2126
+ // quantization
2127
+ //
2128
+
2129
+ // - ggml_quantize_init can be called multiple times with the same type
2130
+ // it will only initialize the quantization tables for the first call or after ggml_quantize_free
2131
+ // automatically called by ggml_quantize_chunk for convenience
2132
+ //
2133
+ // - ggml_quantize_free will free any memory allocated by ggml_quantize_init
2134
+ // call this at the end of the program to avoid memory leaks
2135
+ //
2136
+ // note: these are thread-safe
2137
+ //
2138
+ GGML_API void ggml_quantize_init(enum ggml_type type);
2139
+ GGML_API void ggml_quantize_free(void);
2140
+
2141
+ // some quantization type cannot be used without an importance matrix
2142
+ GGML_API bool ggml_quantize_requires_imatrix(enum ggml_type type);
2143
+
2144
+ // calls ggml_quantize_init internally (i.e. can allocate memory)
2145
+ GGML_API size_t ggml_quantize_chunk(
2146
+ enum ggml_type type,
2147
+ const float * src,
2148
+ void * dst,
2149
+ int64_t start,
2150
+ int64_t nrows,
2151
+ int64_t n_per_row,
2152
+ const float * imatrix);
2153
+
2154
+ #ifdef __cplusplus
2155
+ // restrict not standard in C++
2156
+ # if defined(__GNUC__)
2157
+ # define GGML_RESTRICT __restrict__
2158
+ # elif defined(__clang__)
2159
+ # define GGML_RESTRICT __restrict
2160
+ # elif defined(_MSC_VER)
2161
+ # define GGML_RESTRICT __restrict
2162
+ # else
2163
+ # define GGML_RESTRICT
2164
+ # endif
2165
+ #else
2166
+ # if defined (_MSC_VER) && (__STDC_VERSION__ < 201112L)
2167
+ # define GGML_RESTRICT __restrict
2168
+ # else
2169
+ # define GGML_RESTRICT restrict
2170
+ # endif
2171
+ #endif
2172
+ typedef void (*ggml_to_float_t) (const void * GGML_RESTRICT x, float * GGML_RESTRICT y, int64_t k);
2173
+ typedef void (*ggml_from_float_t)(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k);
2174
+
2175
+ struct ggml_type_traits {
2176
+ const char * type_name;
2177
+ int64_t blck_size;
2178
+ int64_t blck_size_interleave; // interleave elements in blocks
2179
+ size_t type_size;
2180
+ bool is_quantized;
2181
+ ggml_to_float_t to_float;
2182
+ ggml_from_float_t from_float_ref;
2183
+ };
2184
+
2185
+ GGML_API const struct ggml_type_traits * ggml_get_type_traits(enum ggml_type type);
2186
+
2187
+ // ggml threadpool
2188
+ // TODO: currently, only a few functions are in the base ggml API, while the rest are in the CPU backend
2189
+ // the goal should be to create an API that other backends can use move everything to the ggml base
2190
+
2191
+ // scheduling priorities
2192
+ enum ggml_sched_priority {
2193
+ GGML_SCHED_PRIO_LOW = -1,
2194
+ GGML_SCHED_PRIO_NORMAL,
2195
+ GGML_SCHED_PRIO_MEDIUM,
2196
+ GGML_SCHED_PRIO_HIGH,
2197
+ GGML_SCHED_PRIO_REALTIME
2198
+ };
2199
+
2200
+ // threadpool params
2201
+ // Use ggml_threadpool_params_default() or ggml_threadpool_params_init() to populate the defaults
2202
+ struct ggml_threadpool_params {
2203
+ bool cpumask[GGML_MAX_N_THREADS]; // mask of cpu cores (all-zeros means use default affinity settings)
2204
+ int n_threads; // number of threads
2205
+ enum ggml_sched_priority prio; // thread priority
2206
+ uint32_t poll; // polling level (0 - no polling, 100 - aggressive polling)
2207
+ bool strict_cpu; // strict cpu placement
2208
+ bool paused; // start in paused state
2209
+ };
2210
+
2211
+ struct ggml_threadpool; // forward declaration, see ggml.c
2212
+
2213
+ typedef struct ggml_threadpool * ggml_threadpool_t;
2214
+
2215
+ GGML_API struct ggml_threadpool_params ggml_threadpool_params_default(int n_threads);
2216
+ GGML_API void ggml_threadpool_params_init (struct ggml_threadpool_params * p, int n_threads);
2217
+ GGML_API bool ggml_threadpool_params_match (const struct ggml_threadpool_params * p0, const struct ggml_threadpool_params * p1);
2218
+
2219
+ #ifdef __cplusplus
2220
+ }
2221
+ #endif