@fugood/llama.node 0.6.3 → 1.0.0-beta.2

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 (377) hide show
  1. package/CMakeLists.txt +40 -30
  2. package/README.md +4 -1
  3. package/lib/binding.js +41 -29
  4. package/lib/binding.ts +26 -25
  5. package/package.json +40 -7
  6. package/scripts/build.js +47 -0
  7. package/scripts/llama.cpp.patch +109 -0
  8. package/src/anyascii.c +22223 -0
  9. package/src/anyascii.h +42 -0
  10. package/src/tts_utils.cpp +20 -7
  11. package/src/tts_utils.h +2 -0
  12. package/bin/darwin/arm64/llama-node.node +0 -0
  13. package/bin/darwin/x64/llama-node.node +0 -0
  14. package/bin/linux/arm64/llama-node.node +0 -0
  15. package/bin/linux/x64/llama-node.node +0 -0
  16. package/bin/linux-cuda/arm64/llama-node.node +0 -0
  17. package/bin/linux-cuda/x64/llama-node.node +0 -0
  18. package/bin/linux-vulkan/arm64/llama-node.node +0 -0
  19. package/bin/linux-vulkan/x64/llama-node.node +0 -0
  20. package/bin/win32/x64/llama-node.node +0 -0
  21. package/bin/win32/x64/node.lib +0 -0
  22. package/bin/win32-vulkan/arm64/llama-node.node +0 -0
  23. package/bin/win32-vulkan/arm64/node.lib +0 -0
  24. package/bin/win32-vulkan/x64/llama-node.node +0 -0
  25. package/bin/win32-vulkan/x64/node.lib +0 -0
  26. package/src/llama.cpp/.github/workflows/build-linux-cross.yml +0 -233
  27. package/src/llama.cpp/.github/workflows/build.yml +0 -1078
  28. package/src/llama.cpp/.github/workflows/close-issue.yml +0 -28
  29. package/src/llama.cpp/.github/workflows/docker.yml +0 -178
  30. package/src/llama.cpp/.github/workflows/editorconfig.yml +0 -29
  31. package/src/llama.cpp/.github/workflows/gguf-publish.yml +0 -44
  32. package/src/llama.cpp/.github/workflows/labeler.yml +0 -17
  33. package/src/llama.cpp/.github/workflows/python-check-requirements.yml +0 -33
  34. package/src/llama.cpp/.github/workflows/python-lint.yml +0 -30
  35. package/src/llama.cpp/.github/workflows/python-type-check.yml +0 -40
  36. package/src/llama.cpp/.github/workflows/release.yml +0 -739
  37. package/src/llama.cpp/.github/workflows/server.yml +0 -237
  38. package/src/llama.cpp/.github/workflows/winget.yml +0 -42
  39. package/src/llama.cpp/cmake/arm64-apple-clang.cmake +0 -16
  40. package/src/llama.cpp/cmake/arm64-windows-llvm.cmake +0 -16
  41. package/src/llama.cpp/cmake/build-info.cmake +0 -64
  42. package/src/llama.cpp/cmake/common.cmake +0 -35
  43. package/src/llama.cpp/cmake/git-vars.cmake +0 -22
  44. package/src/llama.cpp/cmake/x64-windows-llvm.cmake +0 -5
  45. package/src/llama.cpp/common/build-info.cpp.in +0 -4
  46. package/src/llama.cpp/docs/build.md +0 -561
  47. package/src/llama.cpp/examples/CMakeLists.txt +0 -43
  48. package/src/llama.cpp/examples/batched/CMakeLists.txt +0 -5
  49. package/src/llama.cpp/examples/batched/batched.cpp +0 -246
  50. package/src/llama.cpp/examples/chat-13B.bat +0 -57
  51. package/src/llama.cpp/examples/convert-llama2c-to-ggml/CMakeLists.txt +0 -5
  52. package/src/llama.cpp/examples/convert-llama2c-to-ggml/convert-llama2c-to-ggml.cpp +0 -941
  53. package/src/llama.cpp/examples/deprecation-warning/deprecation-warning.cpp +0 -35
  54. package/src/llama.cpp/examples/embedding/CMakeLists.txt +0 -5
  55. package/src/llama.cpp/examples/embedding/embedding.cpp +0 -323
  56. package/src/llama.cpp/examples/eval-callback/CMakeLists.txt +0 -10
  57. package/src/llama.cpp/examples/eval-callback/eval-callback.cpp +0 -194
  58. package/src/llama.cpp/examples/gen-docs/CMakeLists.txt +0 -5
  59. package/src/llama.cpp/examples/gen-docs/gen-docs.cpp +0 -83
  60. package/src/llama.cpp/examples/gguf/CMakeLists.txt +0 -5
  61. package/src/llama.cpp/examples/gguf/gguf.cpp +0 -265
  62. package/src/llama.cpp/examples/gguf-hash/CMakeLists.txt +0 -22
  63. package/src/llama.cpp/examples/gguf-hash/deps/rotate-bits/rotate-bits.h +0 -46
  64. package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.c +0 -295
  65. package/src/llama.cpp/examples/gguf-hash/deps/sha1/sha1.h +0 -52
  66. package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.c +0 -221
  67. package/src/llama.cpp/examples/gguf-hash/deps/sha256/sha256.h +0 -24
  68. package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.c +0 -42
  69. package/src/llama.cpp/examples/gguf-hash/deps/xxhash/xxhash.h +0 -7093
  70. package/src/llama.cpp/examples/gguf-hash/gguf-hash.cpp +0 -694
  71. package/src/llama.cpp/examples/gritlm/CMakeLists.txt +0 -5
  72. package/src/llama.cpp/examples/gritlm/gritlm.cpp +0 -229
  73. package/src/llama.cpp/examples/jeopardy/questions.txt +0 -100
  74. package/src/llama.cpp/examples/llama.android/app/build.gradle.kts +0 -65
  75. package/src/llama.cpp/examples/llama.android/build.gradle.kts +0 -6
  76. package/src/llama.cpp/examples/llama.android/llama/build.gradle.kts +0 -71
  77. package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/CMakeLists.txt +0 -53
  78. package/src/llama.cpp/examples/llama.android/llama/src/main/cpp/llama-android.cpp +0 -452
  79. package/src/llama.cpp/examples/llama.android/settings.gradle.kts +0 -18
  80. package/src/llama.cpp/examples/lookahead/CMakeLists.txt +0 -5
  81. package/src/llama.cpp/examples/lookahead/lookahead.cpp +0 -472
  82. package/src/llama.cpp/examples/lookup/CMakeLists.txt +0 -23
  83. package/src/llama.cpp/examples/lookup/lookup-create.cpp +0 -40
  84. package/src/llama.cpp/examples/lookup/lookup-merge.cpp +0 -47
  85. package/src/llama.cpp/examples/lookup/lookup-stats.cpp +0 -157
  86. package/src/llama.cpp/examples/lookup/lookup.cpp +0 -242
  87. package/src/llama.cpp/examples/parallel/CMakeLists.txt +0 -5
  88. package/src/llama.cpp/examples/parallel/parallel.cpp +0 -492
  89. package/src/llama.cpp/examples/passkey/CMakeLists.txt +0 -5
  90. package/src/llama.cpp/examples/passkey/passkey.cpp +0 -277
  91. package/src/llama.cpp/examples/retrieval/CMakeLists.txt +0 -5
  92. package/src/llama.cpp/examples/retrieval/retrieval.cpp +0 -304
  93. package/src/llama.cpp/examples/save-load-state/CMakeLists.txt +0 -5
  94. package/src/llama.cpp/examples/save-load-state/save-load-state.cpp +0 -246
  95. package/src/llama.cpp/examples/simple/CMakeLists.txt +0 -5
  96. package/src/llama.cpp/examples/simple/simple.cpp +0 -206
  97. package/src/llama.cpp/examples/simple-chat/CMakeLists.txt +0 -5
  98. package/src/llama.cpp/examples/simple-chat/simple-chat.cpp +0 -206
  99. package/src/llama.cpp/examples/simple-cmake-pkg/CMakeLists.txt +0 -11
  100. package/src/llama.cpp/examples/speculative/CMakeLists.txt +0 -5
  101. package/src/llama.cpp/examples/speculative/speculative.cpp +0 -644
  102. package/src/llama.cpp/examples/speculative-simple/CMakeLists.txt +0 -5
  103. package/src/llama.cpp/examples/speculative-simple/speculative-simple.cpp +0 -261
  104. package/src/llama.cpp/examples/sycl/CMakeLists.txt +0 -9
  105. package/src/llama.cpp/examples/sycl/build.sh +0 -23
  106. package/src/llama.cpp/examples/sycl/ls-sycl-device.cpp +0 -13
  107. package/src/llama.cpp/examples/sycl/run-llama2.sh +0 -27
  108. package/src/llama.cpp/examples/sycl/run-llama3.sh +0 -28
  109. package/src/llama.cpp/examples/sycl/win-build-sycl.bat +0 -33
  110. package/src/llama.cpp/examples/sycl/win-run-llama2.bat +0 -9
  111. package/src/llama.cpp/examples/sycl/win-run-llama3.bat +0 -9
  112. package/src/llama.cpp/examples/training/CMakeLists.txt +0 -5
  113. package/src/llama.cpp/examples/training/finetune.cpp +0 -96
  114. package/src/llama.cpp/ggml/cmake/GitVars.cmake +0 -22
  115. package/src/llama.cpp/ggml/cmake/common.cmake +0 -26
  116. package/src/llama.cpp/ggml/src/ggml-alloc.c +0 -1042
  117. package/src/llama.cpp/ggml/src/ggml-backend-impl.h +0 -255
  118. package/src/llama.cpp/ggml/src/ggml-backend-reg.cpp +0 -586
  119. package/src/llama.cpp/ggml/src/ggml-backend.cpp +0 -2008
  120. package/src/llama.cpp/ggml/src/ggml-blas/CMakeLists.txt +0 -87
  121. package/src/llama.cpp/ggml/src/ggml-blas/ggml-blas.cpp +0 -517
  122. package/src/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +0 -74
  123. package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.cpp +0 -179
  124. package/src/llama.cpp/ggml/src/ggml-cann/acl_tensor.h +0 -258
  125. package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +0 -2863
  126. package/src/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +0 -1110
  127. package/src/llama.cpp/ggml/src/ggml-cann/common.h +0 -420
  128. package/src/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +0 -2570
  129. package/src/llama.cpp/ggml/src/ggml-common.h +0 -1857
  130. package/src/llama.cpp/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +0 -100
  131. package/src/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +0 -184
  132. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/cuda.h +0 -15
  133. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +0 -243
  134. package/src/llama.cpp/ggml/src/ggml-cuda/vendors/musa.h +0 -140
  135. package/src/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +0 -131
  136. package/src/llama.cpp/ggml/src/ggml-impl.h +0 -601
  137. package/src/llama.cpp/ggml/src/ggml-kompute/CMakeLists.txt +0 -166
  138. package/src/llama.cpp/ggml/src/ggml-kompute/ggml-kompute.cpp +0 -2251
  139. package/src/llama.cpp/ggml/src/ggml-metal/CMakeLists.txt +0 -120
  140. package/src/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +0 -622
  141. package/src/llama.cpp/ggml/src/ggml-musa/CMakeLists.txt +0 -113
  142. package/src/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +0 -96
  143. package/src/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +0 -5124
  144. package/src/llama.cpp/ggml/src/ggml-opt.cpp +0 -1037
  145. package/src/llama.cpp/ggml/src/ggml-quants.c +0 -5232
  146. package/src/llama.cpp/ggml/src/ggml-quants.h +0 -100
  147. package/src/llama.cpp/ggml/src/ggml-rpc/CMakeLists.txt +0 -9
  148. package/src/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +0 -1813
  149. package/src/llama.cpp/ggml/src/ggml-sycl/CMakeLists.txt +0 -189
  150. package/src/llama.cpp/ggml/src/ggml-sycl/backend.hpp +0 -37
  151. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +0 -239
  152. package/src/llama.cpp/ggml/src/ggml-sycl/binbcast.hpp +0 -39
  153. package/src/llama.cpp/ggml/src/ggml-sycl/common.cpp +0 -83
  154. package/src/llama.cpp/ggml/src/ggml-sycl/common.hpp +0 -493
  155. package/src/llama.cpp/ggml/src/ggml-sycl/concat.cpp +0 -197
  156. package/src/llama.cpp/ggml/src/ggml-sycl/concat.hpp +0 -20
  157. package/src/llama.cpp/ggml/src/ggml-sycl/conv.cpp +0 -100
  158. package/src/llama.cpp/ggml/src/ggml-sycl/conv.hpp +0 -20
  159. package/src/llama.cpp/ggml/src/ggml-sycl/convert.cpp +0 -623
  160. package/src/llama.cpp/ggml/src/ggml-sycl/convert.hpp +0 -34
  161. package/src/llama.cpp/ggml/src/ggml-sycl/cpy.cpp +0 -701
  162. package/src/llama.cpp/ggml/src/ggml-sycl/cpy.hpp +0 -11
  163. package/src/llama.cpp/ggml/src/ggml-sycl/dequantize.hpp +0 -791
  164. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +0 -1160
  165. package/src/llama.cpp/ggml/src/ggml-sycl/dmmv.hpp +0 -27
  166. package/src/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +0 -2957
  167. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +0 -1536
  168. package/src/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +0 -75
  169. package/src/llama.cpp/ggml/src/ggml-sycl/gemm.hpp +0 -99
  170. package/src/llama.cpp/ggml/src/ggml-sycl/getrows.cpp +0 -311
  171. package/src/llama.cpp/ggml/src/ggml-sycl/getrows.hpp +0 -20
  172. package/src/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +0 -4443
  173. package/src/llama.cpp/ggml/src/ggml-sycl/gla.cpp +0 -105
  174. package/src/llama.cpp/ggml/src/ggml-sycl/gla.hpp +0 -8
  175. package/src/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +0 -136
  176. package/src/llama.cpp/ggml/src/ggml-sycl/im2col.hpp +0 -21
  177. package/src/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +0 -3030
  178. package/src/llama.cpp/ggml/src/ggml-sycl/mmq.hpp +0 -33
  179. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +0 -1108
  180. package/src/llama.cpp/ggml/src/ggml-sycl/mmvq.hpp +0 -27
  181. package/src/llama.cpp/ggml/src/ggml-sycl/norm.cpp +0 -474
  182. package/src/llama.cpp/ggml/src/ggml-sycl/norm.hpp +0 -26
  183. package/src/llama.cpp/ggml/src/ggml-sycl/outprod.cpp +0 -46
  184. package/src/llama.cpp/ggml/src/ggml-sycl/outprod.hpp +0 -10
  185. package/src/llama.cpp/ggml/src/ggml-sycl/presets.hpp +0 -74
  186. package/src/llama.cpp/ggml/src/ggml-sycl/quants.hpp +0 -83
  187. package/src/llama.cpp/ggml/src/ggml-sycl/rope.cpp +0 -362
  188. package/src/llama.cpp/ggml/src/ggml-sycl/rope.hpp +0 -20
  189. package/src/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +0 -264
  190. package/src/llama.cpp/ggml/src/ggml-sycl/softmax.hpp +0 -20
  191. package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.cpp +0 -13
  192. package/src/llama.cpp/ggml/src/ggml-sycl/sycl_hw.hpp +0 -23
  193. package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.cpp +0 -73
  194. package/src/llama.cpp/ggml/src/ggml-sycl/tsembd.hpp +0 -20
  195. package/src/llama.cpp/ggml/src/ggml-sycl/vecdotq.hpp +0 -1215
  196. package/src/llama.cpp/ggml/src/ggml-sycl/wkv.cpp +0 -305
  197. package/src/llama.cpp/ggml/src/ggml-sycl/wkv.hpp +0 -10
  198. package/src/llama.cpp/ggml/src/ggml-threading.cpp +0 -12
  199. package/src/llama.cpp/ggml/src/ggml-threading.h +0 -14
  200. package/src/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +0 -196
  201. package/src/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +0 -10699
  202. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +0 -39
  203. package/src/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +0 -751
  204. package/src/llama.cpp/ggml/src/ggml.c +0 -6550
  205. package/src/llama.cpp/ggml/src/gguf.cpp +0 -1330
  206. package/src/llama.cpp/models/.editorconfig +0 -1
  207. package/src/llama.cpp/models/ggml-vocab-aquila.gguf +0 -0
  208. package/src/llama.cpp/models/ggml-vocab-baichuan.gguf +0 -0
  209. package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf +0 -0
  210. package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.inp +0 -112
  211. package/src/llama.cpp/models/ggml-vocab-bert-bge.gguf.out +0 -46
  212. package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.inp +0 -112
  213. package/src/llama.cpp/models/ggml-vocab-chameleon.gguf.out +0 -46
  214. package/src/llama.cpp/models/ggml-vocab-command-r.gguf +0 -0
  215. package/src/llama.cpp/models/ggml-vocab-command-r.gguf.inp +0 -112
  216. package/src/llama.cpp/models/ggml-vocab-command-r.gguf.out +0 -46
  217. package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf +0 -0
  218. package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.inp +0 -112
  219. package/src/llama.cpp/models/ggml-vocab-deepseek-coder.gguf.out +0 -46
  220. package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf +0 -0
  221. package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.inp +0 -112
  222. package/src/llama.cpp/models/ggml-vocab-deepseek-llm.gguf.out +0 -46
  223. package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.inp +0 -112
  224. package/src/llama.cpp/models/ggml-vocab-deepseek-r1-qwen.gguf.out +0 -46
  225. package/src/llama.cpp/models/ggml-vocab-falcon.gguf +0 -0
  226. package/src/llama.cpp/models/ggml-vocab-falcon.gguf.inp +0 -112
  227. package/src/llama.cpp/models/ggml-vocab-falcon.gguf.out +0 -46
  228. package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf +0 -0
  229. package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.inp +0 -112
  230. package/src/llama.cpp/models/ggml-vocab-gpt-2.gguf.out +0 -46
  231. package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.inp +0 -112
  232. package/src/llama.cpp/models/ggml-vocab-gpt-4o.gguf.out +0 -46
  233. package/src/llama.cpp/models/ggml-vocab-gpt-neox.gguf +0 -0
  234. package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf +0 -0
  235. package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.inp +0 -112
  236. package/src/llama.cpp/models/ggml-vocab-llama-bpe.gguf.out +0 -46
  237. package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf +0 -0
  238. package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.inp +0 -112
  239. package/src/llama.cpp/models/ggml-vocab-llama-spm.gguf.out +0 -46
  240. package/src/llama.cpp/models/ggml-vocab-llama4.gguf.inp +0 -112
  241. package/src/llama.cpp/models/ggml-vocab-llama4.gguf.out +0 -46
  242. package/src/llama.cpp/models/ggml-vocab-mpt.gguf +0 -0
  243. package/src/llama.cpp/models/ggml-vocab-mpt.gguf.inp +0 -112
  244. package/src/llama.cpp/models/ggml-vocab-mpt.gguf.out +0 -46
  245. package/src/llama.cpp/models/ggml-vocab-phi-3.gguf +0 -0
  246. package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.inp +0 -112
  247. package/src/llama.cpp/models/ggml-vocab-phi-3.gguf.out +0 -46
  248. package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.inp +0 -112
  249. package/src/llama.cpp/models/ggml-vocab-pixtral.gguf.out +0 -46
  250. package/src/llama.cpp/models/ggml-vocab-qwen2.gguf +0 -0
  251. package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.inp +0 -112
  252. package/src/llama.cpp/models/ggml-vocab-qwen2.gguf.out +0 -46
  253. package/src/llama.cpp/models/ggml-vocab-refact.gguf +0 -0
  254. package/src/llama.cpp/models/ggml-vocab-refact.gguf.inp +0 -112
  255. package/src/llama.cpp/models/ggml-vocab-refact.gguf.out +0 -46
  256. package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.inp +0 -112
  257. package/src/llama.cpp/models/ggml-vocab-roberta-bpe.gguf.out +0 -46
  258. package/src/llama.cpp/models/ggml-vocab-starcoder.gguf +0 -0
  259. package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.inp +0 -112
  260. package/src/llama.cpp/models/ggml-vocab-starcoder.gguf.out +0 -46
  261. package/src/llama.cpp/pocs/CMakeLists.txt +0 -14
  262. package/src/llama.cpp/pocs/vdot/CMakeLists.txt +0 -9
  263. package/src/llama.cpp/pocs/vdot/q8dot.cpp +0 -173
  264. package/src/llama.cpp/pocs/vdot/vdot.cpp +0 -311
  265. package/src/llama.cpp/prompts/LLM-questions.txt +0 -49
  266. package/src/llama.cpp/prompts/alpaca.txt +0 -1
  267. package/src/llama.cpp/prompts/assistant.txt +0 -31
  268. package/src/llama.cpp/prompts/chat-with-baichuan.txt +0 -4
  269. package/src/llama.cpp/prompts/chat-with-bob.txt +0 -7
  270. package/src/llama.cpp/prompts/chat-with-qwen.txt +0 -1
  271. package/src/llama.cpp/prompts/chat-with-vicuna-v0.txt +0 -7
  272. package/src/llama.cpp/prompts/chat-with-vicuna-v1.txt +0 -7
  273. package/src/llama.cpp/prompts/chat.txt +0 -28
  274. package/src/llama.cpp/prompts/dan-modified.txt +0 -1
  275. package/src/llama.cpp/prompts/dan.txt +0 -1
  276. package/src/llama.cpp/prompts/mnemonics.txt +0 -93
  277. package/src/llama.cpp/prompts/parallel-questions.txt +0 -43
  278. package/src/llama.cpp/prompts/reason-act.txt +0 -18
  279. package/src/llama.cpp/requirements/requirements-all.txt +0 -15
  280. package/src/llama.cpp/requirements/requirements-compare-llama-bench.txt +0 -2
  281. package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +0 -7
  282. package/src/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +0 -7
  283. package/src/llama.cpp/requirements/requirements-convert_legacy_llama.txt +0 -5
  284. package/src/llama.cpp/requirements/requirements-convert_llama_ggml_to_gguf.txt +0 -1
  285. package/src/llama.cpp/requirements/requirements-convert_lora_to_gguf.txt +0 -4
  286. package/src/llama.cpp/requirements/requirements-gguf_editor_gui.txt +0 -3
  287. package/src/llama.cpp/requirements/requirements-pydantic.txt +0 -3
  288. package/src/llama.cpp/requirements/requirements-test-tokenizer-random.txt +0 -1
  289. package/src/llama.cpp/requirements/requirements-tool_bench.txt +0 -12
  290. package/src/llama.cpp/requirements.txt +0 -13
  291. package/src/llama.cpp/scripts/build-info.sh +0 -30
  292. package/src/llama.cpp/scripts/install-oneapi.bat +0 -19
  293. package/src/llama.cpp/scripts/xxd.cmake +0 -16
  294. package/src/llama.cpp/tests/CMakeLists.txt +0 -177
  295. package/src/llama.cpp/tests/get-model.cpp +0 -21
  296. package/src/llama.cpp/tests/get-model.h +0 -2
  297. package/src/llama.cpp/tests/test-arg-parser.cpp +0 -178
  298. package/src/llama.cpp/tests/test-autorelease.cpp +0 -24
  299. package/src/llama.cpp/tests/test-backend-ops.cpp +0 -4793
  300. package/src/llama.cpp/tests/test-barrier.cpp +0 -94
  301. package/src/llama.cpp/tests/test-c.c +0 -7
  302. package/src/llama.cpp/tests/test-chat-template.cpp +0 -417
  303. package/src/llama.cpp/tests/test-chat.cpp +0 -985
  304. package/src/llama.cpp/tests/test-double-float.cpp +0 -57
  305. package/src/llama.cpp/tests/test-gbnf-validator.cpp +0 -109
  306. package/src/llama.cpp/tests/test-gguf.cpp +0 -1338
  307. package/src/llama.cpp/tests/test-grammar-integration.cpp +0 -1308
  308. package/src/llama.cpp/tests/test-grammar-llguidance.cpp +0 -1201
  309. package/src/llama.cpp/tests/test-grammar-parser.cpp +0 -519
  310. package/src/llama.cpp/tests/test-json-schema-to-grammar.cpp +0 -1304
  311. package/src/llama.cpp/tests/test-llama-grammar.cpp +0 -408
  312. package/src/llama.cpp/tests/test-log.cpp +0 -39
  313. package/src/llama.cpp/tests/test-model-load-cancel.cpp +0 -27
  314. package/src/llama.cpp/tests/test-mtmd-c-api.c +0 -63
  315. package/src/llama.cpp/tests/test-opt.cpp +0 -904
  316. package/src/llama.cpp/tests/test-quantize-fns.cpp +0 -186
  317. package/src/llama.cpp/tests/test-quantize-perf.cpp +0 -365
  318. package/src/llama.cpp/tests/test-quantize-stats.cpp +0 -424
  319. package/src/llama.cpp/tests/test-regex-partial.cpp +0 -288
  320. package/src/llama.cpp/tests/test-rope.cpp +0 -262
  321. package/src/llama.cpp/tests/test-sampling.cpp +0 -399
  322. package/src/llama.cpp/tests/test-tokenizer-0.cpp +0 -312
  323. package/src/llama.cpp/tests/test-tokenizer-1-bpe.cpp +0 -155
  324. package/src/llama.cpp/tests/test-tokenizer-1-spm.cpp +0 -125
  325. package/src/llama.cpp/tools/CMakeLists.txt +0 -39
  326. package/src/llama.cpp/tools/batched-bench/CMakeLists.txt +0 -5
  327. package/src/llama.cpp/tools/batched-bench/batched-bench.cpp +0 -204
  328. package/src/llama.cpp/tools/cvector-generator/CMakeLists.txt +0 -5
  329. package/src/llama.cpp/tools/cvector-generator/completions.txt +0 -582
  330. package/src/llama.cpp/tools/cvector-generator/cvector-generator.cpp +0 -508
  331. package/src/llama.cpp/tools/cvector-generator/mean.hpp +0 -48
  332. package/src/llama.cpp/tools/cvector-generator/negative.txt +0 -4
  333. package/src/llama.cpp/tools/cvector-generator/pca.hpp +0 -315
  334. package/src/llama.cpp/tools/cvector-generator/positive.txt +0 -4
  335. package/src/llama.cpp/tools/export-lora/CMakeLists.txt +0 -5
  336. package/src/llama.cpp/tools/export-lora/export-lora.cpp +0 -434
  337. package/src/llama.cpp/tools/gguf-split/CMakeLists.txt +0 -5
  338. package/src/llama.cpp/tools/gguf-split/gguf-split.cpp +0 -583
  339. package/src/llama.cpp/tools/imatrix/CMakeLists.txt +0 -5
  340. package/src/llama.cpp/tools/imatrix/imatrix.cpp +0 -667
  341. package/src/llama.cpp/tools/llama-bench/CMakeLists.txt +0 -5
  342. package/src/llama.cpp/tools/llama-bench/llama-bench.cpp +0 -2024
  343. package/src/llama.cpp/tools/main/CMakeLists.txt +0 -5
  344. package/src/llama.cpp/tools/main/main.cpp +0 -977
  345. package/src/llama.cpp/tools/mtmd/CMakeLists.txt +0 -58
  346. package/src/llama.cpp/tools/mtmd/clip-impl.h +0 -462
  347. package/src/llama.cpp/tools/mtmd/clip.cpp +0 -4024
  348. package/src/llama.cpp/tools/mtmd/clip.h +0 -101
  349. package/src/llama.cpp/tools/mtmd/deprecation-warning.cpp +0 -22
  350. package/src/llama.cpp/tools/mtmd/miniaudio.h +0 -93468
  351. package/src/llama.cpp/tools/mtmd/mtmd-audio.cpp +0 -855
  352. package/src/llama.cpp/tools/mtmd/mtmd-audio.h +0 -62
  353. package/src/llama.cpp/tools/mtmd/mtmd-cli.cpp +0 -377
  354. package/src/llama.cpp/tools/mtmd/mtmd-helper.cpp +0 -297
  355. package/src/llama.cpp/tools/mtmd/mtmd.cpp +0 -942
  356. package/src/llama.cpp/tools/mtmd/mtmd.h +0 -362
  357. package/src/llama.cpp/tools/mtmd/requirements.txt +0 -5
  358. package/src/llama.cpp/tools/perplexity/CMakeLists.txt +0 -5
  359. package/src/llama.cpp/tools/perplexity/perplexity.cpp +0 -2063
  360. package/src/llama.cpp/tools/quantize/CMakeLists.txt +0 -6
  361. package/src/llama.cpp/tools/quantize/quantize.cpp +0 -519
  362. package/src/llama.cpp/tools/rpc/CMakeLists.txt +0 -4
  363. package/src/llama.cpp/tools/rpc/rpc-server.cpp +0 -322
  364. package/src/llama.cpp/tools/run/CMakeLists.txt +0 -16
  365. package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.cpp +0 -1995
  366. package/src/llama.cpp/tools/run/linenoise.cpp/linenoise.h +0 -137
  367. package/src/llama.cpp/tools/run/run.cpp +0 -1261
  368. package/src/llama.cpp/tools/server/CMakeLists.txt +0 -51
  369. package/src/llama.cpp/tools/server/bench/requirements.txt +0 -2
  370. package/src/llama.cpp/tools/server/httplib.h +0 -10506
  371. package/src/llama.cpp/tools/server/server.cpp +0 -4966
  372. package/src/llama.cpp/tools/server/tests/requirements.txt +0 -8
  373. package/src/llama.cpp/tools/server/utils.hpp +0 -1337
  374. package/src/llama.cpp/tools/tokenize/CMakeLists.txt +0 -5
  375. package/src/llama.cpp/tools/tokenize/tokenize.cpp +0 -416
  376. package/src/llama.cpp/tools/tts/CMakeLists.txt +0 -5
  377. package/src/llama.cpp/tools/tts/tts.cpp +0 -1092
