@fugood/llama.node 0.3.16 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/CMakeLists.txt +6 -1
  2. package/bin/darwin/arm64/llama-node.node +0 -0
  3. package/bin/darwin/x64/llama-node.node +0 -0
  4. package/bin/linux/arm64/llama-node.node +0 -0
  5. package/bin/linux/x64/llama-node.node +0 -0
  6. package/bin/linux-cuda/arm64/llama-node.node +0 -0
  7. package/bin/linux-cuda/x64/llama-node.node +0 -0
  8. package/bin/linux-vulkan/arm64/llama-node.node +0 -0
  9. package/bin/linux-vulkan/x64/llama-node.node +0 -0
  10. package/bin/win32/arm64/llama-node.node +0 -0
  11. package/bin/win32/arm64/node.lib +0 -0
  12. package/bin/win32/x64/llama-node.node +0 -0
  13. package/bin/win32/x64/node.lib +0 -0
  14. package/bin/win32-vulkan/arm64/llama-node.node +0 -0
  15. package/bin/win32-vulkan/arm64/node.lib +0 -0
  16. package/bin/win32-vulkan/x64/llama-node.node +0 -0
  17. package/bin/win32-vulkan/x64/node.lib +0 -0
  18. package/lib/binding.ts +44 -2
  19. package/lib/index.js +132 -1
  20. package/lib/index.ts +203 -3
  21. package/package.json +2 -1
  22. package/src/EmbeddingWorker.cpp +1 -1
  23. package/src/LlamaCompletionWorker.cpp +374 -19
  24. package/src/LlamaCompletionWorker.h +31 -10
  25. package/src/LlamaContext.cpp +216 -7
  26. package/src/LlamaContext.h +12 -0
  27. package/src/common.hpp +15 -0
  28. package/src/llama.cpp/.github/workflows/build-linux-cross.yml +233 -0
  29. package/src/llama.cpp/.github/workflows/build.yml +89 -767
  30. package/src/llama.cpp/.github/workflows/docker.yml +9 -6
  31. package/src/llama.cpp/.github/workflows/release.yml +716 -0
  32. package/src/llama.cpp/.github/workflows/server.yml +19 -23
  33. package/src/llama.cpp/CMakeLists.txt +11 -1
  34. package/src/llama.cpp/cmake/build-info.cmake +8 -2
  35. package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -6
  36. package/src/llama.cpp/common/CMakeLists.txt +35 -4
  37. package/src/llama.cpp/common/arg.cpp +844 -121
  38. package/src/llama.cpp/common/arg.h +9 -0
  39. package/src/llama.cpp/common/chat.cpp +129 -107
  40. package/src/llama.cpp/common/chat.h +2 -0
  41. package/src/llama.cpp/common/common.cpp +64 -518
  42. package/src/llama.cpp/common/common.h +35 -45
  43. package/src/llama.cpp/common/json-schema-to-grammar.cpp +3 -0
  44. package/src/llama.cpp/common/llguidance.cpp +31 -47
  45. package/src/llama.cpp/common/minja/chat-template.hpp +23 -11
  46. package/src/llama.cpp/common/minja/minja.hpp +186 -127
  47. package/src/llama.cpp/common/regex-partial.cpp +204 -0
  48. package/src/llama.cpp/common/regex-partial.h +56 -0
  49. package/src/llama.cpp/common/sampling.cpp +60 -50
  50. package/src/llama.cpp/docs/build.md +122 -7
  51. package/src/llama.cpp/examples/CMakeLists.txt +2 -32
  52. package/src/llama.cpp/examples/batched/batched.cpp +1 -1
  53. package/src/llama.cpp/examples/embedding/embedding.cpp +9 -12
  54. package/src/llama.cpp/examples/gritlm/gritlm.cpp +1 -1
  55. package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +1 -0
  56. package/src/llama.cpp/examples/parallel/parallel.cpp +89 -15
  57. package/src/llama.cpp/examples/passkey/passkey.cpp +1 -1
  58. package/src/llama.cpp/examples/speculative/speculative.cpp +1 -1
  59. package/src/llama.cpp/examples/speculative-simple/speculative-simple.cpp +1 -1
  60. package/src/llama.cpp/examples/sycl/build.sh +2 -2
  61. package/src/llama.cpp/examples/sycl/win-build-sycl.bat +2 -2
  62. package/src/llama.cpp/examples/training/CMakeLists.txt +5 -0
  63. package/src/llama.cpp/examples/training/finetune.cpp +96 -0
  64. package/src/llama.cpp/ggml/CMakeLists.txt +35 -2
  65. package/src/llama.cpp/ggml/cmake/GitVars.cmake +22 -0
  66. package/src/llama.cpp/ggml/include/ggml-backend.h +4 -4
  67. package/src/llama.cpp/ggml/include/ggml-cpp.h +1 -1
  68. package/src/llama.cpp/ggml/include/ggml-cpu.h +5 -0
  69. package/src/llama.cpp/ggml/include/ggml-opt.h +47 -28
  70. package/src/llama.cpp/ggml/include/ggml-rpc.h +6 -1
  71. package/src/llama.cpp/ggml/include/ggml.h +76 -106
  72. package/src/llama.cpp/ggml/src/CMakeLists.txt +11 -8
  73. package/src/llama.cpp/ggml/src/ggml-alloc.c +4 -1
  74. package/src/llama.cpp/ggml/src/ggml-backend.cpp +9 -5
  75. package/src/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +0 -2
  76. package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +8 -4
  77. package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +5 -5
  78. package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +692 -1534
  79. package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +613 -122
  80. package/src/llama.cpp/ggml/src/ggml-cann/common.h +135 -1
  81. package/src/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +507 -137
  82. package/src/llama.cpp/ggml/src/ggml-common.h +12 -6
  83. package/src/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +66 -33
  84. package/src/llama.cpp/ggml/src/ggml-cpu/binary-ops.cpp +158 -0
  85. package/src/llama.cpp/ggml/src/ggml-cpu/binary-ops.h +16 -0
  86. package/src/llama.cpp/ggml/src/ggml-cpu/common.h +72 -0
  87. package/src/llama.cpp/ggml/src/ggml-cpu/cpu-feats-x86.cpp +1 -1
  88. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +896 -194
  89. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-impl.h +2 -21
  90. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-quants.c +1060 -410
  91. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +1008 -13533
  92. package/src/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +31 -16
  93. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.cpp +90 -12
  94. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kernels.h +47 -13
  95. package/src/llama.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +266 -72
  96. package/src/llama.cpp/ggml/src/ggml-cpu/llamafile/sgemm.cpp +1034 -88
  97. package/src/llama.cpp/ggml/src/ggml-cpu/ops.cpp +8796 -0
  98. package/src/llama.cpp/ggml/src/ggml-cpu/ops.h +110 -0
  99. package/src/llama.cpp/ggml/src/ggml-cpu/simd-mappings.h +892 -0
  100. package/src/llama.cpp/ggml/src/ggml-cpu/unary-ops.cpp +186 -0
  101. package/src/llama.cpp/ggml/src/ggml-cpu/unary-ops.h +28 -0
  102. package/src/llama.cpp/ggml/src/ggml-cpu/vec.cpp +252 -0
  103. package/src/llama.cpp/ggml/src/ggml-cpu/vec.h +802 -0
  104. package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +23 -4
  105. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +7 -0
  106. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/musa.h +1 -0
  107. package/src/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +0 -4
  108. package/src/llama.cpp/ggml/src/ggml-impl.h +52 -18
  109. package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +106 -14
  110. package/src/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +67 -119
  111. package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +1023 -262
  112. package/src/llama.cpp/ggml/src/ggml-opt.cpp +368 -190
  113. package/src/llama.cpp/ggml/src/ggml-quants.c +0 -6
  114. package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +307 -40
  115. package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +125 -45
  116. package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +10 -8
  117. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +239 -0
  118. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.hpp +39 -0
  119. package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +0 -35
  120. package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +9 -307
  121. package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +72 -25
  122. package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +14 -7
  123. package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +59 -21
  124. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +7 -1
  125. package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +79 -90
  126. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +944 -438
  127. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +22 -23
  128. package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +37 -8
  129. package/src/llama.cpp/ggml/src/ggml-sycl/getrows.cpp +24 -20
  130. package/src/llama.cpp/ggml/src/ggml-sycl/getrows.hpp +1 -4
  131. package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +507 -411
  132. package/src/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +84 -74
  133. package/src/llama.cpp/ggml/src/ggml-sycl/im2col.hpp +1 -3
  134. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +185 -89
  135. package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +37 -49
  136. package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +7 -22
  137. package/src/llama.cpp/ggml/src/ggml-sycl/outprod.cpp +4 -14
  138. package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +83 -0
  139. package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +204 -118
  140. package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +1 -3
  141. package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +128 -53
  142. package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +83 -49
  143. package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +1278 -282
  144. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +32 -0
  145. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +133 -30
  146. package/src/llama.cpp/ggml/src/ggml.c +170 -265
  147. package/src/llama.cpp/ggml/src/gguf.cpp +34 -33
  148. package/src/llama.cpp/include/llama.h +82 -22
  149. package/src/llama.cpp/models/ggml-vocab-llama4.gguf.inp +112 -0
  150. package/src/llama.cpp/models/ggml-vocab-llama4.gguf.out +46 -0
  151. package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.inp +112 -0
  152. package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.out +46 -0
  153. package/src/llama.cpp/requirements/requirements-all.txt +5 -3
  154. package/src/llama.cpp/requirements/requirements-gguf_editor_gui.txt +3 -0
  155. package/src/llama.cpp/scripts/xxd.cmake +1 -1
  156. package/src/llama.cpp/src/CMakeLists.txt +4 -2
  157. package/src/llama.cpp/src/llama-adapter.cpp +43 -1
  158. package/src/llama.cpp/src/llama-arch.cpp +163 -17
  159. package/src/llama.cpp/src/llama-arch.h +16 -0
  160. package/src/llama.cpp/src/llama-batch.cpp +5 -1
  161. package/src/llama.cpp/src/llama-batch.h +2 -1
  162. package/src/llama.cpp/src/llama-chat.cpp +91 -16
  163. package/src/llama.cpp/src/llama-chat.h +7 -2
  164. package/src/llama.cpp/src/llama-context.cpp +479 -575
  165. package/src/llama.cpp/src/llama-context.h +44 -33
  166. package/src/llama.cpp/src/llama-cparams.h +1 -0
  167. package/src/llama.cpp/src/llama-graph.cpp +209 -157
  168. package/src/llama.cpp/src/llama-graph.h +38 -14
  169. package/src/llama.cpp/src/llama-hparams.h +13 -0
  170. package/src/llama.cpp/src/llama-kv-cache.cpp +1604 -543
  171. package/src/llama.cpp/src/llama-kv-cache.h +283 -171
  172. package/src/llama.cpp/src/llama-memory.h +12 -2
  173. package/src/llama.cpp/src/llama-mmap.cpp +1 -1
  174. package/src/llama.cpp/src/llama-model-loader.cpp +34 -20
  175. package/src/llama.cpp/src/llama-model-loader.h +5 -3
  176. package/src/llama.cpp/src/llama-model-saver.cpp +281 -0
  177. package/src/llama.cpp/src/llama-model-saver.h +37 -0
  178. package/src/llama.cpp/src/llama-model.cpp +1803 -330
  179. package/src/llama.cpp/src/llama-model.h +21 -2
  180. package/src/llama.cpp/src/llama-quant.cpp +33 -10
  181. package/src/llama.cpp/src/llama-sampling.cpp +25 -7
  182. package/src/llama.cpp/src/llama-vocab.cpp +86 -10
  183. package/src/llama.cpp/src/llama-vocab.h +6 -0
  184. package/src/llama.cpp/src/llama.cpp +15 -1
  185. package/src/llama.cpp/tests/CMakeLists.txt +52 -31
  186. package/src/llama.cpp/tests/test-arg-parser.cpp +51 -4
  187. package/src/llama.cpp/tests/test-backend-ops.cpp +189 -90
  188. package/src/llama.cpp/tests/test-chat-template.cpp +26 -6
  189. package/src/llama.cpp/tests/test-chat.cpp +15 -3
  190. package/src/llama.cpp/{examples/gbnf-validator/gbnf-validator.cpp → tests/test-gbnf-validator.cpp} +2 -2
  191. package/src/llama.cpp/tests/test-grammar-integration.cpp +3 -2
  192. package/src/llama.cpp/tests/test-grammar-llguidance.cpp +63 -2
  193. package/src/llama.cpp/tests/test-grammar-parser.cpp +3 -1
  194. package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +17 -1
  195. package/src/llama.cpp/tests/test-llama-grammar.cpp +2 -1
  196. package/src/llama.cpp/tests/test-mtmd-c-api.c +63 -0
  197. package/src/llama.cpp/tests/test-opt.cpp +33 -21
  198. package/src/llama.cpp/{examples/quantize-stats/quantize-stats.cpp → tests/test-quantize-stats.cpp} +3 -1
  199. package/src/llama.cpp/tests/test-regex-partial.cpp +288 -0
  200. package/src/llama.cpp/tests/test-sampling.cpp +1 -1
  201. package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +2 -1
  202. package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +2 -1
  203. package/src/llama.cpp/tools/CMakeLists.txt +39 -0
  204. package/src/llama.cpp/{examples → tools}/batched-bench/batched-bench.cpp +3 -3
  205. package/src/llama.cpp/{examples → tools}/export-lora/export-lora.cpp +1 -1
  206. package/src/llama.cpp/{examples → tools}/gguf-split/gguf-split.cpp +15 -16
  207. package/src/llama.cpp/{examples → tools}/imatrix/imatrix.cpp +11 -9
  208. package/src/llama.cpp/{examples → tools}/llama-bench/llama-bench.cpp +623 -274
  209. package/src/llama.cpp/{examples → tools}/main/main.cpp +22 -14
  210. package/src/llama.cpp/tools/mtmd/CMakeLists.txt +47 -0
  211. package/src/llama.cpp/tools/mtmd/clip-impl.h +365 -0
  212. package/src/llama.cpp/tools/mtmd/clip.cpp +3646 -0
  213. package/src/llama.cpp/tools/mtmd/clip.h +99 -0
  214. package/src/llama.cpp/tools/mtmd/deprecation-warning.cpp +22 -0
  215. package/src/llama.cpp/tools/mtmd/mtmd-cli.cpp +370 -0
  216. package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +310 -0
  217. package/src/llama.cpp/tools/mtmd/mtmd.cpp +678 -0
  218. package/src/llama.cpp/tools/mtmd/mtmd.h +331 -0
  219. package/src/llama.cpp/{examples → tools}/perplexity/perplexity.cpp +21 -5
  220. package/src/llama.cpp/{examples → tools}/quantize/quantize.cpp +53 -3
  221. package/src/llama.cpp/tools/rpc/CMakeLists.txt +4 -0
  222. package/src/llama.cpp/tools/rpc/rpc-server.cpp +322 -0
  223. package/src/llama.cpp/tools/run/CMakeLists.txt +16 -0
  224. package/src/llama.cpp/{examples → tools}/run/run.cpp +30 -30
  225. package/src/llama.cpp/{examples → tools}/server/CMakeLists.txt +2 -1
  226. package/src/llama.cpp/{examples → tools}/server/httplib.h +313 -247
  227. package/src/llama.cpp/{examples → tools}/server/server.cpp +529 -215
  228. package/src/llama.cpp/{examples → tools}/server/utils.hpp +427 -6
  229. package/src/llama.cpp/{examples → tools}/tts/tts.cpp +6 -9
  230. package/src/llama.cpp/cmake/arm64-windows-msvc.cmake +0 -6
  231. package/src/llama.cpp/examples/gbnf-validator/CMakeLists.txt +0 -5
  232. package/src/llama.cpp/examples/infill/CMakeLists.txt +0 -5
  233. package/src/llama.cpp/examples/infill/infill.cpp +0 -590
  234. package/src/llama.cpp/examples/llava/CMakeLists.txt +0 -66
  235. package/src/llama.cpp/examples/llava/android/build_64.sh +0 -8
  236. package/src/llama.cpp/examples/llava/clip-quantize-cli.cpp +0 -59
  237. package/src/llama.cpp/examples/llava/clip.cpp +0 -3206
  238. package/src/llama.cpp/examples/llava/clip.h +0 -118
  239. package/src/llama.cpp/examples/llava/gemma3-cli.cpp +0 -341
  240. package/src/llama.cpp/examples/llava/llava-cli.cpp +0 -332
  241. package/src/llama.cpp/examples/llava/llava.cpp +0 -574
  242. package/src/llama.cpp/examples/llava/llava.h +0 -49
  243. package/src/llama.cpp/examples/llava/minicpmv-cli.cpp +0 -354
  244. package/src/llama.cpp/examples/llava/qwen2vl-cli.cpp +0 -584
  245. package/src/llama.cpp/examples/quantize-stats/CMakeLists.txt +0 -6
  246. package/src/llama.cpp/examples/rpc/CMakeLists.txt +0 -2
  247. package/src/llama.cpp/examples/rpc/rpc-server.cpp +0 -171
  248. package/src/llama.cpp/examples/run/CMakeLists.txt +0 -5
  249. package/src/llama.cpp/ggml/src/ggml-cann/kernels/CMakeLists.txt +0 -30
  250. package/src/llama.cpp/ggml/src/ggml-cann/kernels/ascendc_kernels.h +0 -19
  251. package/src/llama.cpp/ggml/src/ggml-cann/kernels/dup.cpp +0 -234
  252. package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f16.cpp +0 -197
  253. package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_f32.cpp +0 -190
  254. package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q4_0.cpp +0 -204
  255. package/src/llama.cpp/ggml/src/ggml-cann/kernels/get_row_q8_0.cpp +0 -191
  256. package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +0 -218
  257. package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +0 -216
  258. package/src/llama.cpp/ggml/src/ggml-cann/kernels/quantize_float_to_q4_0.cpp +0 -295
  259. /package/src/llama.cpp/{examples → tools}/batched-bench/CMakeLists.txt +0 -0
  260. /package/src/llama.cpp/{examples → tools}/cvector-generator/CMakeLists.txt +0 -0
  261. /package/src/llama.cpp/{examples → tools}/cvector-generator/completions.txt +0 -0
  262. /package/src/llama.cpp/{examples → tools}/cvector-generator/cvector-generator.cpp +0 -0
  263. /package/src/llama.cpp/{examples → tools}/cvector-generator/mean.hpp +0 -0
  264. /package/src/llama.cpp/{examples → tools}/cvector-generator/negative.txt +0 -0
  265. /package/src/llama.cpp/{examples → tools}/cvector-generator/pca.hpp +0 -0
  266. /package/src/llama.cpp/{examples → tools}/cvector-generator/positive.txt +0 -0
  267. /package/src/llama.cpp/{examples → tools}/export-lora/CMakeLists.txt +0 -0
  268. /package/src/llama.cpp/{examples → tools}/gguf-split/CMakeLists.txt +0 -0
  269. /package/src/llama.cpp/{examples → tools}/imatrix/CMakeLists.txt +0 -0
  270. /package/src/llama.cpp/{examples → tools}/llama-bench/CMakeLists.txt +0 -0
  271. /package/src/llama.cpp/{examples → tools}/main/CMakeLists.txt +0 -0
  272. /package/src/llama.cpp/{examples/llava → tools/mtmd}/requirements.txt +0 -0
  273. /package/src/llama.cpp/{examples → tools}/perplexity/CMakeLists.txt +0 -0
  274. /package/src/llama.cpp/{examples → tools}/quantize/CMakeLists.txt +0 -0
  275. /package/src/llama.cpp/{examples → tools}/run/linenoise.cpp/linenoise.cpp +0 -0
  276. /package/src/llama.cpp/{examples → tools}/run/linenoise.cpp/linenoise.h +0 -0
  277. /package/src/llama.cpp/{examples → tools}/server/bench/requirements.txt +0 -0
  278. /package/src/llama.cpp/{examples → tools}/server/tests/requirements.txt +0 -0
  279. /package/src/llama.cpp/{examples → tools}/tokenize/CMakeLists.txt +0 -0
  280. /package/src/llama.cpp/{examples → tools}/tokenize/tokenize.cpp +0 -0
  281. /package/src/llama.cpp/{examples → tools}/tts/CMakeLists.txt +0 -0