@@ -1,288 +0,0 @@
1
- // Tests common_regex (esp. its partial final matches support).
2
-
3
- #include "common.h"
4
- #include "regex-partial.h"
5
-
6
- #include <sstream>
7
- #include <iostream>
8
- #include <optional>
9
-
10
- template <class T> static void assert_equals(const T & expected, const T & actual) {
11
- if (expected != actual) {
12
- std::cerr << "Expected: " << expected << std::endl;
13
- std::cerr << " Actual: " << actual << std::endl;
14
- std::cerr << std::flush;
15
- throw std::runtime_error("Test failed");
16
- }
17
- }
18
-
19
- struct test_case {
20
- std::string pattern;
21
- struct input_output {
22
- std::string input;
23
- common_regex_match output;
24
- };
25
- std::vector<input_output> inputs_outputs;
26
- };
27
-
28
- static std::string common_regex_match_type_name(common_regex_match_type type) {
29
- switch (type) {
30
- case COMMON_REGEX_MATCH_TYPE_NONE:
31
- return "COMMON_REGEX_MATCH_TYPE_NONE";
32
- case COMMON_REGEX_MATCH_TYPE_PARTIAL:
33
- return "COMMON_REGEX_MATCH_TYPE_PARTIAL";
34
- case COMMON_REGEX_MATCH_TYPE_FULL:
35
- return "COMMON_REGEX_MATCH_TYPE_FULL";
36
- }
37
- return "?";
38
- }
39
-
40
- static void test_regex() {
41
- printf("[%s]\n", __func__);
42
- auto test = [](const test_case & test_case) {
43
- common_regex cr(test_case.pattern);
44
- std::cout << "Testing pattern: /" << test_case.pattern << "/\n";
45
- // std::cout << " partial rev: " << cr.reversed_partial_pattern.str() << '\n';
46
- for (const auto & input_output : test_case.inputs_outputs) {
47
- std::cout << " Input: " << input_output.input << '\n';
48
- auto m = cr.search(input_output.input, 0);
49
- if (m != input_output.output) {
50
- auto match_to_str = [&](const std::optional<common_regex_match> & m) {
51
- std::ostringstream ss;
52
- if (m->type == COMMON_REGEX_MATCH_TYPE_NONE) {
53
- ss << "<no match>";
54
- } else {
55
- GGML_ASSERT(!input_output.output.groups.empty());
56
- std::vector<std::string> parts;
57
- for (const auto & g : m->groups) {
58
- parts.push_back("{" + std::to_string(g.begin) + ", " + std::to_string(g.end) + "}");
59
- }
60
- ss << "{" << common_regex_match_type_name(m->type) << ", {" << string_join(parts, ", ") << "}}";
61
- }
62
- return ss.str();
63
- };
64
- std::cout << " Expected: " << match_to_str(input_output.output) << '\n';
65
- std::cout << " Got: " << match_to_str(m) << '\n';
66
- std::cout << " Inverted pattern: /" << regex_to_reversed_partial_regex(test_case.pattern) << "/\n";
67
-
68
- throw std::runtime_error("Test failed");
69
- }
70
- }
71
- };
72
- test({
73
- "a",
74
- {
75
- {"a", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 1}}}},
76
- {"b", {COMMON_REGEX_MATCH_TYPE_NONE, {}}},
77
- {"ab", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 1}}}},
78
- {"ba", {COMMON_REGEX_MATCH_TYPE_FULL, {{1, 2}}}},
79
- }
80
- });
81
- test({
82
- "abcd",
83
- {
84
- {"abcd", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 4}}}},
85
- {"abcde", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 4}}}},
86
- {"abc", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 3}}}},
87
- {"ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 2}}}},
88
- {"a", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 1}}}},
89
- {"d", {}},
90
- {"bcd", {}},
91
- {"cde", {}},
92
- {"cd", {}},
93
- {"yeah ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{5, 7}}}},
94
- {"abbie", {}},
95
- {"", {}},
96
- }
97
- });
98
- test({
99
- ".*?ab",
100
- {
101
- {"ab", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 2}}}},
102
- {"abc", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 2}}}},
103
- {"dab", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 3}}}},
104
- {"dabc", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 3}}}},
105
- {"da", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 2}}}},
106
- {"d", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 1}}}},
107
- }
108
- });
109
- test({
110
- "a.*?b",
111
- {
112
- {"ab", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 2}}}},
113
- {"abc", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 2}}}},
114
- {"a b", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 3}}}},
115
- {"a", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 1}}}},
116
- {"argh", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 4}}}},
117
- {"d", {}},
118
- {"b", {}},
119
- }
120
- });
121
- test({
122
- "ab(?:cd){2,4}ef",
123
- {
124
- // {"ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, 0, {}}},
125
- {"ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 2}}}},
126
- {"abcd", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 4}}}},
127
- {"abcde", {}},
128
- {"abcdef", {}},
129
- {"abcdcd", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 6}}}},
130
- {"abcdcde", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 7}}}},
131
- {"abcdcdef", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 8}}}},
132
- {"abcdcdcdcdef", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 12}}}},
133
- {"abcdcdcdcdcdef", {}},
134
- {"abcde", {}},
135
- {"yea", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{2, 3}}}},
136
- }
137
- });
138
- test({
139
- "a(?:rte| pure )fact",
140
- {
141
- {"a", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 1}}}},
142
- {"art", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 3}}}},
143
- {"artefa", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 6}}}},
144
- {"fact", {}},
145
- {"an arte", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{3, 7}}}},
146
- {"artefact", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 8}}}},
147
- {"an artefact", {COMMON_REGEX_MATCH_TYPE_FULL, {{3, 11}}}},
148
- {"a pure", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 6}}}},
149
- {"a pure fact", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 11}}}},
150
- {"it's a pure fact", {COMMON_REGEX_MATCH_TYPE_FULL, {{5, 16}}}},
151
- {"" , {}},
152
- {"pure", {}},
153
- {"pure fact", {}},
154
- }
155
- });
156
- test({
157
- "abc",
158
- {
159
- {" abcc", {COMMON_REGEX_MATCH_TYPE_FULL, {{1, 4}}}},
160
- {"ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 2}}}},
161
- {"abc", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 3}}}},
162
- {" ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{1, 3}}}},
163
- {"a", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 1}}}},
164
- {"b", {}},
165
- {"c", {}},
166
- {"", {}},
167
- }
168
- });
169
-
170
- test({
171
- "(?:abc)?\\s*def",
172
- {
173
- {"ab", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 2}}}},
174
- {"abc", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 3}}}},
175
- {"abc ", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 4}}}},
176
- {"abc d", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 5}}}},
177
- {"abc de", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 6}}}},
178
- {"abc def", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 7}}}},
179
- {"abc defg", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 7}}}},
180
- {"abc defgh", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 7}}}},
181
- {"abcde", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 5}}}},
182
- {"abcdefgh", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 6}}}},
183
- {" d", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 2}}}},
184
- {"def", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 3}}}},
185
- }
186
- });
187
-
188
- test({
189
- "a+b",
190
- {
191
- {"aaab", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 4}}}},
192
- {"aaa", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 3}}}},
193
- {"ab", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 2}}}},
194
- }
195
- });
196
-
197
- test({
198
- "(?:"
199
- "(```(?:xml|json)?\\n\\s*)?" // match 1 (block_start)
200
- "(" // match 2 (open_tag)
201
- "<tool_call>"
202
- "|<function_call>"
203
- "|<tool>"
204
- "|<tools>"
205
- "|<response>"
206
- "|<json>"
207
- "|<xml>"
208
- "|<JSON>"
209
- ")?"
210
- "(\\s*\\{\\s*\"name\"\\s*:)" // match 3 (named tool call)
211
- ")"
212
- "|<function=([^>]+)>" // match 4 (function name)
213
- "|<function name=\"([^\"]+)\">", // match 5 (function name again)
214
- {
215
- {"{\"name\": \"special_function\", \"arguments\": {\"arg1\": 1}}", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 8}, {54, 54}, {54, 54}, {0, 8}, {54, 54}, {54, 54}}}},
216
- {"<tool_call> {\"name", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 18}}}},
217
- {"<tool_call>{\"name", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 17}}}},
218
- {"Let's call something\n<tool_call>{\"name", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{21, 38}}}},
219
- {"Ok then<tool_call>{\"name", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{7, 24}}}},
220
- {"{\"name", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{0, 6}}}},
221
- {"Ok then{\"name", {COMMON_REGEX_MATCH_TYPE_PARTIAL, {{7, 13}}}},
222
- {"<tool_call> {\"name\": \"special_function\", \"arguments\": {\"arg1\": 1}}", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 20}, {66, 66}, {0, 11}, {11, 20}, {66, 66}, {66, 66}}}},
223
- {"<function_call> {\"name\": \"special_function\", \"arguments\": {\"arg1\": 1}}", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 24}, {70, 70}, {0, 15}, {15, 24}, {70, 70}, {70, 70}}}},
224
- {"<function name=\"special_function\"> {\"name\": \"special_function\", \"arguments\": {\"arg1\": 1}}", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 34}, {89, 89}, {89, 89}, {89, 89}, {89, 89}, {16, 32}}}},
225
- {"<function=all>", {COMMON_REGEX_MATCH_TYPE_FULL, {{0, 14}, {14, 14}, {14, 14}, {14, 14}, {10, 13}, {14, 14}}}},
226
-
227
- }
228
- });
229
- }
230
-
231
- static void test_regex_to_reversed_partial_regex() {
232
- printf("[%s]\n", __func__);
233
-
234
- assert_equals<std::string>(
235
- "((?:(?:c)?b)?a)[\\s\\S]*",
236
- regex_to_reversed_partial_regex("abc"));
237
-
238
- assert_equals<std::string>(
239
- "(a+)[\\s\\S]*",
240
- regex_to_reversed_partial_regex("a+"));
241
-
242
- assert_equals<std::string>(
243
- "(a*)[\\s\\S]*",
244
- regex_to_reversed_partial_regex("a*"));
245
-
246
- assert_equals<std::string>(
247
- "(a?)[\\s\\S]*",
248
- regex_to_reversed_partial_regex("a?"));
249
-
250
- assert_equals<std::string>(
251
- "([a-z])[\\s\\S]*",
252
- regex_to_reversed_partial_regex("[a-z]"));
253
-
254
- assert_equals<std::string>(
255
- "((?:\\w+)?[a-z])[\\s\\S]*",
256
- regex_to_reversed_partial_regex("[a-z]\\w+"));
257
-
258
- assert_equals<std::string>(
259
- "((?:a|b))[\\s\\S]*",
260
- regex_to_reversed_partial_regex("(?:a|b)"));
261
- assert_equals<std::string>(
262
- "((?:(?:(?:d)?c)?b)?a)[\\s\\S]*",
263
- regex_to_reversed_partial_regex("abcd"));
264
- assert_equals<std::string>(
265
- "((?:b)?a*)[\\s\\S]*", // TODO: ((?:b)?a*+).* ??
266
- regex_to_reversed_partial_regex("a*b"));
267
- assert_equals<std::string>(
268
- "((?:(?:b)?a)?.*)[\\s\\S]*",
269
- regex_to_reversed_partial_regex(".*?ab"));
270
- assert_equals<std::string>(
271
- "((?:(?:b)?.*)?a)[\\s\\S]*",
272
- regex_to_reversed_partial_regex("a.*?b"));
273
- assert_equals<std::string>(
274
- "((?:(?:d)?(?:(?:c)?b))?a)[\\s\\S]*",
275
- regex_to_reversed_partial_regex("a(bc)d"));
276
- assert_equals<std::string>(
277
- "((?:(?:(?:c)?b|(?:e)?d))?a)[\\s\\S]*",
278
- regex_to_reversed_partial_regex("a(bc|de)"));
279
- assert_equals<std::string>(
280
- "((?:(?:(?:(?:(?:c)?b?)?b?)?b)?b)?a)[\\s\\S]*",
281
- regex_to_reversed_partial_regex("ab{2,4}c"));
282
- }
283
-
284
- int main() {
285
- test_regex_to_reversed_partial_regex();
286
- test_regex();
287
- std::cout << "All tests passed.\n";
288
- }
@@ -1,262 +0,0 @@
1
- #include "ggml.h"
2
- #include "ggml-cpu.h"
3
-
4
- #include <cmath>
5
- #include <cstdio>
6
- #include <cstdlib>
7
- #include <cassert>
8
- #include <vector>
9
-
10
- #if defined(_MSC_VER)
11
- #pragma warning(disable: 4244 4267) // possible loss of data
12
- #endif
13
-
14
- #if defined(__GNUC__)
15
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
16
- #endif
17
-
18
- #define MAX_NARGS 3
19
-
20
- #undef MIN
21
- #undef MAX
22
- #define MIN(a, b) ((a) < (b) ? (a) : (b))
23
- #define MAX(a, b) ((a) > (b) ? (a) : (b))
24
-
25
- #define GGML_SILU_FP16
26
-
27
- //
28
- // logging
29
- //
30
-
31
- #if (GGML_DEBUG >= 1)
32
- #define GGML_PRINT_DEBUG(...) printf(__VA_ARGS__)
33
- #else
34
- #define GGML_PRINT_DEBUG(...)
35
- #endif
36
-
37
- #if (GGML_DEBUG >= 5)
38
- #define GGML_PRINT_DEBUG_5(...) printf(__VA_ARGS__)
39
- #else
40
- #define GGML_PRINT_DEBUG_5(...)
41
- #endif
42
-
43
- #if (GGML_DEBUG >= 10)
44
- #define GGML_PRINT_DEBUG_10(...) printf(__VA_ARGS__)
45
- #else
46
- #define GGML_PRINT_DEBUG_10(...)
47
- #endif
48
-
49
- #define GGML_PRINT(...) printf(__VA_ARGS__)
50
-
51
- static float frand(void) {
52
- return (float)rand()/(float)RAND_MAX;
53
- }
54
-
55
- static int irand(int n) {
56
- if (n == 0) return 0;
57
- return rand()%n;
58
- }
59
-
60
- static void get_random_dims(int64_t * dims, int ndims) {
61
- dims[0] = dims[1] = dims[2] = dims[3] = 1;
62
-
63
- for (int i = 0; i < ndims; i++) {
64
- dims[i] = 1 + irand(4);
65
- }
66
- }
67
-
68
- static struct ggml_tensor * get_random_tensor_f32(
69
- struct ggml_context * ctx0,
70
- int ndims,
71
- const int64_t ne[],
72
- float fmin,
73
- float fmax) {
74
- struct ggml_tensor * result = ggml_new_tensor(ctx0, GGML_TYPE_F32, ndims, ne);
75
-
76
- switch (ndims) {
77
- case 1:
78
- for (int i0 = 0; i0 < ne[0]; i0++) {
79
- ((float *)result->data)[i0] = frand()*(fmax - fmin) + fmin;
80
- }
81
- break;
82
- case 2:
83
- for (int i1 = 0; i1 < ne[1]; i1++) {
84
- for (int i0 = 0; i0 < ne[0]; i0++) {
85
- ((float *)result->data)[i1*ne[0] + i0] = frand()*(fmax - fmin) + fmin;
86
- }
87
- }
88
- break;
89
- case 3:
90
- for (int i2 = 0; i2 < ne[2]; i2++) {
91
- for (int i1 = 0; i1 < ne[1]; i1++) {
92
- for (int i0 = 0; i0 < ne[0]; i0++) {
93
- ((float *)result->data)[i2*ne[1]*ne[0] + i1*ne[0] + i0] = frand()*(fmax - fmin) + fmin;
94
- }
95
- }
96
- }
97
- break;
98
- case 4:
99
- for (int i3 = 0; i3 < ne[3]; i3++) {
100
- for (int i2 = 0; i2 < ne[2]; i2++) {
101
- for (int i1 = 0; i1 < ne[1]; i1++) {
102
- for (int i0 = 0; i0 < ne[0]; i0++) {
103
- ((float *)result->data)[i3*ne[2]*ne[1]*ne[0] + i2*ne[1]*ne[0] + i1*ne[0] + i0] = frand()*(fmax - fmin) + fmin;
104
- }
105
- }
106
- }
107
- }
108
- break;
109
- default:
110
- assert(false);
111
- };
112
-
113
- return result;
114
- }
115
-
116
- static void ggml_graph_compute_helper(std::vector<uint8_t> & buf, ggml_cgraph * graph, int n_threads) {
117
- struct ggml_cplan plan = ggml_graph_plan(graph, n_threads, nullptr);
118
-
119
- if (plan.work_size > 0) {
120
- buf.resize(plan.work_size);
121
- plan.work_data = buf.data();
122
- }
123
-
124
- ggml_graph_compute(graph, &plan);
125
- }
126
-
127
- int main(int /*argc*/, const char ** /*argv*/) {
128
- struct ggml_init_params params = {
129
- /* .mem_size = */ 128*1024*1024,
130
- /* .mem_buffer = */ NULL,
131
- /* .no_alloc = */ false,
132
- };
133
-
134
- std::vector<uint8_t> work_buffer;
135
-
136
- struct ggml_context * ctx0 = ggml_init(params);
137
-
138
- struct ggml_tensor * x;
139
-
140
- // rope f32
141
- for (int m = 0; m < 5; ++m) {
142
- const int ndims = 4;
143
-
144
- const int64_t n_rot = 128;
145
- const int64_t ne[4] = { 2*n_rot, 32, 73, 1 };
146
-
147
- const int n_past_0 = 100;
148
- const int n_past_2 = 33;
149
-
150
- struct ggml_tensor * r0;
151
- struct ggml_tensor * r1;
152
- struct ggml_tensor * r2;
153
- x = get_random_tensor_f32(ctx0, ndims, ne, -1.0f, 1.0f);
154
- int mode = -1;
155
-
156
- if (m < 3) {
157
- struct ggml_tensor * p0 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2]);
158
- struct ggml_tensor * p1 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2]);
159
- struct ggml_tensor * p2 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2]);
160
-
161
- for (int i = 0; i < ne[2]; ++i) {
162
- ((int32_t *) p0->data)[i] = n_past_0 + i;
163
- ((int32_t *) p1->data)[i] = n_past_2 - n_past_0;
164
- ((int32_t *) p2->data)[i] = n_past_2 + i;
165
- }
166
- // test mode 0, 2, 4 (standard, GPT-NeoX, GLM)
167
- mode = m == 0 ? 0 : m == 1 ? 2 : 4;
168
-
169
- // 100, 101, 102, ..., 172
170
- r0 = ggml_rope(ctx0, x, p0, n_rot, mode);
171
- // -67, -67, -67, ..., -67
172
- r1 = ggml_rope(ctx0, r0, p1, n_rot, mode); // "context swap", i.e. forget n_past_0 - n_past_2 tokens
173
-
174
- // 33, 34, 35, ..., 105
175
- r2 = ggml_rope(ctx0, x, p2, n_rot, mode);
176
- } else {
177
- // testing multi-dimension rope position embedding mode
178
- struct ggml_tensor * p0 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2] * 4);
179
- struct ggml_tensor * p1 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2] * 4);
180
- struct ggml_tensor * p2 = ggml_new_tensor_1d(ctx0, GGML_TYPE_I32, ne[2] * 4);
181
-
182
- int sections[4] = {16, 24, 24, 0};
183
- mode = (m == 3) ? GGML_ROPE_TYPE_MROPE : GGML_ROPE_TYPE_VISION;
184
-
185
- for (int i = 0; i < ne[2]; ++i) {
186
- for (int j = 0; j < 4; ++j) {
187
- ((int32_t *) p0->data)[i + ne[2] * j] = n_past_0 + i + j;
188
- ((int32_t *) p1->data)[i + ne[2] * j] = n_past_2 - n_past_0;
189
- ((int32_t *) p2->data)[i + ne[2] * j] = n_past_2 + i + j;
190
- }
191
- }
192
-
193
- // [[100, 101, 102, ..., 172],
194
- // [101, 102, 103, ..., 173],
195
- // [102, 103, 104, ..., 174]]
196
- r0 = ggml_rope_multi(
197
- ctx0, x, p0, nullptr,
198
- n_rot, sections, mode, 32768, 1000000, 1, 0, 1, 32, 1);
199
- // [[-67, -67, -67, ..., -67]
200
- // [-67, -67, -67, ..., -67]
201
- // [-67, -67, -67, ..., -67]]
202
- r1 = ggml_rope_multi(
203
- ctx0, r0, p1, nullptr,
204
- n_rot, sections, mode, 32768, 1000000, 1, 0, 1, 32, 1);
205
-
206
- // [[33, 34, 35, ..., 105]
207
- // [34, 35, 36, ..., 106]
208
- // [35, 36, 37, ..., 107]]
209
- r2 = ggml_rope_multi(
210
- ctx0, x, p2, nullptr,
211
- n_rot, sections, mode, 32768, 1000000, 1, 0, 1, 32, 1);
212
- }
213
-
214
- ggml_cgraph * gf = ggml_new_graph(ctx0);
215
-
216
- ggml_build_forward_expand(gf, r0);
217
- ggml_build_forward_expand(gf, r1);
218
- ggml_build_forward_expand(gf, r2);
219
-
220
- ggml_graph_compute_helper(work_buffer, gf, 4);
221
-
222
- // check that r1 and r2 are the same
223
- {
224
- double sum0 = 0.0f;
225
- double sum1 = 0.0f;
226
- double diff = 0.0f;
227
-
228
- const float * r1_data = (float *) r1->data;
229
- const float * r2_data = (float *) r2->data;
230
-
231
- const int n_elements = ggml_nelements(r1);
232
-
233
- for (int i = 0; i < n_elements; ++i) {
234
- sum0 += fabs(r1_data[i]);
235
- sum1 += fabs(r2_data[i]);
236
- diff += fabs(r1_data[i] - r2_data[i]);
237
- //if (fabs(r1_data[i] - r2_data[i]) > 0.0001f) {
238
- // printf("%d: %f %f\n", i, r1_data[i], r2_data[i]);
239
- // printf("diff: %f\n", fabs(r1_data[i] - r2_data[i]));
240
- //}
241
- }
242
-
243
- //for (int i = 4096; i < 4096 + 128; ++i) {
244
- // printf("%f %f\n", r1_data[i], r2_data[i]);
245
- //}
246
-
247
- printf("mode: %d\n", mode);
248
- printf("sum0: %f\n", sum0);
249
- printf("sum1: %f\n", sum1);
250
- printf("diff: %f\n", diff);
251
- printf("rel err: %f\n", diff / sum0);
252
- printf("rel err: %f\n", diff / sum1);
253
-
254
- GGML_ASSERT(diff / sum0 < 0.0001f);
255
- GGML_ASSERT(diff / sum1 < 0.0001f);
256
- }
257
- }
258
-
259
- ggml_free(ctx0);
260
-
261
- return 0;
262
- }