@@ -0,0 +1,186 @@
1
+ #include "unary-ops.h"
2
+
3
+ static inline float op_abs(float x) {
4
+ return fabsf(x);
5
+ }
6
+
7
+ static inline float op_sgn(float x) {
8
+ return (x > 0.f) ? 1.f : ((x < 0.f) ? -1.f : 0.f);
9
+ }
10
+
11
+ static inline float op_neg(float x) {
12
+ return -x;
13
+ }
14
+
15
+ static inline float op_step(float x) {
16
+ return (x > 0.f) ? 1.f : 0.f;
17
+ }
18
+
19
+ static inline float op_tanh(float x) {
20
+ return tanhf(x);
21
+ }
22
+
23
+ static inline float op_elu(float x) {
24
+ return (x > 0.f) ? x : expm1f(x);
25
+ }
26
+
27
+ static inline float op_relu(float x) {
28
+ return (x > 0.f) ? x : 0.f;
29
+ }
30
+
31
+ static inline float op_sigmoid(float x) {
32
+ return 1.f / (1.f + expf(-x));
33
+ }
34
+
35
+ static inline float op_hardsigmoid(float x) {
36
+ return fminf(1.0f, fmaxf(0.0f, (x + 3.0f) / 6.0f));
37
+ }
38
+
39
+ static inline float op_exp(float x) {
40
+ return expf(x);
41
+ }
42
+
43
+ static inline float op_hardswish(float x) {
44
+ return x * fminf(1.0f, fmaxf(0.0f, (x + 3.0f) / 6.0f));
45
+ }
46
+
47
+ static inline float op_sqr(float x) {
48
+ return x * x;
49
+ }
50
+
51
+ static inline float op_sqrt(float x) {
52
+ return sqrtf(x);
53
+ }
54
+
55
+ static inline float op_sin(float x) {
56
+ return sinf(x);
57
+ }
58
+
59
+ static inline float op_cos(float x) {
60
+ return cosf(x);
61
+ }
62
+
63
+ static inline float op_log(float x) {
64
+ return logf(x);
65
+ }
66
+
67
+ template <float (*op)(float), typename src0_t, typename dst_t>
68
+ static inline void vec_unary_op(int64_t n, dst_t * y, const src0_t * x) {
69
+ constexpr auto src0_to_f32 = type_conversion_table<src0_t>::to_f32;
70
+ constexpr auto f32_to_dst = type_conversion_table<dst_t >::from_f32;
71
+
72
+ for (int i = 0; i < n; i++) {
73
+ y[i] = f32_to_dst(op(src0_to_f32(x[i])));
74
+ }
75
+ }
76
+
77
+ template <float (*op)(float), typename src0_t, typename dst_t>
78
+ static void apply_unary_op(const ggml_compute_params * params, ggml_tensor * dst) {
79
+ const ggml_tensor * src0 = dst->src[0];
80
+
81
+ GGML_ASSERT(ggml_is_contiguous_1(src0) && ggml_is_contiguous_1(dst) && ggml_are_same_shape(src0, dst));
82
+
83
+ GGML_TENSOR_UNARY_OP_LOCALS
84
+
85
+ GGML_ASSERT( nb0 == sizeof(dst_t));
86
+ GGML_ASSERT(nb00 == sizeof(src0_t));
87
+
88
+ const auto [ir0, ir1] = get_thread_range(params, src0);
89
+
90
+ for (int64_t ir = ir0; ir < ir1; ++ir) {
91
+ const int64_t i03 = ir/(ne02*ne01);
92
+ const int64_t i02 = (ir - i03*ne02*ne01)/ne01;
93
+ const int64_t i01 = (ir - i03*ne02*ne01 - i02*ne01);
94
+
95
+ dst_t * dst_ptr = (dst_t *) ((char *) dst->data + i03*nb3 + i02*nb2 + i01*nb1 );
96
+ const src0_t * src0_ptr = (const src0_t *) ((const char *) src0->data + i03*nb03 + i02*nb02 + i01*nb01);
97
+
98
+ vec_unary_op<op>(ne0, dst_ptr, src0_ptr);
99
+ }
100
+ }
101
+
102
+ // TODO: Use the 'traits' lookup table (for type conversion fns), instead of a mass of 'if' conditions with long templates
103
+ template <float (*op)(float)>
104
+ static void unary_op(const ggml_compute_params * params, ggml_tensor * dst) {
105
+ const ggml_tensor * src0 = dst->src[0];
106
+
107
+ /* */ if (src0->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32) { // all f32
108
+ apply_unary_op<op, float, float>(params, dst);
109
+ } else if (src0->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F16) { // all f16
110
+ apply_unary_op<op, ggml_fp16_t, ggml_fp16_t>(params, dst);
111
+ } else if (src0->type == GGML_TYPE_BF16 && dst->type == GGML_TYPE_BF16) { // all bf16
112
+ apply_unary_op<op, ggml_bf16_t, ggml_bf16_t>(params, dst);
113
+ } else if (src0->type == GGML_TYPE_BF16 && dst->type == GGML_TYPE_F32) {
114
+ apply_unary_op<op, ggml_bf16_t, float>(params, dst);
115
+ } else if (src0->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F32) {
116
+ apply_unary_op<op, ggml_fp16_t, float>(params, dst);
117
+ } else {
118
+ fprintf(stderr, "%s: unsupported types: dst: %s, src0: %s\n", __func__,
119
+ ggml_type_name(dst->type), ggml_type_name(src0->type));
120
+ GGML_ABORT("fatal error");
121
+ }
122
+ }
123
+
124
+ void ggml_compute_forward_abs(const ggml_compute_params * params, ggml_tensor * dst) {
125
+ unary_op<op_abs>(params, dst);
126
+ }
127
+
128
+ void ggml_compute_forward_sgn(const ggml_compute_params * params, ggml_tensor * dst) {
129
+ unary_op<op_sgn>(params, dst);
130
+ }
131
+
132
+ void ggml_compute_forward_neg(const ggml_compute_params * params, ggml_tensor * dst) {
133
+ unary_op<op_neg>(params, dst);
134
+ }
135
+
136
+ void ggml_compute_forward_step(const ggml_compute_params * params, ggml_tensor * dst) {
137
+ unary_op<op_step>(params, dst);
138
+ }
139
+
140
+ void ggml_compute_forward_tanh(const ggml_compute_params * params, ggml_tensor * dst) {
141
+ unary_op<op_tanh>(params, dst);
142
+ }
143
+
144
+ void ggml_compute_forward_elu(const ggml_compute_params * params, ggml_tensor * dst) {
145
+ unary_op<op_elu>(params, dst);
146
+ }
147
+
148
+ void ggml_compute_forward_relu(const ggml_compute_params * params, ggml_tensor * dst) {
149
+ unary_op<op_relu>(params, dst);
150
+ }
151
+
152
+ void ggml_compute_forward_sigmoid(const ggml_compute_params * params, ggml_tensor * dst) {
153
+ unary_op<op_sigmoid>(params, dst);
154
+ }
155
+
156
+ void ggml_compute_forward_hardsigmoid(const ggml_compute_params * params, ggml_tensor * dst) {
157
+ unary_op<op_hardsigmoid>(params, dst);
158
+ }
159
+
160
+ void ggml_compute_forward_exp(const ggml_compute_params * params, ggml_tensor * dst) {
161
+ unary_op<op_exp>(params, dst);
162
+ }
163
+
164
+ void ggml_compute_forward_hardswish(const ggml_compute_params * params, ggml_tensor * dst) {
165
+ unary_op<op_hardswish>(params, dst);
166
+ }
167
+
168
+ void ggml_compute_forward_sqr(const ggml_compute_params * params, ggml_tensor * dst) {
169
+ unary_op<op_sqr>(params, dst);
170
+ }
171
+
172
+ void ggml_compute_forward_sqrt(const ggml_compute_params * params, ggml_tensor * dst) {
173
+ unary_op<op_sqrt>(params, dst);
174
+ }
175
+
176
+ void ggml_compute_forward_sin(const ggml_compute_params * params, ggml_tensor * dst) {
177
+ unary_op<op_sin>(params, dst);
178
+ }
179
+
180
+ void ggml_compute_forward_cos(const ggml_compute_params * params, ggml_tensor * dst) {
181
+ unary_op<op_cos>(params, dst);
182
+ }
183
+
184
+ void ggml_compute_forward_log(const ggml_compute_params * params, ggml_tensor * dst) {
185
+ unary_op<op_log>(params, dst);
186
+ }
@@ -0,0 +1,28 @@
1
+ #pragma once
2
+
3
+ #include "common.h"
4
+
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ void ggml_compute_forward_abs(const struct ggml_compute_params * params, struct ggml_tensor * dst);
10
+ void ggml_compute_forward_sgn(const struct ggml_compute_params * params, struct ggml_tensor * dst);
11
+ void ggml_compute_forward_neg(const struct ggml_compute_params * params, struct ggml_tensor * dst);
12
+ void ggml_compute_forward_step(const struct ggml_compute_params * params, struct ggml_tensor * dst);
13
+ void ggml_compute_forward_tanh(const struct ggml_compute_params * params, struct ggml_tensor * dst);
14
+ void ggml_compute_forward_elu(const struct ggml_compute_params * params, struct ggml_tensor * dst);
15
+ void ggml_compute_forward_relu(const struct ggml_compute_params * params, struct ggml_tensor * dst);
16
+ void ggml_compute_forward_sigmoid(const struct ggml_compute_params * params, struct ggml_tensor * dst);
17
+ void ggml_compute_forward_hardsigmoid(const struct ggml_compute_params * params, struct ggml_tensor * dst);
18
+ void ggml_compute_forward_exp(const struct ggml_compute_params * params, struct ggml_tensor * dst);
19
+ void ggml_compute_forward_hardswish(const struct ggml_compute_params * params, struct ggml_tensor * dst);
20
+ void ggml_compute_forward_sqr(const struct ggml_compute_params * params, struct ggml_tensor * dst);
21
+ void ggml_compute_forward_sqrt(const struct ggml_compute_params * params, struct ggml_tensor * dst);
22
+ void ggml_compute_forward_sin(const struct ggml_compute_params * params, struct ggml_tensor * dst);
23
+ void ggml_compute_forward_cos(const struct ggml_compute_params * params, struct ggml_tensor * dst);
24
+ void ggml_compute_forward_log(const struct ggml_compute_params * params, struct ggml_tensor * dst);
25
+
26
+ #ifdef __cplusplus
27
+ }
28
+ #endif
@@ -0,0 +1,252 @@
1
+ #include "vec.h"
2
+
3
+ #include <cassert>
4
+
5
+ // precomputed gelu table for f16 (128 KB)
6
+ ggml_fp16_t ggml_table_gelu_f16[1 << 16];
7
+
8
+ // precomputed quick gelu table for f16 (128 KB)
9
+ ggml_fp16_t ggml_table_gelu_quick_f16[1 << 16];
10
+
11
+ void ggml_vec_dot_f32(int n, float * GGML_RESTRICT s, size_t bs, const float * GGML_RESTRICT x, size_t bx, const float * GGML_RESTRICT y, size_t by, int nrc) {
12
+ assert(nrc == 1);
13
+ GGML_UNUSED(nrc);
14
+ GGML_UNUSED(bx);
15
+ GGML_UNUSED(by);
16
+ GGML_UNUSED(bs);
17
+
18
+ #if defined(GGML_SIMD)
19
+ float sumf = 0.0f;
20
+ const int np = (n & ~(GGML_F32_STEP - 1));
21
+
22
+ GGML_F32_VEC sum[GGML_F32_ARR] = { GGML_F32_VEC_ZERO };
23
+
24
+ GGML_F32_VEC ax[GGML_F32_ARR];
25
+ GGML_F32_VEC ay[GGML_F32_ARR];
26
+
27
+ for (int i = 0; i < np; i += GGML_F32_STEP) {
28
+ for (int j = 0; j < GGML_F32_ARR; j++) {
29
+ ax[j] = GGML_F32_VEC_LOAD(x + i + j*GGML_F32_EPR);
30
+ ay[j] = GGML_F32_VEC_LOAD(y + i + j*GGML_F32_EPR);
31
+
32
+ sum[j] = GGML_F32_VEC_FMA(sum[j], ax[j], ay[j]);
33
+ }
34
+ }
35
+
36
+ // reduce sum0..sum3 to sum0
37
+ GGML_F32_VEC_REDUCE(sumf, sum);
38
+
39
+ // leftovers
40
+ for (int i = np; i < n; ++i) {
41
+ sumf += x[i]*y[i];
42
+ }
43
+ #else
44
+ // scalar
45
+ ggml_float sumf = 0.0;
46
+ for (int i = 0; i < n; ++i) {
47
+ sumf += (ggml_float)(x[i]*y[i]);
48
+ }
49
+ #endif
50
+
51
+ *s = sumf;
52
+ }
53
+
54
+ void ggml_vec_dot_bf16(int n, float * GGML_RESTRICT s, size_t bs, ggml_bf16_t * GGML_RESTRICT x, size_t bx, ggml_bf16_t * GGML_RESTRICT y, size_t by, int nrc) {
55
+ assert(nrc == 1);
56
+ GGML_UNUSED(nrc);
57
+ GGML_UNUSED(bx);
58
+ GGML_UNUSED(by);
59
+ GGML_UNUSED(bs);
60
+ int i = 0;
61
+ ggml_float sumf = 0;
62
+
63
+ #if defined(__AVX512BF16__)
64
+ __m512 c1 = _mm512_setzero_ps();
65
+ __m512 c2 = _mm512_setzero_ps();
66
+ for (; i + 64 <= n; i += 64) {
67
+ c1 = _mm512_dpbf16_ps(c1, m512bh(_mm512_loadu_si512((x + i))),
68
+ m512bh(_mm512_loadu_si512((y + i))));
69
+ c2 = _mm512_dpbf16_ps(c2, m512bh(_mm512_loadu_si512((x + i + 32))),
70
+ m512bh(_mm512_loadu_si512((y + i + 32))));
71
+ }
72
+ sumf += (ggml_float)_mm512_reduce_add_ps(c1);
73
+ sumf += (ggml_float)_mm512_reduce_add_ps(c2);
74
+
75
+ #elif defined(__AVX512F__)
76
+ #define LOAD(p) _mm512_castsi512_ps(_mm512_slli_epi32(_mm512_cvtepu16_epi32(_mm256_loadu_si256((const __m256i *)(p))), 16))
77
+ __m512 c1 = _mm512_setzero_ps();
78
+ __m512 c2 = _mm512_setzero_ps();
79
+ for (; i + 32 <= n; i += 32) {
80
+ c1 = _mm512_add_ps(_mm512_mul_ps(LOAD(x + i), LOAD(y + i)), c1);
81
+ c2 = _mm512_add_ps(_mm512_mul_ps(LOAD(x + i + 16), LOAD(y + i + 16)), c2);
82
+ }
83
+ sumf += (ggml_float)_mm512_reduce_add_ps(c1);
84
+ sumf += (ggml_float)_mm512_reduce_add_ps(c2);
85
+
86
+ #undef LOAD
87
+ #elif defined(__AVX2__) || defined(__AVX__)
88
+ #if defined(__AVX2__)
89
+ #define LOAD(p) _mm256_castsi256_ps(_mm256_slli_epi32(_mm256_cvtepu16_epi32(_mm_loadu_si128((const __m128i *)(p))), 16))
90
+ #else
91
+ #define LOAD(p) _mm256_castsi256_ps(_mm256_insertf128_si256(_mm256_castsi128_si256(_mm_slli_epi32(_mm_cvtepu16_epi32(_mm_loadu_si128((const __m128i *)(p))), 16)), (_mm_slli_epi32(_mm_cvtepu16_epi32(_mm_bsrli_si128(_mm_loadu_si128((const __m128i *)(p)), 8)), 16)), 1))
92
+ #endif
93
+ __m256 c1 = _mm256_setzero_ps();
94
+ __m256 c2 = _mm256_setzero_ps();
95
+ __m256 c3 = _mm256_setzero_ps();
96
+ __m256 c4 = _mm256_setzero_ps();
97
+ for (; i + 32 <= n; i += 32) {
98
+ c1 = _mm256_add_ps(_mm256_mul_ps(LOAD(x + i), LOAD(y + i)), c1);
99
+ c2 = _mm256_add_ps(_mm256_mul_ps(LOAD(x + i + 8), LOAD(y + i + 8)), c2);
100
+ c3 = _mm256_add_ps(_mm256_mul_ps(LOAD(x + i + 16), LOAD(y + i + 16)), c3);
101
+ c4 = _mm256_add_ps(_mm256_mul_ps(LOAD(x + i + 24), LOAD(y + i + 24)), c4);
102
+ }
103
+ __m128 g;
104
+ c1 = _mm256_add_ps(_mm256_add_ps(c1, c3),
105
+ _mm256_add_ps(c2, c4));
106
+ g = _mm_add_ps(_mm256_extractf128_ps(c1, 1),
107
+ _mm256_castps256_ps128(c1));
108
+ g = _mm_add_ps(g, _mm_movehl_ps(g, g));
109
+ g = _mm_add_ss(g, _mm_movehdup_ps(g));
110
+ sumf += (ggml_float)_mm_cvtss_f32(g);
111
+
112
+ #undef LOAD
113
+ #endif
114
+
115
+ for (; i < n; ++i) {
116
+ sumf += (ggml_float)(GGML_BF16_TO_FP32(x[i]) *
117
+ GGML_BF16_TO_FP32(y[i]));
118
+ }
119
+ *s = sumf;
120
+ }
121
+
122
+ void ggml_vec_dot_f16(int n, float * GGML_RESTRICT s, size_t bs, ggml_fp16_t * GGML_RESTRICT x, size_t bx, ggml_fp16_t * GGML_RESTRICT y, size_t by, int nrc) {
123
+ assert(nrc == 1);
124
+ GGML_UNUSED(nrc);
125
+ GGML_UNUSED(bx);
126
+ GGML_UNUSED(by);
127
+ GGML_UNUSED(bs);
128
+
129
+ ggml_float sumf = 0.0;
130
+
131
+ #if defined(GGML_SIMD)
132
+ const int np = (n & ~(GGML_F16_STEP - 1));
133
+
134
+ GGML_F16_VEC sum[GGML_F16_ARR] = { GGML_F16_VEC_ZERO };
135
+
136
+ GGML_F16_VEC ax[GGML_F16_ARR];
137
+ GGML_F16_VEC ay[GGML_F16_ARR];
138
+
139
+ for (int i = 0; i < np; i += GGML_F16_STEP) {
140
+ for (int j = 0; j < GGML_F16_ARR; j++) {
141
+ ax[j] = GGML_F16_VEC_LOAD(x + i + j*GGML_F16_EPR, j);
142
+ ay[j] = GGML_F16_VEC_LOAD(y + i + j*GGML_F16_EPR, j);
143
+
144
+ sum[j] = GGML_F16_VEC_FMA(sum[j], ax[j], ay[j]);
145
+ }
146
+ }
147
+
148
+ // reduce sum0..sum3 to sum0
149
+ GGML_F16_VEC_REDUCE(sumf, sum);
150
+
151
+ // leftovers
152
+ for (int i = np; i < n; ++i) {
153
+ sumf += (ggml_float)(GGML_FP16_TO_FP32(x[i])*GGML_FP16_TO_FP32(y[i]));
154
+ }
155
+ #else
156
+ for (int i = 0; i < n; ++i) {
157
+ sumf += (ggml_float)(GGML_FP16_TO_FP32(x[i])*GGML_FP16_TO_FP32(y[i]));
158
+ }
159
+ #endif
160
+
161
+ *s = sumf;
162
+ }
163
+
164
+ void ggml_vec_silu_f32(const int n, float * y, const float * x) {
165
+ int i = 0;
166
+ #if defined(__AVX512F__) && defined(__AVX512DQ__)
167
+ for (; i + 15 < n; i += 16) {
168
+ _mm512_storeu_ps(y + i, ggml_v_silu(_mm512_loadu_ps(x + i)));
169
+ }
170
+ #elif defined(__AVX2__) && defined(__FMA__)
171
+ for (; i + 7 < n; i += 8) {
172
+ _mm256_storeu_ps(y + i, ggml_v_silu(_mm256_loadu_ps(x + i)));
173
+ }
174
+ #elif defined(__SSE2__)
175
+ for (; i + 3 < n; i += 4) {
176
+ _mm_storeu_ps(y + i, ggml_v_silu(_mm_loadu_ps(x + i)));
177
+ }
178
+ #elif defined(__ARM_NEON) && defined(__aarch64__)
179
+ for (; i + 3 < n; i += 4) {
180
+ vst1q_f32(y + i, ggml_v_silu(vld1q_f32(x + i)));
181
+ }
182
+ #endif
183
+ for (; i < n; ++i) {
184
+ y[i] = ggml_silu_f32(x[i]);
185
+ }
186
+ }
187
+
188
+ ggml_float ggml_vec_soft_max_f32(const int n, float * y, const float * x, float max) {
189
+ int i = 0;
190
+ ggml_float sum = 0;
191
+ #if defined(__AVX512F__) && defined(__AVX512DQ__)
192
+ for (; i + 15 < n; i += 16) {
193
+ __m512 val = ggml_v_expf(_mm512_sub_ps(_mm512_loadu_ps(x + i),
194
+ _mm512_set1_ps(max)));
195
+ _mm512_storeu_ps(y + i, val);
196
+ sum += (ggml_float)_mm512_reduce_add_ps(val);
197
+ }
198
+ #elif defined(__AVX2__) && defined(__FMA__)
199
+ for (; i + 7 < n; i += 8) {
200
+ __m256 val = ggml_v_expf(_mm256_sub_ps(_mm256_loadu_ps(x + i),
201
+ _mm256_set1_ps(max)));
202
+ _mm256_storeu_ps(y + i, val);
203
+ __m128 val2 = _mm_add_ps(_mm256_extractf128_ps(val, 1),
204
+ _mm256_castps256_ps128(val));
205
+ val2 = _mm_add_ps(val2, _mm_movehl_ps(val2, val2));
206
+ val2 = _mm_add_ss(val2, _mm_movehdup_ps(val2));
207
+ sum += (ggml_float)_mm_cvtss_f32(val2);
208
+ }
209
+ #elif defined(__SSE2__)
210
+ for (; i + 3 < n; i += 4) {
211
+ __m128 val = ggml_v_expf(_mm_sub_ps(_mm_loadu_ps(x + i),
212
+ _mm_set1_ps(max)));
213
+ _mm_storeu_ps(y + i, val);
214
+ #if defined(__AVX__) || defined(__AVX2__) || defined(__AVX512F__)
215
+ val = _mm_add_ps(val, _mm_movehl_ps(val, val));
216
+ val = _mm_add_ss(val, _mm_movehdup_ps(val));
217
+ #else
218
+ __m128 tmp = _mm_shuffle_ps(val, val, _MM_SHUFFLE(2, 3, 0, 1));
219
+ val = _mm_add_ps(val, tmp);
220
+ tmp = _mm_movehl_ps(tmp, val);
221
+ val = _mm_add_ss(val, tmp);
222
+ #endif
223
+ sum += (ggml_float)_mm_cvtss_f32(val);
224
+ }
225
+ #elif defined(__ARM_NEON) && defined(__aarch64__)
226
+ for (; i + 3 < n; i += 4) {
227
+ float32x4_t val = ggml_v_expf(vsubq_f32(vld1q_f32(x + i),
228
+ vdupq_n_f32(max)));
229
+ vst1q_f32(y + i, val);
230
+ sum += (ggml_float)vaddvq_f32(val);
231
+ }
232
+ #endif
233
+ for (; i < n; ++i) {
234
+ float val = expf(x[i] - max);
235
+ sum += (ggml_float)val;
236
+ y[i] = val;
237
+ }
238
+ return sum;
239
+ }
240
+
241
+ ggml_float ggml_vec_log_soft_max_f32(const int n, float * y, const float * x, float max) {
242
+ // log(soft_max) = log(soft_max_i / soft_max_sum) = log(soft_max_i) - log(soft_max_sum) = (logit_i - max) - log(soft_max_i)
243
+
244
+ int i = 0;
245
+ ggml_float sum = 0;
246
+ for (; i < n; ++i) {
247
+ float val = x[i] - max;
248
+ y[i] = val;
249
+ sum += (ggml_float)expf(val);
250
+ }
251
+ return sum = (ggml_float)logf(sum);
252
+ }