elelem-ggml 0.1.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 (1367) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/exe/elelem-ggml +8 -0
  4. data/ext/elelem/ggml/elelem.c +466 -0
  5. data/ext/elelem/ggml/extconf.rb +52 -0
  6. data/lib/elelem/ggml/chat_ml.rb +23 -0
  7. data/lib/elelem/ggml/gguf.rb +82 -0
  8. data/lib/elelem/ggml/provider.rb +63 -0
  9. data/lib/elelem/ggml/tokenizer.rb +95 -0
  10. data/lib/elelem/ggml/version.rb +7 -0
  11. data/lib/elelem/ggml.rb +37 -0
  12. data/vendor/ggml/AUTHORS +335 -0
  13. data/vendor/ggml/CMakeLists.txt +499 -0
  14. data/vendor/ggml/CONTRIBUTING.md +3 -0
  15. data/vendor/ggml/LICENSE +21 -0
  16. data/vendor/ggml/README.md +49 -0
  17. data/vendor/ggml/cmake/FindNCCL.cmake +36 -0
  18. data/vendor/ggml/cmake/GitVars.cmake +22 -0
  19. data/vendor/ggml/cmake/common.cmake +50 -0
  20. data/vendor/ggml/cmake/ggml-config.cmake.in +216 -0
  21. data/vendor/ggml/ggml.pc.in +10 -0
  22. data/vendor/ggml/include/ggml-alloc.h +86 -0
  23. data/vendor/ggml/include/ggml-backend.h +437 -0
  24. data/vendor/ggml/include/ggml-blas.h +25 -0
  25. data/vendor/ggml/include/ggml-cann.h +123 -0
  26. data/vendor/ggml/include/ggml-cpp.h +39 -0
  27. data/vendor/ggml/include/ggml-cpu.h +152 -0
  28. data/vendor/ggml/include/ggml-cuda.h +47 -0
  29. data/vendor/ggml/include/ggml-et.h +28 -0
  30. data/vendor/ggml/include/ggml-hexagon.h +19 -0
  31. data/vendor/ggml/include/ggml-metal.h +61 -0
  32. data/vendor/ggml/include/ggml-opencl.h +26 -0
  33. data/vendor/ggml/include/ggml-openvino.h +37 -0
  34. data/vendor/ggml/include/ggml-opt.h +256 -0
  35. data/vendor/ggml/include/ggml-rpc.h +35 -0
  36. data/vendor/ggml/include/ggml-sycl.h +57 -0
  37. data/vendor/ggml/include/ggml-virtgpu.h +14 -0
  38. data/vendor/ggml/include/ggml-vulkan.h +29 -0
  39. data/vendor/ggml/include/ggml-webgpu.h +19 -0
  40. data/vendor/ggml/include/ggml-zdnn.h +17 -0
  41. data/vendor/ggml/include/ggml-zendnn.h +22 -0
  42. data/vendor/ggml/include/ggml.h +2963 -0
  43. data/vendor/ggml/include/gguf.h +211 -0
  44. data/vendor/ggml/requirements.txt +12 -0
  45. data/vendor/ggml/scripts/gen-authors.sh +9 -0
  46. data/vendor/ggml/scripts/make-release-checks.sh +96 -0
  47. data/vendor/ggml/scripts/make-release-desc.sh +69 -0
  48. data/vendor/ggml/scripts/make-release-summary.txt +33 -0
  49. data/vendor/ggml/scripts/release.sh +195 -0
  50. data/vendor/ggml/scripts/sync-llama-am.sh +167 -0
  51. data/vendor/ggml/scripts/sync-llama.last +1 -0
  52. data/vendor/ggml/scripts/sync-llama.sh +21 -0
  53. data/vendor/ggml/scripts/sync-whisper-am.sh +138 -0
  54. data/vendor/ggml/scripts/sync-whisper.last +1 -0
  55. data/vendor/ggml/scripts/sync-whisper.sh +17 -0
  56. data/vendor/ggml/src/CMakeLists.txt +634 -0
  57. data/vendor/ggml/src/ggml-alloc.c +1249 -0
  58. data/vendor/ggml/src/ggml-backend-dl.cpp +48 -0
  59. data/vendor/ggml/src/ggml-backend-dl.h +45 -0
  60. data/vendor/ggml/src/ggml-backend-impl.h +291 -0
  61. data/vendor/ggml/src/ggml-backend-meta.cpp +2511 -0
  62. data/vendor/ggml/src/ggml-backend-reg.cpp +605 -0
  63. data/vendor/ggml/src/ggml-backend.cpp +2517 -0
  64. data/vendor/ggml/src/ggml-blas/CMakeLists.txt +101 -0
  65. data/vendor/ggml/src/ggml-blas/ggml-blas.cpp +530 -0
  66. data/vendor/ggml/src/ggml-cann/CMakeLists.txt +89 -0
  67. data/vendor/ggml/src/ggml-cann/acl_tensor.cpp +195 -0
  68. data/vendor/ggml/src/ggml-cann/acl_tensor.h +349 -0
  69. data/vendor/ggml/src/ggml-cann/aclnn_ops.cpp +4479 -0
  70. data/vendor/ggml/src/ggml-cann/aclnn_ops.h +1191 -0
  71. data/vendor/ggml/src/ggml-cann/common.h +651 -0
  72. data/vendor/ggml/src/ggml-cann/ggml-cann.cpp +3070 -0
  73. data/vendor/ggml/src/ggml-common.h +1911 -0
  74. data/vendor/ggml/src/ggml-cpu/CMakeLists.txt +685 -0
  75. data/vendor/ggml/src/ggml-cpu/amx/amx.cpp +249 -0
  76. data/vendor/ggml/src/ggml-cpu/amx/amx.h +8 -0
  77. data/vendor/ggml/src/ggml-cpu/amx/common.h +115 -0
  78. data/vendor/ggml/src/ggml-cpu/amx/mmq.cpp +2511 -0
  79. data/vendor/ggml/src/ggml-cpu/amx/mmq.h +10 -0
  80. data/vendor/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +41 -0
  81. data/vendor/ggml/src/ggml-cpu/arch/arm/quants.c +4319 -0
  82. data/vendor/ggml/src/ggml-cpu/arch/arm/repack.cpp +5156 -0
  83. data/vendor/ggml/src/ggml-cpu/arch/loongarch/quants.c +2309 -0
  84. data/vendor/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
  85. data/vendor/ggml/src/ggml-cpu/arch/powerpc/quants.c +2304 -0
  86. data/vendor/ggml/src/ggml-cpu/arch/riscv/cpu-feats.cpp +38 -0
  87. data/vendor/ggml/src/ggml-cpu/arch/riscv/quants.c +6596 -0
  88. data/vendor/ggml/src/ggml-cpu/arch/riscv/repack.cpp +1703 -0
  89. data/vendor/ggml/src/ggml-cpu/arch/s390/cpu-feats.cpp +50 -0
  90. data/vendor/ggml/src/ggml-cpu/arch/s390/quants.c +1465 -0
  91. data/vendor/ggml/src/ggml-cpu/arch/wasm/quants.c +1292 -0
  92. data/vendor/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp +327 -0
  93. data/vendor/ggml/src/ggml-cpu/arch/x86/quants.c +4108 -0
  94. data/vendor/ggml/src/ggml-cpu/arch/x86/repack.cpp +6407 -0
  95. data/vendor/ggml/src/ggml-cpu/arch-fallback.h +353 -0
  96. data/vendor/ggml/src/ggml-cpu/binary-ops.cpp +154 -0
  97. data/vendor/ggml/src/ggml-cpu/binary-ops.h +16 -0
  98. data/vendor/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
  99. data/vendor/ggml/src/ggml-cpu/cmake/FindSMTIME.cmake +32 -0
  100. data/vendor/ggml/src/ggml-cpu/common.h +95 -0
  101. data/vendor/ggml/src/ggml-cpu/ggml-cpu-impl.h +539 -0
  102. data/vendor/ggml/src/ggml-cpu/ggml-cpu.c +3936 -0
  103. data/vendor/ggml/src/ggml-cpu/ggml-cpu.cpp +712 -0
  104. data/vendor/ggml/src/ggml-cpu/hbm.cpp +55 -0
  105. data/vendor/ggml/src/ggml-cpu/hbm.h +8 -0
  106. data/vendor/ggml/src/ggml-cpu/iqp.cpp +1253 -0
  107. data/vendor/ggml/src/ggml-cpu/iqp.h +39 -0
  108. data/vendor/ggml/src/ggml-cpu/kleidiai/CMakeLists.txt +14 -0
  109. data/vendor/ggml/src/ggml-cpu/kleidiai/kernels.cpp +1101 -0
  110. data/vendor/ggml/src/ggml-cpu/kleidiai/kernels.h +101 -0
  111. data/vendor/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +1919 -0
  112. data/vendor/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
  113. data/vendor/ggml/src/ggml-cpu/llamafile/sgemm.cpp +4164 -0
  114. data/vendor/ggml/src/ggml-cpu/llamafile/sgemm.h +25 -0
  115. data/vendor/ggml/src/ggml-cpu/ops.cpp +12164 -0
  116. data/vendor/ggml/src/ggml-cpu/ops.h +124 -0
  117. data/vendor/ggml/src/ggml-cpu/quants.c +1339 -0
  118. data/vendor/ggml/src/ggml-cpu/quants.h +106 -0
  119. data/vendor/ggml/src/ggml-cpu/repack.cpp +4836 -0
  120. data/vendor/ggml/src/ggml-cpu/repack.h +245 -0
  121. data/vendor/ggml/src/ggml-cpu/simd-gemm.h +226 -0
  122. data/vendor/ggml/src/ggml-cpu/simd-mappings.h +1319 -0
  123. data/vendor/ggml/src/ggml-cpu/spacemit/ime.cpp +1742 -0
  124. data/vendor/ggml/src/ggml-cpu/spacemit/ime.h +21 -0
  125. data/vendor/ggml/src/ggml-cpu/spacemit/ime1_kernels.cpp +1027 -0
  126. data/vendor/ggml/src/ggml-cpu/spacemit/ime2_kernels.cpp +5768 -0
  127. data/vendor/ggml/src/ggml-cpu/spacemit/ime_env.cpp +320 -0
  128. data/vendor/ggml/src/ggml-cpu/spacemit/ime_env.h +55 -0
  129. data/vendor/ggml/src/ggml-cpu/spacemit/ime_kernels.h +189 -0
  130. data/vendor/ggml/src/ggml-cpu/spacemit/repack.cpp +1795 -0
  131. data/vendor/ggml/src/ggml-cpu/spacemit/repack.h +14 -0
  132. data/vendor/ggml/src/ggml-cpu/spacemit/rvv_kernels.cpp +3178 -0
  133. data/vendor/ggml/src/ggml-cpu/spacemit/rvv_kernels.h +95 -0
  134. data/vendor/ggml/src/ggml-cpu/spacemit/spine_barrier.h +34 -0
  135. data/vendor/ggml/src/ggml-cpu/spacemit/spine_mem_pool.cpp +760 -0
  136. data/vendor/ggml/src/ggml-cpu/spacemit/spine_mem_pool.h +32 -0
  137. data/vendor/ggml/src/ggml-cpu/spacemit/spine_tcm.h +409 -0
  138. data/vendor/ggml/src/ggml-cpu/traits.cpp +36 -0
  139. data/vendor/ggml/src/ggml-cpu/traits.h +38 -0
  140. data/vendor/ggml/src/ggml-cpu/unary-ops.cpp +337 -0
  141. data/vendor/ggml/src/ggml-cpu/unary-ops.h +35 -0
  142. data/vendor/ggml/src/ggml-cpu/vec.cpp +613 -0
  143. data/vendor/ggml/src/ggml-cpu/vec.h +1570 -0
  144. data/vendor/ggml/src/ggml-cuda/CMakeLists.txt +267 -0
  145. data/vendor/ggml/src/ggml-cuda/acc.cu +61 -0
  146. data/vendor/ggml/src/ggml-cuda/acc.cuh +5 -0
  147. data/vendor/ggml/src/ggml-cuda/add-id.cu +58 -0
  148. data/vendor/ggml/src/ggml-cuda/add-id.cuh +3 -0
  149. data/vendor/ggml/src/ggml-cuda/allreduce.cu +971 -0
  150. data/vendor/ggml/src/ggml-cuda/allreduce.cuh +29 -0
  151. data/vendor/ggml/src/ggml-cuda/arange.cu +34 -0
  152. data/vendor/ggml/src/ggml-cuda/arange.cuh +5 -0
  153. data/vendor/ggml/src/ggml-cuda/argmax.cu +91 -0
  154. data/vendor/ggml/src/ggml-cuda/argmax.cuh +3 -0
  155. data/vendor/ggml/src/ggml-cuda/argsort.cu +292 -0
  156. data/vendor/ggml/src/ggml-cuda/argsort.cuh +20 -0
  157. data/vendor/ggml/src/ggml-cuda/binbcast.cu +574 -0
  158. data/vendor/ggml/src/ggml-cuda/binbcast.cuh +12 -0
  159. data/vendor/ggml/src/ggml-cuda/clamp.cu +45 -0
  160. data/vendor/ggml/src/ggml-cuda/clamp.cuh +5 -0
  161. data/vendor/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
  162. data/vendor/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
  163. data/vendor/ggml/src/ggml-cuda/common.cuh +1678 -0
  164. data/vendor/ggml/src/ggml-cuda/concat.cu +242 -0
  165. data/vendor/ggml/src/ggml-cuda/concat.cuh +5 -0
  166. data/vendor/ggml/src/ggml-cuda/conv-transpose-1d.cu +88 -0
  167. data/vendor/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
  168. data/vendor/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
  169. data/vendor/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
  170. data/vendor/ggml/src/ggml-cuda/conv2d-transpose.cu +115 -0
  171. data/vendor/ggml/src/ggml-cuda/conv2d-transpose.cuh +5 -0
  172. data/vendor/ggml/src/ggml-cuda/conv2d.cu +167 -0
  173. data/vendor/ggml/src/ggml-cuda/conv2d.cuh +5 -0
  174. data/vendor/ggml/src/ggml-cuda/convert.cu +705 -0
  175. data/vendor/ggml/src/ggml-cuda/convert.cuh +66 -0
  176. data/vendor/ggml/src/ggml-cuda/count-equal.cu +64 -0
  177. data/vendor/ggml/src/ggml-cuda/count-equal.cuh +5 -0
  178. data/vendor/ggml/src/ggml-cuda/cp-async.cuh +57 -0
  179. data/vendor/ggml/src/ggml-cuda/cpy-utils.cuh +217 -0
  180. data/vendor/ggml/src/ggml-cuda/cpy.cu +617 -0
  181. data/vendor/ggml/src/ggml-cuda/cpy.cuh +7 -0
  182. data/vendor/ggml/src/ggml-cuda/cross-entropy-loss.cu +177 -0
  183. data/vendor/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
  184. data/vendor/ggml/src/ggml-cuda/cumsum.cu +307 -0
  185. data/vendor/ggml/src/ggml-cuda/cumsum.cuh +5 -0
  186. data/vendor/ggml/src/ggml-cuda/dequantize.cuh +452 -0
  187. data/vendor/ggml/src/ggml-cuda/diag.cu +77 -0
  188. data/vendor/ggml/src/ggml-cuda/diag.cuh +5 -0
  189. data/vendor/ggml/src/ggml-cuda/diagmask.cu +40 -0
  190. data/vendor/ggml/src/ggml-cuda/diagmask.cuh +5 -0
  191. data/vendor/ggml/src/ggml-cuda/dsv4-hc.cu +294 -0
  192. data/vendor/ggml/src/ggml-cuda/dsv4-hc.cuh +6 -0
  193. data/vendor/ggml/src/ggml-cuda/fattn-common.cuh +1289 -0
  194. data/vendor/ggml/src/ggml-cuda/fattn-mma-f16.cuh +2136 -0
  195. data/vendor/ggml/src/ggml-cuda/fattn-swizzle.cuh +126 -0
  196. data/vendor/ggml/src/ggml-cuda/fattn-tile.cu +60 -0
  197. data/vendor/ggml/src/ggml-cuda/fattn-tile.cuh +1355 -0
  198. data/vendor/ggml/src/ggml-cuda/fattn-vec.cuh +611 -0
  199. data/vendor/ggml/src/ggml-cuda/fattn.cu +722 -0
  200. data/vendor/ggml/src/ggml-cuda/fattn.cuh +7 -0
  201. data/vendor/ggml/src/ggml-cuda/fill.cu +37 -0
  202. data/vendor/ggml/src/ggml-cuda/fill.cuh +3 -0
  203. data/vendor/ggml/src/ggml-cuda/fwht.cu +101 -0
  204. data/vendor/ggml/src/ggml-cuda/fwht.cuh +4 -0
  205. data/vendor/ggml/src/ggml-cuda/gated_delta_net.cu +327 -0
  206. data/vendor/ggml/src/ggml-cuda/gated_delta_net.cuh +14 -0
  207. data/vendor/ggml/src/ggml-cuda/getrows.cu +490 -0
  208. data/vendor/ggml/src/ggml-cuda/getrows.cuh +15 -0
  209. data/vendor/ggml/src/ggml-cuda/ggml-cuda.cu +5781 -0
  210. data/vendor/ggml/src/ggml-cuda/gla.cu +93 -0
  211. data/vendor/ggml/src/ggml-cuda/gla.cuh +3 -0
  212. data/vendor/ggml/src/ggml-cuda/im2col.cu +267 -0
  213. data/vendor/ggml/src/ggml-cuda/im2col.cuh +6 -0
  214. data/vendor/ggml/src/ggml-cuda/lightning-indexer.cu +588 -0
  215. data/vendor/ggml/src/ggml-cuda/lightning-indexer.cuh +4 -0
  216. data/vendor/ggml/src/ggml-cuda/mean.cu +77 -0
  217. data/vendor/ggml/src/ggml-cuda/mean.cuh +3 -0
  218. data/vendor/ggml/src/ggml-cuda/mma.cuh +1456 -0
  219. data/vendor/ggml/src/ggml-cuda/mmf.cu +191 -0
  220. data/vendor/ggml/src/ggml-cuda/mmf.cuh +908 -0
  221. data/vendor/ggml/src/ggml-cuda/mmid.cu +180 -0
  222. data/vendor/ggml/src/ggml-cuda/mmid.cuh +5 -0
  223. data/vendor/ggml/src/ggml-cuda/mmq-config-ampere.cuh +383 -0
  224. data/vendor/ggml/src/ggml-cuda/mmq-config-blackwell.cuh +37 -0
  225. data/vendor/ggml/src/ggml-cuda/mmq-config-cdna.cuh +185 -0
  226. data/vendor/ggml/src/ggml-cuda/mmq-config-pascal-dp4a.cuh +273 -0
  227. data/vendor/ggml/src/ggml-cuda/mmq-config-pascal-older.cuh +273 -0
  228. data/vendor/ggml/src/ggml-cuda/mmq-config-rdna2.cuh +273 -0
  229. data/vendor/ggml/src/ggml-cuda/mmq-config-rdna3-5.cuh +290 -0
  230. data/vendor/ggml/src/ggml-cuda/mmq-config-rdna3.cuh +274 -0
  231. data/vendor/ggml/src/ggml-cuda/mmq-config-rdna4.cuh +290 -0
  232. data/vendor/ggml/src/ggml-cuda/mmq-load-tiles.cuh +1768 -0
  233. data/vendor/ggml/src/ggml-cuda/mmq-vec-dot.cuh +1240 -0
  234. data/vendor/ggml/src/ggml-cuda/mmq.cu +386 -0
  235. data/vendor/ggml/src/ggml-cuda/mmq.cuh +1598 -0
  236. data/vendor/ggml/src/ggml-cuda/mmvf.cu +875 -0
  237. data/vendor/ggml/src/ggml-cuda/mmvf.cuh +14 -0
  238. data/vendor/ggml/src/ggml-cuda/mmvq.cu +1504 -0
  239. data/vendor/ggml/src/ggml-cuda/mmvq.cuh +18 -0
  240. data/vendor/ggml/src/ggml-cuda/moe-weighted-reduction.cu +65 -0
  241. data/vendor/ggml/src/ggml-cuda/moe-weighted-reduction.cuh +7 -0
  242. data/vendor/ggml/src/ggml-cuda/norm.cu +698 -0
  243. data/vendor/ggml/src/ggml-cuda/norm.cuh +18 -0
  244. data/vendor/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
  245. data/vendor/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
  246. data/vendor/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
  247. data/vendor/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
  248. data/vendor/ggml/src/ggml-cuda/out-prod.cu +125 -0
  249. data/vendor/ggml/src/ggml-cuda/out-prod.cuh +3 -0
  250. data/vendor/ggml/src/ggml-cuda/pad.cu +106 -0
  251. data/vendor/ggml/src/ggml-cuda/pad.cuh +5 -0
  252. data/vendor/ggml/src/ggml-cuda/pad_reflect_1d.cu +91 -0
  253. data/vendor/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
  254. data/vendor/ggml/src/ggml-cuda/pool1d.cu +85 -0
  255. data/vendor/ggml/src/ggml-cuda/pool1d.cuh +5 -0
  256. data/vendor/ggml/src/ggml-cuda/pool2d.cu +94 -0
  257. data/vendor/ggml/src/ggml-cuda/pool2d.cuh +5 -0
  258. data/vendor/ggml/src/ggml-cuda/quantize.cu +697 -0
  259. data/vendor/ggml/src/ggml-cuda/quantize.cuh +70 -0
  260. data/vendor/ggml/src/ggml-cuda/reduce_rows.cuh +43 -0
  261. data/vendor/ggml/src/ggml-cuda/roll.cu +67 -0
  262. data/vendor/ggml/src/ggml-cuda/roll.cuh +5 -0
  263. data/vendor/ggml/src/ggml-cuda/rope.cu +941 -0
  264. data/vendor/ggml/src/ggml-cuda/rope.cuh +11 -0
  265. data/vendor/ggml/src/ggml-cuda/scale.cu +37 -0
  266. data/vendor/ggml/src/ggml-cuda/scale.cuh +5 -0
  267. data/vendor/ggml/src/ggml-cuda/set-rows.cu +398 -0
  268. data/vendor/ggml/src/ggml-cuda/set-rows.cuh +7 -0
  269. data/vendor/ggml/src/ggml-cuda/set.cu +39 -0
  270. data/vendor/ggml/src/ggml-cuda/set.cuh +7 -0
  271. data/vendor/ggml/src/ggml-cuda/snake.cu +72 -0
  272. data/vendor/ggml/src/ggml-cuda/snake.cuh +8 -0
  273. data/vendor/ggml/src/ggml-cuda/softcap.cu +37 -0
  274. data/vendor/ggml/src/ggml-cuda/softcap.cuh +5 -0
  275. data/vendor/ggml/src/ggml-cuda/softmax.cu +480 -0
  276. data/vendor/ggml/src/ggml-cuda/softmax.cuh +7 -0
  277. data/vendor/ggml/src/ggml-cuda/solve_tri.cu +273 -0
  278. data/vendor/ggml/src/ggml-cuda/solve_tri.cuh +3 -0
  279. data/vendor/ggml/src/ggml-cuda/ssm-conv.cu +206 -0
  280. data/vendor/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
  281. data/vendor/ggml/src/ggml-cuda/ssm-scan.cu +859 -0
  282. data/vendor/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
  283. data/vendor/ggml/src/ggml-cuda/sum.cu +41 -0
  284. data/vendor/ggml/src/ggml-cuda/sum.cuh +5 -0
  285. data/vendor/ggml/src/ggml-cuda/sumrows.cu +47 -0
  286. data/vendor/ggml/src/ggml-cuda/sumrows.cuh +4 -0
  287. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +6 -0
  288. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_32.cu +6 -0
  289. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +12 -0
  290. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
  291. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +11 -0
  292. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +12 -0
  293. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +6 -0
  294. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_32.cu +6 -0
  295. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +12 -0
  296. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +12 -0
  297. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
  298. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +11 -0
  299. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +6 -0
  300. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +11 -0
  301. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +12 -0
  302. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +12 -0
  303. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
  304. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
  305. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +11 -0
  306. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +12 -0
  307. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +12 -0
  308. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq112-dv112.cu +5 -0
  309. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq128-dv128.cu +5 -0
  310. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq192-dv128.cu +5 -0
  311. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq256-dv256.cu +5 -0
  312. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq320-dv256.cu +5 -0
  313. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq40-dv40.cu +5 -0
  314. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq512-dv512.cu +5 -0
  315. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq576-dv512.cu +5 -0
  316. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq64-dv64.cu +5 -0
  317. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq72-dv72.cu +5 -0
  318. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq80-dv80.cu +5 -0
  319. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-tile-instance-dkq96-dv96.cu +5 -0
  320. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-bf16.cu +7 -0
  321. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-f16.cu +7 -0
  322. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_0.cu +7 -0
  323. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q4_1.cu +7 -0
  324. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_0.cu +7 -0
  325. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q5_1.cu +7 -0
  326. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-bf16-q8_0.cu +7 -0
  327. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-bf16.cu +7 -0
  328. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-f16.cu +7 -0
  329. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_0.cu +7 -0
  330. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q4_1.cu +7 -0
  331. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_0.cu +7 -0
  332. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q5_1.cu +7 -0
  333. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-f16-q8_0.cu +7 -0
  334. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-bf16.cu +7 -0
  335. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-f16.cu +7 -0
  336. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_0.cu +7 -0
  337. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q4_1.cu +7 -0
  338. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_0.cu +7 -0
  339. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q5_1.cu +7 -0
  340. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_0-q8_0.cu +7 -0
  341. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-bf16.cu +7 -0
  342. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-f16.cu +7 -0
  343. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_0.cu +7 -0
  344. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q4_1.cu +7 -0
  345. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_0.cu +7 -0
  346. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q5_1.cu +7 -0
  347. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q4_1-q8_0.cu +7 -0
  348. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-bf16.cu +7 -0
  349. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-f16.cu +7 -0
  350. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_0.cu +7 -0
  351. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q4_1.cu +7 -0
  352. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_0.cu +7 -0
  353. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q5_1.cu +7 -0
  354. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_0-q8_0.cu +7 -0
  355. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-bf16.cu +7 -0
  356. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-f16.cu +7 -0
  357. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_0.cu +7 -0
  358. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q4_1.cu +7 -0
  359. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_0.cu +7 -0
  360. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q5_1.cu +7 -0
  361. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q5_1-q8_0.cu +7 -0
  362. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-bf16.cu +7 -0
  363. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-f16.cu +7 -0
  364. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_0.cu +7 -0
  365. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q4_1.cu +7 -0
  366. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_0.cu +7 -0
  367. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q5_1.cu +7 -0
  368. data/vendor/ggml/src/ggml-cuda/template-instances/fattn-vec-instance-q8_0-q8_0.cu +7 -0
  369. data/vendor/ggml/src/ggml-cuda/template-instances/generate_cu_files.py +111 -0
  370. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_1.cu +5 -0
  371. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_10.cu +5 -0
  372. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_11.cu +5 -0
  373. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_12.cu +5 -0
  374. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_13.cu +5 -0
  375. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_14.cu +5 -0
  376. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_15.cu +5 -0
  377. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_16.cu +5 -0
  378. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_2.cu +5 -0
  379. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_3.cu +5 -0
  380. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_4.cu +5 -0
  381. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_5.cu +5 -0
  382. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_6.cu +5 -0
  383. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_7.cu +5 -0
  384. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_8.cu +5 -0
  385. data/vendor/ggml/src/ggml-cuda/template-instances/mmf-instance-ncols_9.cu +5 -0
  386. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
  387. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
  388. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
  389. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
  390. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
  391. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
  392. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
  393. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
  394. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
  395. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-nvfp4.cu +5 -0
  396. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q1_0.cu +5 -0
  397. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_0.cu +5 -0
  398. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
  399. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
  400. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
  401. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
  402. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
  403. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
  404. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
  405. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
  406. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
  407. data/vendor/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
  408. data/vendor/ggml/src/ggml-cuda/top-k.cu +275 -0
  409. data/vendor/ggml/src/ggml-cuda/top-k.cuh +3 -0
  410. data/vendor/ggml/src/ggml-cuda/topk-moe.cu +442 -0
  411. data/vendor/ggml/src/ggml-cuda/topk-moe.cuh +31 -0
  412. data/vendor/ggml/src/ggml-cuda/tri.cu +136 -0
  413. data/vendor/ggml/src/ggml-cuda/tri.cuh +5 -0
  414. data/vendor/ggml/src/ggml-cuda/tsembd.cu +47 -0
  415. data/vendor/ggml/src/ggml-cuda/tsembd.cuh +5 -0
  416. data/vendor/ggml/src/ggml-cuda/unary.cu +721 -0
  417. data/vendor/ggml/src/ggml-cuda/unary.cuh +123 -0
  418. data/vendor/ggml/src/ggml-cuda/upscale.cu +293 -0
  419. data/vendor/ggml/src/ggml-cuda/upscale.cuh +5 -0
  420. data/vendor/ggml/src/ggml-cuda/vecdotq.cuh +1371 -0
  421. data/vendor/ggml/src/ggml-cuda/vendors/cuda.h +28 -0
  422. data/vendor/ggml/src/ggml-cuda/vendors/hip.h +301 -0
  423. data/vendor/ggml/src/ggml-cuda/vendors/musa.h +151 -0
  424. data/vendor/ggml/src/ggml-cuda/wkv.cu +253 -0
  425. data/vendor/ggml/src/ggml-cuda/wkv.cuh +7 -0
  426. data/vendor/ggml/src/ggml-et/CMakeLists.txt +246 -0
  427. data/vendor/ggml/src/ggml-et/cmake/embed_one_kernel.cmake +15 -0
  428. data/vendor/ggml/src/ggml-et/cmake/ggml-et-kernels-embed.cpp.in +6 -0
  429. data/vendor/ggml/src/ggml-et/cmake/ggml-et-kernels-embed.hpp.in +12 -0
  430. data/vendor/ggml/src/ggml-et/cmake/ggml-et-uberkernel-kernel-map.cpp.in +18 -0
  431. data/vendor/ggml/src/ggml-et/cmake/ggml-et-uberkernel-kernel-map.h.in +13 -0
  432. data/vendor/ggml/src/ggml-et/et-kernels/CMakeLists.txt +137 -0
  433. data/vendor/ggml/src/ggml-et/et-kernels/scripts/check_unimplemented_instructions.sh +36 -0
  434. data/vendor/ggml/src/ggml-et/et-kernels/src/RunBackend.sh +23 -0
  435. data/vendor/ggml/src/ggml-et/et-kernels/src/block_ops.h +997 -0
  436. data/vendor/ggml/src/ggml-et/et-kernels/src/clamp_f32.c +120 -0
  437. data/vendor/ggml/src/ggml-et/et-kernels/src/concat_f32.c +175 -0
  438. data/vendor/ggml/src/ggml-et/et-kernels/src/cont_f16.c +107 -0
  439. data/vendor/ggml/src/ggml-et/et-kernels/src/cont_f32.c +248 -0
  440. data/vendor/ggml/src/ggml-et/et-kernels/src/conv_2d_f32_me.c +807 -0
  441. data/vendor/ggml/src/ggml-et/et-kernels/src/cpy_f32_f16.c +110 -0
  442. data/vendor/ggml/src/ggml-et/et-kernels/src/crt.S +15 -0
  443. data/vendor/ggml/src/ggml-et/et-kernels/src/cumsum_f32.c +96 -0
  444. data/vendor/ggml/src/ggml-et/et-kernels/src/diag_f32.c +90 -0
  445. data/vendor/ggml/src/ggml-et/et-kernels/src/el_map_f32.c +377 -0
  446. data/vendor/ggml/src/ggml-et/et-kernels/src/fill_f32.c +87 -0
  447. data/vendor/ggml/src/ggml-et/et-kernels/src/flash_attn_ext_f16_me.c +1000 -0
  448. data/vendor/ggml/src/ggml-et/et-kernels/src/flash_attn_ext_f32.c +217 -0
  449. data/vendor/ggml/src/ggml-et/et-kernels/src/gated_delta_net_f32.c +346 -0
  450. data/vendor/ggml/src/ggml-et/et-kernels/src/get_rows_f32.c +612 -0
  451. data/vendor/ggml/src/ggml-et/et-kernels/src/ggml_tensor.h +44 -0
  452. data/vendor/ggml/src/ggml-et/et-kernels/src/glu_f32.c +606 -0
  453. data/vendor/ggml/src/ggml-et/et-kernels/src/group_norm_f32.c +171 -0
  454. data/vendor/ggml/src/ggml-et/et-kernels/src/im2col.c +130 -0
  455. data/vendor/ggml/src/ggml-et/et-kernels/src/l2_norm_f32.c +237 -0
  456. data/vendor/ggml/src/ggml-et/et-kernels/src/linker.ld +85 -0
  457. data/vendor/ggml/src/ggml-et/et-kernels/src/math_fp.h +299 -0
  458. data/vendor/ggml/src/ggml-et/et-kernels/src/mean_f32.c +220 -0
  459. data/vendor/ggml/src/ggml-et/et-kernels/src/memops.c +181 -0
  460. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_Q4_0.c +358 -0
  461. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_Q4_0_matrix_engine.c +368 -0
  462. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_Q8_0.c +413 -0
  463. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_f16.c +142 -0
  464. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_f16_matrix_engine.c +329 -0
  465. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_f32.c +137 -0
  466. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_f32_matrix_engine.c +155 -0
  467. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_id_Q4_0.c +169 -0
  468. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_id_Q8_0.c +160 -0
  469. data/vendor/ggml/src/ggml-et/et-kernels/src/mul_mat_id_f32.c +288 -0
  470. data/vendor/ggml/src/ggml-et/et-kernels/src/norm_f32.c +328 -0
  471. data/vendor/ggml/src/ggml-et/et-kernels/src/pad_f32.c +165 -0
  472. data/vendor/ggml/src/ggml-et/et-kernels/src/platform.h +545 -0
  473. data/vendor/ggml/src/ggml-et/et-kernels/src/quants.h +72 -0
  474. data/vendor/ggml/src/ggml-et/et-kernels/src/repeat_f32.c +118 -0
  475. data/vendor/ggml/src/ggml-et/et-kernels/src/rms_norm_f32.c +270 -0
  476. data/vendor/ggml/src/ggml-et/et-kernels/src/rms_norm_mul_f32.c +290 -0
  477. data/vendor/ggml/src/ggml-et/et-kernels/src/rope_f32.c +656 -0
  478. data/vendor/ggml/src/ggml-et/et-kernels/src/rwkv_wkv6_f32.c +184 -0
  479. data/vendor/ggml/src/ggml-et/et-kernels/src/rwkv_wkv7_f32.c +272 -0
  480. data/vendor/ggml/src/ggml-et/et-kernels/src/scale_f32.c +94 -0
  481. data/vendor/ggml/src/ggml-et/et-kernels/src/set_f32.c +101 -0
  482. data/vendor/ggml/src/ggml-et/et-kernels/src/set_rows_f32.c +394 -0
  483. data/vendor/ggml/src/ggml-et/et-kernels/src/softmax_f32.c +698 -0
  484. data/vendor/ggml/src/ggml-et/et-kernels/src/solve_tri_f32.c +109 -0
  485. data/vendor/ggml/src/ggml-et/et-kernels/src/sqr_f32.c +88 -0
  486. data/vendor/ggml/src/ggml-et/et-kernels/src/ssm_conv_f32.c +129 -0
  487. data/vendor/ggml/src/ggml-et/et-kernels/src/ssm_scan_f32.c +282 -0
  488. data/vendor/ggml/src/ggml-et/et-kernels/src/sum_rows_f32.c +103 -0
  489. data/vendor/ggml/src/ggml-et/et-kernels/src/tensor.h +897 -0
  490. data/vendor/ggml/src/ggml-et/et-kernels/src/tri_f32.c +244 -0
  491. data/vendor/ggml/src/ggml-et/et-kernels/src/uberkernel.c +497 -0
  492. data/vendor/ggml/src/ggml-et/et-kernels/src/unary_f32.c +705 -0
  493. data/vendor/ggml/src/ggml-et/ggml-et-common.h +86 -0
  494. data/vendor/ggml/src/ggml-et/ggml-et-cpu-compare.cpp +502 -0
  495. data/vendor/ggml/src/ggml-et/ggml-et-cpu-compare.h +54 -0
  496. data/vendor/ggml/src/ggml-et/ggml-et-kernels.cpp +508 -0
  497. data/vendor/ggml/src/ggml-et/ggml-et-kernels.h +48 -0
  498. data/vendor/ggml/src/ggml-et/ggml-et-memops.cpp +36 -0
  499. data/vendor/ggml/src/ggml-et/ggml-et-memops.h +18 -0
  500. data/vendor/ggml/src/ggml-et/ggml-et-ops.cpp +2584 -0
  501. data/vendor/ggml/src/ggml-et/ggml-et-ops.h +393 -0
  502. data/vendor/ggml/src/ggml-et/ggml-et-uberkernel-common.h +17 -0
  503. data/vendor/ggml/src/ggml-et/ggml-et.cpp +1880 -0
  504. data/vendor/ggml/src/ggml-feats.h +166 -0
  505. data/vendor/ggml/src/ggml-hexagon/CMakeLists.txt +113 -0
  506. data/vendor/ggml/src/ggml-hexagon/ggml-hexagon.cpp +6523 -0
  507. data/vendor/ggml/src/ggml-hexagon/htp/CMakeLists.txt +58 -0
  508. data/vendor/ggml/src/ggml-hexagon/htp/act-ops.c +585 -0
  509. data/vendor/ggml/src/ggml-hexagon/htp/allreduce-ops.c +398 -0
  510. data/vendor/ggml/src/ggml-hexagon/htp/allreduce-ops.h +40 -0
  511. data/vendor/ggml/src/ggml-hexagon/htp/argsort-ops.c +514 -0
  512. data/vendor/ggml/src/ggml-hexagon/htp/binary-ops.c +873 -0
  513. data/vendor/ggml/src/ggml-hexagon/htp/cmake-toolchain.cmake +155 -0
  514. data/vendor/ggml/src/ggml-hexagon/htp/concat-ops.c +277 -0
  515. data/vendor/ggml/src/ggml-hexagon/htp/cpy-ops.c +354 -0
  516. data/vendor/ggml/src/ggml-hexagon/htp/cumsum-ops.c +265 -0
  517. data/vendor/ggml/src/ggml-hexagon/htp/diag-ops.c +216 -0
  518. data/vendor/ggml/src/ggml-hexagon/htp/dma-queue.c +104 -0
  519. data/vendor/ggml/src/ggml-hexagon/htp/dma-queue.h +408 -0
  520. data/vendor/ggml/src/ggml-hexagon/htp/fill-ops.c +123 -0
  521. data/vendor/ggml/src/ggml-hexagon/htp/flash-attn-ops.c +2479 -0
  522. data/vendor/ggml/src/ggml-hexagon/htp/flash-attn-ops.h +344 -0
  523. data/vendor/ggml/src/ggml-hexagon/htp/gated-delta-net-ops.c +1157 -0
  524. data/vendor/ggml/src/ggml-hexagon/htp/get-rows-ops.c +260 -0
  525. data/vendor/ggml/src/ggml-hexagon/htp/get-rows-ops.h +77 -0
  526. data/vendor/ggml/src/ggml-hexagon/htp/hex-bitmap.h +24 -0
  527. data/vendor/ggml/src/ggml-hexagon/htp/hex-common.h +80 -0
  528. data/vendor/ggml/src/ggml-hexagon/htp/hex-dma.h +2 -0
  529. data/vendor/ggml/src/ggml-hexagon/htp/hex-dump.h +86 -0
  530. data/vendor/ggml/src/ggml-hexagon/htp/hex-fastdiv.h +37 -0
  531. data/vendor/ggml/src/ggml-hexagon/htp/hex-profile.h +64 -0
  532. data/vendor/ggml/src/ggml-hexagon/htp/hex-utils.h +65 -0
  533. data/vendor/ggml/src/ggml-hexagon/htp/hmx-fa-kernels.h +555 -0
  534. data/vendor/ggml/src/ggml-hexagon/htp/hmx-mm-kernels-tiled.h +1378 -0
  535. data/vendor/ggml/src/ggml-hexagon/htp/hmx-queue.c +170 -0
  536. data/vendor/ggml/src/ggml-hexagon/htp/hmx-queue.h +160 -0
  537. data/vendor/ggml/src/ggml-hexagon/htp/hmx-utils.h +222 -0
  538. data/vendor/ggml/src/ggml-hexagon/htp/htp-ctx.h +146 -0
  539. data/vendor/ggml/src/ggml-hexagon/htp/htp-ops.h +242 -0
  540. data/vendor/ggml/src/ggml-hexagon/htp/htp-tensor.c +300 -0
  541. data/vendor/ggml/src/ggml-hexagon/htp/htp-tensor.h +29 -0
  542. data/vendor/ggml/src/ggml-hexagon/htp/htp-vtcm.h +19 -0
  543. data/vendor/ggml/src/ggml-hexagon/htp/htp_iface.idl +23 -0
  544. data/vendor/ggml/src/ggml-hexagon/htp/hvx-arith.h +636 -0
  545. data/vendor/ggml/src/ggml-hexagon/htp/hvx-base.h +292 -0
  546. data/vendor/ggml/src/ggml-hexagon/htp/hvx-copy.h +262 -0
  547. data/vendor/ggml/src/ggml-hexagon/htp/hvx-div.h +291 -0
  548. data/vendor/ggml/src/ggml-hexagon/htp/hvx-dump.h +129 -0
  549. data/vendor/ggml/src/ggml-hexagon/htp/hvx-exp.h +255 -0
  550. data/vendor/ggml/src/ggml-hexagon/htp/hvx-fa-kernels.h +303 -0
  551. data/vendor/ggml/src/ggml-hexagon/htp/hvx-flash-attn.h +47 -0
  552. data/vendor/ggml/src/ggml-hexagon/htp/hvx-floor.h +100 -0
  553. data/vendor/ggml/src/ggml-hexagon/htp/hvx-inverse.h +210 -0
  554. data/vendor/ggml/src/ggml-hexagon/htp/hvx-log.h +118 -0
  555. data/vendor/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-flat.h +1511 -0
  556. data/vendor/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-tiled.h +1200 -0
  557. data/vendor/ggml/src/ggml-hexagon/htp/hvx-norm.h +454 -0
  558. data/vendor/ggml/src/ggml-hexagon/htp/hvx-pow.h +42 -0
  559. data/vendor/ggml/src/ggml-hexagon/htp/hvx-quant.h +165 -0
  560. data/vendor/ggml/src/ggml-hexagon/htp/hvx-reduce.h +336 -0
  561. data/vendor/ggml/src/ggml-hexagon/htp/hvx-repl.h +74 -0
  562. data/vendor/ggml/src/ggml-hexagon/htp/hvx-scale.h +199 -0
  563. data/vendor/ggml/src/ggml-hexagon/htp/hvx-sigmoid.h +181 -0
  564. data/vendor/ggml/src/ggml-hexagon/htp/hvx-sin-cos.h +90 -0
  565. data/vendor/ggml/src/ggml-hexagon/htp/hvx-sqrt.h +189 -0
  566. data/vendor/ggml/src/ggml-hexagon/htp/hvx-types.h +36 -0
  567. data/vendor/ggml/src/ggml-hexagon/htp/hvx-utils.h +24 -0
  568. data/vendor/ggml/src/ggml-hexagon/htp/im2col-ops.c +306 -0
  569. data/vendor/ggml/src/ggml-hexagon/htp/main.c +1245 -0
  570. data/vendor/ggml/src/ggml-hexagon/htp/matmul-ops.c +4078 -0
  571. data/vendor/ggml/src/ggml-hexagon/htp/matmul-ops.h +778 -0
  572. data/vendor/ggml/src/ggml-hexagon/htp/pad-ops.c +547 -0
  573. data/vendor/ggml/src/ggml-hexagon/htp/repeat-ops.c +148 -0
  574. data/vendor/ggml/src/ggml-hexagon/htp/rope-ops.c +733 -0
  575. data/vendor/ggml/src/ggml-hexagon/htp/set-rows-ops.c +230 -0
  576. data/vendor/ggml/src/ggml-hexagon/htp/set-rows-ops.h +74 -0
  577. data/vendor/ggml/src/ggml-hexagon/htp/softmax-ops.c +407 -0
  578. data/vendor/ggml/src/ggml-hexagon/htp/solve-tri-ops.c +267 -0
  579. data/vendor/ggml/src/ggml-hexagon/htp/ssm-conv.c +433 -0
  580. data/vendor/ggml/src/ggml-hexagon/htp/sum-rows-ops.c +128 -0
  581. data/vendor/ggml/src/ggml-hexagon/htp/unary-ops.c +1264 -0
  582. data/vendor/ggml/src/ggml-hexagon/htp/unary-ops.h +176 -0
  583. data/vendor/ggml/src/ggml-hexagon/htp/work-queue.c +244 -0
  584. data/vendor/ggml/src/ggml-hexagon/htp/work-queue.h +38 -0
  585. data/vendor/ggml/src/ggml-hexagon/htp-drv.cpp +425 -0
  586. data/vendor/ggml/src/ggml-hexagon/htp-drv.h +123 -0
  587. data/vendor/ggml/src/ggml-hexagon/htp-opnode.h +372 -0
  588. data/vendor/ggml/src/ggml-hexagon/libdl.h +79 -0
  589. data/vendor/ggml/src/ggml-hexagon/libggml-htp.inf +36 -0
  590. data/vendor/ggml/src/ggml-hip/CMakeLists.txt +153 -0
  591. data/vendor/ggml/src/ggml-impl.h +783 -0
  592. data/vendor/ggml/src/ggml-metal/CMakeLists.txt +240 -0
  593. data/vendor/ggml/src/ggml-metal/ggml-metal-common.cpp +474 -0
  594. data/vendor/ggml/src/ggml-metal/ggml-metal-common.h +56 -0
  595. data/vendor/ggml/src/ggml-metal/ggml-metal-context.h +41 -0
  596. data/vendor/ggml/src/ggml-metal/ggml-metal-context.m +759 -0
  597. data/vendor/ggml/src/ggml-metal/ggml-metal-device.cpp +2330 -0
  598. data/vendor/ggml/src/ggml-metal/ggml-metal-device.h +355 -0
  599. data/vendor/ggml/src/ggml-metal/ggml-metal-device.m +2473 -0
  600. data/vendor/ggml/src/ggml-metal/ggml-metal-impl.h +1345 -0
  601. data/vendor/ggml/src/ggml-metal/ggml-metal-ops.cpp +5610 -0
  602. data/vendor/ggml/src/ggml-metal/ggml-metal-ops.h +106 -0
  603. data/vendor/ggml/src/ggml-metal/ggml-metal-tuning.cpp +3732 -0
  604. data/vendor/ggml/src/ggml-metal/ggml-metal-tuning.h +77 -0
  605. data/vendor/ggml/src/ggml-metal/ggml-metal.cpp +1006 -0
  606. data/vendor/ggml/src/ggml-metal/kernels/argsort.metal +337 -0
  607. data/vendor/ggml/src/ggml-metal/kernels/binbcast.metal +228 -0
  608. data/vendor/ggml/src/ggml-metal/kernels/common.h +126 -0
  609. data/vendor/ggml/src/ggml-metal/kernels/conv.metal +724 -0
  610. data/vendor/ggml/src/ggml-metal/kernels/dequantize.h +735 -0
  611. data/vendor/ggml/src/ggml-metal/kernels/fa.metal +2445 -0
  612. data/vendor/ggml/src/ggml-metal/kernels/gated_delta_net.metal +250 -0
  613. data/vendor/ggml/src/ggml-metal/kernels/misc.metal +595 -0
  614. data/vendor/ggml/src/ggml-metal/kernels/mul_mm.metal +853 -0
  615. data/vendor/ggml/src/ggml-metal/kernels/mul_mv.metal +3225 -0
  616. data/vendor/ggml/src/ggml-metal/kernels/norm.metal +308 -0
  617. data/vendor/ggml/src/ggml-metal/kernels/pool.metal +148 -0
  618. data/vendor/ggml/src/ggml-metal/kernels/quantize.h +262 -0
  619. data/vendor/ggml/src/ggml-metal/kernels/quantize.metal +480 -0
  620. data/vendor/ggml/src/ggml-metal/kernels/reduce.metal +228 -0
  621. data/vendor/ggml/src/ggml-metal/kernels/rope.metal +333 -0
  622. data/vendor/ggml/src/ggml-metal/kernels/softmax.metal +223 -0
  623. data/vendor/ggml/src/ggml-metal/kernels/solve_tri.metal +75 -0
  624. data/vendor/ggml/src/ggml-metal/kernels/ssm.metal +473 -0
  625. data/vendor/ggml/src/ggml-metal/kernels/tri.metal +69 -0
  626. data/vendor/ggml/src/ggml-metal/kernels/unary.metal +400 -0
  627. data/vendor/ggml/src/ggml-metal/kernels/upscale.metal +179 -0
  628. data/vendor/ggml/src/ggml-metal/kernels/wkv.metal +179 -0
  629. data/vendor/ggml/src/ggml-musa/CMakeLists.txt +123 -0
  630. data/vendor/ggml/src/ggml-musa/mudnn.cu +112 -0
  631. data/vendor/ggml/src/ggml-musa/mudnn.cuh +12 -0
  632. data/vendor/ggml/src/ggml-opencl/CMakeLists.txt +246 -0
  633. data/vendor/ggml/src/ggml-opencl/cl-program-cache.cpp +453 -0
  634. data/vendor/ggml/src/ggml-opencl/cl-program-cache.h +75 -0
  635. data/vendor/ggml/src/ggml-opencl/fa_tune.h +92 -0
  636. data/vendor/ggml/src/ggml-opencl/ggml-opencl.cpp +26982 -0
  637. data/vendor/ggml/src/ggml-opencl/kernels/abs.cl +113 -0
  638. data/vendor/ggml/src/ggml-opencl/kernels/add.cl +190 -0
  639. data/vendor/ggml/src/ggml-opencl/kernels/add_id.cl +42 -0
  640. data/vendor/ggml/src/ggml-opencl/kernels/argsort.cl +86 -0
  641. data/vendor/ggml/src/ggml-opencl/kernels/clamp.cl +20 -0
  642. data/vendor/ggml/src/ggml-opencl/kernels/concat.cl +118 -0
  643. data/vendor/ggml/src/ggml-opencl/kernels/conv2d.cl +185 -0
  644. data/vendor/ggml/src/ggml-opencl/kernels/conv2d_f16_f32.cl +176 -0
  645. data/vendor/ggml/src/ggml-opencl/kernels/cpy.cl +288 -0
  646. data/vendor/ggml/src/ggml-opencl/kernels/cumsum.cl +139 -0
  647. data/vendor/ggml/src/ggml-opencl/kernels/cvt.cl +2663 -0
  648. data/vendor/ggml/src/ggml-opencl/kernels/diag.cl +27 -0
  649. data/vendor/ggml/src/ggml-opencl/kernels/diag_mask_inf.cl +58 -0
  650. data/vendor/ggml/src/ggml-opencl/kernels/div.cl +138 -0
  651. data/vendor/ggml/src/ggml-opencl/kernels/embed_kernel.py +26 -0
  652. data/vendor/ggml/src/ggml-opencl/kernels/exp.cl +125 -0
  653. data/vendor/ggml/src/ggml-opencl/kernels/expm1.cl +113 -0
  654. data/vendor/ggml/src/ggml-opencl/kernels/fill.cl +17 -0
  655. data/vendor/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +421 -0
  656. data/vendor/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +422 -0
  657. data/vendor/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +2656 -0
  658. data/vendor/ggml/src/ggml-opencl/kernels/flash_attn_f32_q4_0.cl +2011 -0
  659. data/vendor/ggml/src/ggml-opencl/kernels/flash_attn_f32_q8_0.cl +1840 -0
  660. data/vendor/ggml/src/ggml-opencl/kernels/flash_attn_pre_f16.cl +156 -0
  661. data/vendor/ggml/src/ggml-opencl/kernels/gated_delta_net.cl +249 -0
  662. data/vendor/ggml/src/ggml-opencl/kernels/gelu.cl +89 -0
  663. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32.cl +162 -0
  664. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl +376 -0
  665. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_q8_1_dp4a.cl +190 -0
  666. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl +324 -0
  667. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_q8_1_dp4a.cl +169 -0
  668. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl +326 -0
  669. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl +348 -0
  670. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_q8_1_dp4a.cl +209 -0
  671. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl +328 -0
  672. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl +330 -0
  673. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl +356 -0
  674. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl +335 -0
  675. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_q8_1_dp4a.cl +200 -0
  676. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q8_0_f32_ns.cl +221 -0
  677. data/vendor/ggml/src/ggml-opencl/kernels/gemm_moe_q8_1_dp4a.cl +226 -0
  678. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_iq4_nl_f32.cl +150 -0
  679. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_iq4_nl_q8_1_dp4a.cl +143 -0
  680. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q1_0_f32.cl +94 -0
  681. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q4_0_f32.cl +139 -0
  682. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q4_0_q8_1_dp4a.cl +127 -0
  683. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q4_1_f32.cl +132 -0
  684. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q4_k_f32.cl +490 -0
  685. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q4_k_q8_1_dp4a.cl +281 -0
  686. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q5_0_f32.cl +131 -0
  687. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q5_0_q8_1_dp4a.cl +235 -0
  688. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q5_1_f32.cl +134 -0
  689. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q5_k_f32.cl +176 -0
  690. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q5_k_q8_1_dp4a.cl +164 -0
  691. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q6_k_f32.cl +245 -0
  692. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q6_k_f32_tiled.cl +136 -0
  693. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q6_k_q8_1_dp4a.cl +144 -0
  694. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q8_0_f32.cl +129 -0
  695. data/vendor/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q8_0_q8_1_dp4a.cl +212 -0
  696. data/vendor/ggml/src/ggml-opencl/kernels/gemm_xmem_f16_f32_os8.cl +233 -0
  697. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_mxfp4_f32.cl +156 -0
  698. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_mxfp4_f32_ns.cl +257 -0
  699. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q4_0_f32_ns.cl +120 -0
  700. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q4_1_f32_ns.cl +123 -0
  701. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q4_k_f32_ns.cl +266 -0
  702. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q5_0_f32_ns.cl +123 -0
  703. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q5_1_f32_ns.cl +125 -0
  704. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q5_k_f32_ns.cl +160 -0
  705. data/vendor/ggml/src/ggml-opencl/kernels/gemv_moe_q6_k_f32_ns.cl +141 -0
  706. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_iq4_nl_f32.cl +307 -0
  707. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q1_0_f32.cl +125 -0
  708. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q4_0_f32.cl +383 -0
  709. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q4_0_f32_spec.cl +272 -0
  710. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q4_1_f32.cl +384 -0
  711. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q4_k_f32.cl +823 -0
  712. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q4_k_f32_o4.cl +349 -0
  713. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q4_k_f32_tiled.cl +118 -0
  714. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q5_0_f32.cl +296 -0
  715. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q5_1_f32.cl +299 -0
  716. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q5_k_f32.cl +453 -0
  717. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q6_k_f32.cl +409 -0
  718. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q6_k_f32_o4.cl +372 -0
  719. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q6_k_f32_tiled.cl +196 -0
  720. data/vendor/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q8_0_f32.cl +280 -0
  721. data/vendor/ggml/src/ggml-opencl/kernels/get_rows.cl +193 -0
  722. data/vendor/ggml/src/ggml-opencl/kernels/glu.cl +443 -0
  723. data/vendor/ggml/src/ggml-opencl/kernels/group_norm.cl +121 -0
  724. data/vendor/ggml/src/ggml-opencl/kernels/im2col_f16.cl +57 -0
  725. data/vendor/ggml/src/ggml-opencl/kernels/im2col_f32.cl +57 -0
  726. data/vendor/ggml/src/ggml-opencl/kernels/l2_norm.cl +71 -0
  727. data/vendor/ggml/src/ggml-opencl/kernels/mean.cl +140 -0
  728. data/vendor/ggml/src/ggml-opencl/kernels/moe_add_id_glu.cl +76 -0
  729. data/vendor/ggml/src/ggml-opencl/kernels/moe_combine.cl +79 -0
  730. data/vendor/ggml/src/ggml-opencl/kernels/moe_reorder_b.cl +30 -0
  731. data/vendor/ggml/src/ggml-opencl/kernels/moe_reorder_quant_a_q8_1.cl +64 -0
  732. data/vendor/ggml/src/ggml-opencl/kernels/moe_sort_by_expert.cl +155 -0
  733. data/vendor/ggml/src/ggml-opencl/kernels/mul.cl +152 -0
  734. data/vendor/ggml/src/ggml-opencl/kernels/mul_mat_f16_f32.cl +130 -0
  735. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_f16_f32_kq_kqv.cl +273 -0
  736. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_f16_f32_l4_lm.cl +146 -0
  737. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_f32_f32_l4_lm.cl +196 -0
  738. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_iq4_nl_f32_l4_lm.cl +171 -0
  739. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q1_0_f32_l4_lm.cl +156 -0
  740. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q4_0_f32_l4_lm.cl +163 -0
  741. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q4_1_f32_l4_lm.cl +165 -0
  742. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q4_k_f32_l4_lm.cl +189 -0
  743. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q5_0_f32_l4_lm.cl +173 -0
  744. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q5_1_f32_l4_lm.cl +175 -0
  745. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q5_k_f32_l4_lm.cl +202 -0
  746. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q6_k_f32_l4_lm.cl +158 -0
  747. data/vendor/ggml/src/ggml-opencl/kernels/mul_mm_q8_0_f32_l4_lm.cl +154 -0
  748. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_f16_f16.cl +125 -0
  749. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32.cl +125 -0
  750. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_1row.cl +101 -0
  751. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +1237 -0
  752. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_mrow.cl +306 -0
  753. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_f32_f32.cl +118 -0
  754. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_id_mxfp4_f32.cl +189 -0
  755. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_id_mxfp4_f32_flat.cl +176 -0
  756. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_id_q4_0_f32_8x_flat.cl +283 -0
  757. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_id_q8_0_f32.cl +140 -0
  758. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_id_q8_0_f32_flat.cl +222 -0
  759. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_iq4_nl_f32.cl +164 -0
  760. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_iq4_nl_f32_flat.cl +202 -0
  761. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_mxfp4_f32.cl +144 -0
  762. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_mxfp4_f32_flat.cl +167 -0
  763. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32.cl +141 -0
  764. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32_flat.cl +190 -0
  765. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32.cl +192 -0
  766. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_1d_16x_flat.cl +307 -0
  767. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_1d_8x_flat.cl +265 -0
  768. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_8x_flat.cl +272 -0
  769. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_v.cl +254 -0
  770. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_1_f32.cl +219 -0
  771. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_1_f32_flat.cl +229 -0
  772. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_k_f32.cl +182 -0
  773. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q4_k_f32_flat.cl +205 -0
  774. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q5_0_f32.cl +241 -0
  775. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q5_0_f32_flat.cl +243 -0
  776. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q5_1_f32.cl +243 -0
  777. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q5_1_f32_flat.cl +247 -0
  778. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q5_k_f32.cl +187 -0
  779. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q5_k_f32_flat.cl +244 -0
  780. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q6_k_f32.cl +194 -0
  781. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q6_k_f32_flat.cl +272 -0
  782. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q8_0_f32.cl +125 -0
  783. data/vendor/ggml/src/ggml-opencl/kernels/mul_mv_q8_0_f32_flat.cl +202 -0
  784. data/vendor/ggml/src/ggml-opencl/kernels/neg.cl +125 -0
  785. data/vendor/ggml/src/ggml-opencl/kernels/norm.cl +164 -0
  786. data/vendor/ggml/src/ggml-opencl/kernels/pad.cl +39 -0
  787. data/vendor/ggml/src/ggml-opencl/kernels/quant_a_q8_1.cl +42 -0
  788. data/vendor/ggml/src/ggml-opencl/kernels/relu.cl +16 -0
  789. data/vendor/ggml/src/ggml-opencl/kernels/repeat.cl +38 -0
  790. data/vendor/ggml/src/ggml-opencl/kernels/rms_norm.cl +369 -0
  791. data/vendor/ggml/src/ggml-opencl/kernels/rope.cl +759 -0
  792. data/vendor/ggml/src/ggml-opencl/kernels/scale.cl +27 -0
  793. data/vendor/ggml/src/ggml-opencl/kernels/set_rows.cl +708 -0
  794. data/vendor/ggml/src/ggml-opencl/kernels/sigmoid.cl +29 -0
  795. data/vendor/ggml/src/ggml-opencl/kernels/silu.cl +30 -0
  796. data/vendor/ggml/src/ggml-opencl/kernels/softmax_4_f16.cl +108 -0
  797. data/vendor/ggml/src/ggml-opencl/kernels/softmax_4_f32.cl +108 -0
  798. data/vendor/ggml/src/ggml-opencl/kernels/softmax_f16.cl +107 -0
  799. data/vendor/ggml/src/ggml-opencl/kernels/softmax_f32.cl +107 -0
  800. data/vendor/ggml/src/ggml-opencl/kernels/softplus.cl +116 -0
  801. data/vendor/ggml/src/ggml-opencl/kernels/solve_tri.cl +51 -0
  802. data/vendor/ggml/src/ggml-opencl/kernels/sqr.cl +53 -0
  803. data/vendor/ggml/src/ggml-opencl/kernels/sqrt.cl +53 -0
  804. data/vendor/ggml/src/ggml-opencl/kernels/ssm_conv.cl +77 -0
  805. data/vendor/ggml/src/ggml-opencl/kernels/ssm_scan.cl +216 -0
  806. data/vendor/ggml/src/ggml-opencl/kernels/sub.cl +138 -0
  807. data/vendor/ggml/src/ggml-opencl/kernels/sum_rows.cl +140 -0
  808. data/vendor/ggml/src/ggml-opencl/kernels/tanh.cl +109 -0
  809. data/vendor/ggml/src/ggml-opencl/kernels/transpose.cl +143 -0
  810. data/vendor/ggml/src/ggml-opencl/kernels/tri.cl +32 -0
  811. data/vendor/ggml/src/ggml-opencl/kernels/tsembd.cl +48 -0
  812. data/vendor/ggml/src/ggml-opencl/kernels/upscale.cl +120 -0
  813. data/vendor/ggml/src/ggml-opencl/libdl.h +79 -0
  814. data/vendor/ggml/src/ggml-openvino/CMakeLists.txt +22 -0
  815. data/vendor/ggml/src/ggml-openvino/ggml-decoder.cpp +2057 -0
  816. data/vendor/ggml/src/ggml-openvino/ggml-decoder.h +417 -0
  817. data/vendor/ggml/src/ggml-openvino/ggml-openvino-extra.cpp +493 -0
  818. data/vendor/ggml/src/ggml-openvino/ggml-openvino-extra.h +216 -0
  819. data/vendor/ggml/src/ggml-openvino/ggml-openvino.cpp +1566 -0
  820. data/vendor/ggml/src/ggml-openvino/ggml-quants.cpp +1273 -0
  821. data/vendor/ggml/src/ggml-openvino/ggml-quants.h +186 -0
  822. data/vendor/ggml/src/ggml-openvino/model-cache.cpp +272 -0
  823. data/vendor/ggml/src/ggml-openvino/model-cache.h +56 -0
  824. data/vendor/ggml/src/ggml-openvino/openvino/decoder.h +133 -0
  825. data/vendor/ggml/src/ggml-openvino/openvino/frontend.cpp +27 -0
  826. data/vendor/ggml/src/ggml-openvino/openvino/frontend.h +23 -0
  827. data/vendor/ggml/src/ggml-openvino/openvino/input_model.cpp +17 -0
  828. data/vendor/ggml/src/ggml-openvino/openvino/input_model.h +29 -0
  829. data/vendor/ggml/src/ggml-openvino/openvino/node_context.h +171 -0
  830. data/vendor/ggml/src/ggml-openvino/openvino/op/add.cpp +45 -0
  831. data/vendor/ggml/src/ggml-openvino/openvino/op/add_id.cpp +76 -0
  832. data/vendor/ggml/src/ggml-openvino/openvino/op/argsort.cpp +47 -0
  833. data/vendor/ggml/src/ggml-openvino/openvino/op/clamp.cpp +33 -0
  834. data/vendor/ggml/src/ggml-openvino/openvino/op/concat.cpp +48 -0
  835. data/vendor/ggml/src/ggml-openvino/openvino/op/cont.cpp +40 -0
  836. data/vendor/ggml/src/ggml-openvino/openvino/op/cpy.cpp +295 -0
  837. data/vendor/ggml/src/ggml-openvino/openvino/op/cumsum.cpp +29 -0
  838. data/vendor/ggml/src/ggml-openvino/openvino/op/diag.cpp +58 -0
  839. data/vendor/ggml/src/ggml-openvino/openvino/op/div.cpp +146 -0
  840. data/vendor/ggml/src/ggml-openvino/openvino/op/fill.cpp +34 -0
  841. data/vendor/ggml/src/ggml-openvino/openvino/op/flash_attn_ext.cpp +241 -0
  842. data/vendor/ggml/src/ggml-openvino/openvino/op/gated_delta_net.cpp +327 -0
  843. data/vendor/ggml/src/ggml-openvino/openvino/op/gated_delta_net.hpp +65 -0
  844. data/vendor/ggml/src/ggml-openvino/openvino/op/gather_matmul.hpp +43 -0
  845. data/vendor/ggml/src/ggml-openvino/openvino/op/get_rows.cpp +142 -0
  846. data/vendor/ggml/src/ggml-openvino/openvino/op/glu_geglu.cpp +75 -0
  847. data/vendor/ggml/src/ggml-openvino/openvino/op/glu_geglu_quick.cpp +64 -0
  848. data/vendor/ggml/src/ggml-openvino/openvino/op/glu_swiglu.cpp +110 -0
  849. data/vendor/ggml/src/ggml-openvino/openvino/op/im2col.cpp +120 -0
  850. data/vendor/ggml/src/ggml-openvino/openvino/op/l2_norm.cpp +61 -0
  851. data/vendor/ggml/src/ggml-openvino/openvino/op/mul_mat_id.cpp +283 -0
  852. data/vendor/ggml/src/ggml-openvino/openvino/op/mulmat.cpp +100 -0
  853. data/vendor/ggml/src/ggml-openvino/openvino/op/norm.cpp +58 -0
  854. data/vendor/ggml/src/ggml-openvino/openvino/op/pad.cpp +95 -0
  855. data/vendor/ggml/src/ggml-openvino/openvino/op/permute.cpp +147 -0
  856. data/vendor/ggml/src/ggml-openvino/openvino/op/pool_2d.cpp +53 -0
  857. data/vendor/ggml/src/ggml-openvino/openvino/op/repeat.cpp +48 -0
  858. data/vendor/ggml/src/ggml-openvino/openvino/op/reshape.cpp +113 -0
  859. data/vendor/ggml/src/ggml-openvino/openvino/op/rms_norm.cpp +81 -0
  860. data/vendor/ggml/src/ggml-openvino/openvino/op/roll.cpp +36 -0
  861. data/vendor/ggml/src/ggml-openvino/openvino/op/rope.cpp +303 -0
  862. data/vendor/ggml/src/ggml-openvino/openvino/op/scale.cpp +86 -0
  863. data/vendor/ggml/src/ggml-openvino/openvino/op/set.cpp +76 -0
  864. data/vendor/ggml/src/ggml-openvino/openvino/op/set_rows.cpp +95 -0
  865. data/vendor/ggml/src/ggml-openvino/openvino/op/softmax.cpp +166 -0
  866. data/vendor/ggml/src/ggml-openvino/openvino/op/solve_tri.cpp +108 -0
  867. data/vendor/ggml/src/ggml-openvino/openvino/op/sqr.cpp +35 -0
  868. data/vendor/ggml/src/ggml-openvino/openvino/op/ssm_conv.cpp +61 -0
  869. data/vendor/ggml/src/ggml-openvino/openvino/op/sum_rows.cpp +27 -0
  870. data/vendor/ggml/src/ggml-openvino/openvino/op/transpose.cpp +54 -0
  871. data/vendor/ggml/src/ggml-openvino/openvino/op/tri.cpp +82 -0
  872. data/vendor/ggml/src/ggml-openvino/openvino/op/unary_silu.cpp +27 -0
  873. data/vendor/ggml/src/ggml-openvino/openvino/op/unary_softplus.cpp +38 -0
  874. data/vendor/ggml/src/ggml-openvino/openvino/op/view.cpp +245 -0
  875. data/vendor/ggml/src/ggml-openvino/openvino/op_table.cpp +88 -0
  876. data/vendor/ggml/src/ggml-openvino/openvino/op_table.h +67 -0
  877. data/vendor/ggml/src/ggml-openvino/openvino/pass/fuse_to_conv.cpp +212 -0
  878. data/vendor/ggml/src/ggml-openvino/openvino/pass/fuse_to_conv.h +17 -0
  879. data/vendor/ggml/src/ggml-openvino/openvino/pass/fuse_to_sdpa.cpp +60 -0
  880. data/vendor/ggml/src/ggml-openvino/openvino/pass/fuse_to_sdpa.h +17 -0
  881. data/vendor/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h +29 -0
  882. data/vendor/ggml/src/ggml-openvino/openvino/pass/mark_dequantization_subgraph.h +44 -0
  883. data/vendor/ggml/src/ggml-openvino/openvino/pass/squeeze_matmul.cpp +58 -0
  884. data/vendor/ggml/src/ggml-openvino/openvino/pass/squeeze_matmul.h +17 -0
  885. data/vendor/ggml/src/ggml-openvino/openvino/rt_info/weightless_caching_attributes.hpp +41 -0
  886. data/vendor/ggml/src/ggml-openvino/openvino/translate_session.cpp +432 -0
  887. data/vendor/ggml/src/ggml-openvino/openvino/translate_session.h +29 -0
  888. data/vendor/ggml/src/ggml-openvino/openvino/utils.cpp +886 -0
  889. data/vendor/ggml/src/ggml-openvino/openvino/utils.h +88 -0
  890. data/vendor/ggml/src/ggml-openvino/utils.cpp +1496 -0
  891. data/vendor/ggml/src/ggml-openvino/utils.h +195 -0
  892. data/vendor/ggml/src/ggml-opt.cpp +1094 -0
  893. data/vendor/ggml/src/ggml-quants.c +5667 -0
  894. data/vendor/ggml/src/ggml-quants.h +115 -0
  895. data/vendor/ggml/src/ggml-rpc/CMakeLists.txt +49 -0
  896. data/vendor/ggml/src/ggml-rpc/ggml-rpc.cpp +2351 -0
  897. data/vendor/ggml/src/ggml-rpc/transport-apple.cpp +481 -0
  898. data/vendor/ggml/src/ggml-rpc/transport-apple.h +27 -0
  899. data/vendor/ggml/src/ggml-rpc/transport.cpp +739 -0
  900. data/vendor/ggml/src/ggml-rpc/transport.h +38 -0
  901. data/vendor/ggml/src/ggml-sycl/CMakeLists.txt +218 -0
  902. data/vendor/ggml/src/ggml-sycl/add-id.cpp +81 -0
  903. data/vendor/ggml/src/ggml-sycl/add-id.hpp +8 -0
  904. data/vendor/ggml/src/ggml-sycl/backend.hpp +52 -0
  905. data/vendor/ggml/src/ggml-sycl/base.hpp +36 -0
  906. data/vendor/ggml/src/ggml-sycl/binbcast.cpp +650 -0
  907. data/vendor/ggml/src/ggml-sycl/binbcast.hpp +69 -0
  908. data/vendor/ggml/src/ggml-sycl/col2im-1d.cpp +102 -0
  909. data/vendor/ggml/src/ggml-sycl/col2im-1d.hpp +8 -0
  910. data/vendor/ggml/src/ggml-sycl/common.cpp +153 -0
  911. data/vendor/ggml/src/ggml-sycl/common.hpp +1029 -0
  912. data/vendor/ggml/src/ggml-sycl/concat.cpp +509 -0
  913. data/vendor/ggml/src/ggml-sycl/concat.hpp +20 -0
  914. data/vendor/ggml/src/ggml-sycl/conv.cpp +101 -0
  915. data/vendor/ggml/src/ggml-sycl/conv.hpp +20 -0
  916. data/vendor/ggml/src/ggml-sycl/conv2d-dw.cpp +170 -0
  917. data/vendor/ggml/src/ggml-sycl/conv2d-dw.hpp +10 -0
  918. data/vendor/ggml/src/ggml-sycl/conv2d-transpose.cpp +125 -0
  919. data/vendor/ggml/src/ggml-sycl/conv2d-transpose.hpp +10 -0
  920. data/vendor/ggml/src/ggml-sycl/conv2d.cpp +150 -0
  921. data/vendor/ggml/src/ggml-sycl/conv2d.hpp +10 -0
  922. data/vendor/ggml/src/ggml-sycl/conv3d.cpp +224 -0
  923. data/vendor/ggml/src/ggml-sycl/conv3d.hpp +8 -0
  924. data/vendor/ggml/src/ggml-sycl/convert.cpp +877 -0
  925. data/vendor/ggml/src/ggml-sycl/convert.hpp +64 -0
  926. data/vendor/ggml/src/ggml-sycl/count-equal.cpp +79 -0
  927. data/vendor/ggml/src/ggml-sycl/count-equal.hpp +9 -0
  928. data/vendor/ggml/src/ggml-sycl/cpy.cpp +1433 -0
  929. data/vendor/ggml/src/ggml-sycl/cpy.hpp +537 -0
  930. data/vendor/ggml/src/ggml-sycl/cross_entropy_loss.cpp +255 -0
  931. data/vendor/ggml/src/ggml-sycl/cross_entropy_loss.hpp +7 -0
  932. data/vendor/ggml/src/ggml-sycl/cumsum.cpp +148 -0
  933. data/vendor/ggml/src/ggml-sycl/cumsum.hpp +5 -0
  934. data/vendor/ggml/src/ggml-sycl/dequantize.hpp +1681 -0
  935. data/vendor/ggml/src/ggml-sycl/diag.cpp +67 -0
  936. data/vendor/ggml/src/ggml-sycl/diag.hpp +5 -0
  937. data/vendor/ggml/src/ggml-sycl/dmmv.cpp +2227 -0
  938. data/vendor/ggml/src/ggml-sycl/dmmv.hpp +27 -0
  939. data/vendor/ggml/src/ggml-sycl/dpct/helper.hpp +3782 -0
  940. data/vendor/ggml/src/ggml-sycl/dsv4-hc.cpp +280 -0
  941. data/vendor/ggml/src/ggml-sycl/dsv4-hc.hpp +10 -0
  942. data/vendor/ggml/src/ggml-sycl/element_wise.cpp +1432 -0
  943. data/vendor/ggml/src/ggml-sycl/element_wise.hpp +135 -0
  944. data/vendor/ggml/src/ggml-sycl/esimd.hpp +589 -0
  945. data/vendor/ggml/src/ggml-sycl/fattn-buffers.cpp +56 -0
  946. data/vendor/ggml/src/ggml-sycl/fattn-buffers.hpp +63 -0
  947. data/vendor/ggml/src/ggml-sycl/fattn-common.hpp +1185 -0
  948. data/vendor/ggml/src/ggml-sycl/fattn-mkl.cpp +689 -0
  949. data/vendor/ggml/src/ggml-sycl/fattn-onednn.cpp +450 -0
  950. data/vendor/ggml/src/ggml-sycl/fattn-onednn.hpp +18 -0
  951. data/vendor/ggml/src/ggml-sycl/fattn-tile.cpp +59 -0
  952. data/vendor/ggml/src/ggml-sycl/fattn-tile.hpp +1246 -0
  953. data/vendor/ggml/src/ggml-sycl/fattn-vec.hpp +684 -0
  954. data/vendor/ggml/src/ggml-sycl/fattn.cpp +452 -0
  955. data/vendor/ggml/src/ggml-sycl/fattn.hpp +42 -0
  956. data/vendor/ggml/src/ggml-sycl/fill.cpp +55 -0
  957. data/vendor/ggml/src/ggml-sycl/fill.hpp +5 -0
  958. data/vendor/ggml/src/ggml-sycl/fusion.cpp +212 -0
  959. data/vendor/ggml/src/ggml-sycl/fusion.hpp +17 -0
  960. data/vendor/ggml/src/ggml-sycl/fwht.cpp +119 -0
  961. data/vendor/ggml/src/ggml-sycl/fwht.hpp +12 -0
  962. data/vendor/ggml/src/ggml-sycl/gated_delta_net.cpp +366 -0
  963. data/vendor/ggml/src/ggml-sycl/gated_delta_net.hpp +19 -0
  964. data/vendor/ggml/src/ggml-sycl/gemm.hpp +93 -0
  965. data/vendor/ggml/src/ggml-sycl/getrows.cpp +368 -0
  966. data/vendor/ggml/src/ggml-sycl/getrows.hpp +20 -0
  967. data/vendor/ggml/src/ggml-sycl/ggml-sycl.cpp +7028 -0
  968. data/vendor/ggml/src/ggml-sycl/gla.cpp +106 -0
  969. data/vendor/ggml/src/ggml-sycl/gla.hpp +8 -0
  970. data/vendor/ggml/src/ggml-sycl/im2col.cpp +400 -0
  971. data/vendor/ggml/src/ggml-sycl/im2col.hpp +23 -0
  972. data/vendor/ggml/src/ggml-sycl/lightning-indexer.cpp +197 -0
  973. data/vendor/ggml/src/ggml-sycl/lightning-indexer.hpp +8 -0
  974. data/vendor/ggml/src/ggml-sycl/mem.cpp +162 -0
  975. data/vendor/ggml/src/ggml-sycl/mem.hpp +16 -0
  976. data/vendor/ggml/src/ggml-sycl/mmq.cpp +3030 -0
  977. data/vendor/ggml/src/ggml-sycl/mmq.hpp +33 -0
  978. data/vendor/ggml/src/ggml-sycl/mmvq.cpp +3033 -0
  979. data/vendor/ggml/src/ggml-sycl/mmvq.hpp +76 -0
  980. data/vendor/ggml/src/ggml-sycl/norm.cpp +963 -0
  981. data/vendor/ggml/src/ggml-sycl/norm.hpp +32 -0
  982. data/vendor/ggml/src/ggml-sycl/opt-step.cpp +131 -0
  983. data/vendor/ggml/src/ggml-sycl/opt-step.hpp +6 -0
  984. data/vendor/ggml/src/ggml-sycl/outprod.cpp +83 -0
  985. data/vendor/ggml/src/ggml-sycl/outprod.hpp +10 -0
  986. data/vendor/ggml/src/ggml-sycl/pad.cpp +97 -0
  987. data/vendor/ggml/src/ggml-sycl/pad.hpp +24 -0
  988. data/vendor/ggml/src/ggml-sycl/pad_reflect_1d.cpp +100 -0
  989. data/vendor/ggml/src/ggml-sycl/pad_reflect_1d.hpp +10 -0
  990. data/vendor/ggml/src/ggml-sycl/pool.cpp +185 -0
  991. data/vendor/ggml/src/ggml-sycl/pool.hpp +22 -0
  992. data/vendor/ggml/src/ggml-sycl/presets.hpp +79 -0
  993. data/vendor/ggml/src/ggml-sycl/quantize.hpp +133 -0
  994. data/vendor/ggml/src/ggml-sycl/quants.hpp +204 -0
  995. data/vendor/ggml/src/ggml-sycl/repeat_back.cpp +76 -0
  996. data/vendor/ggml/src/ggml-sycl/repeat_back.hpp +8 -0
  997. data/vendor/ggml/src/ggml-sycl/roll.cpp +122 -0
  998. data/vendor/ggml/src/ggml-sycl/roll.hpp +20 -0
  999. data/vendor/ggml/src/ggml-sycl/rope.cpp +651 -0
  1000. data/vendor/ggml/src/ggml-sycl/rope.hpp +26 -0
  1001. data/vendor/ggml/src/ggml-sycl/set.cpp +73 -0
  1002. data/vendor/ggml/src/ggml-sycl/set.hpp +5 -0
  1003. data/vendor/ggml/src/ggml-sycl/set_rows.cpp +577 -0
  1004. data/vendor/ggml/src/ggml-sycl/set_rows.hpp +8 -0
  1005. data/vendor/ggml/src/ggml-sycl/softmax.cpp +425 -0
  1006. data/vendor/ggml/src/ggml-sycl/softmax.hpp +24 -0
  1007. data/vendor/ggml/src/ggml-sycl/solve_tri.cpp +172 -0
  1008. data/vendor/ggml/src/ggml-sycl/solve_tri.hpp +8 -0
  1009. data/vendor/ggml/src/ggml-sycl/ssm_conv.cpp +136 -0
  1010. data/vendor/ggml/src/ggml-sycl/ssm_conv.hpp +5 -0
  1011. data/vendor/ggml/src/ggml-sycl/ssm_scan.cpp +170 -0
  1012. data/vendor/ggml/src/ggml-sycl/ssm_scan.hpp +5 -0
  1013. data/vendor/ggml/src/ggml-sycl/sycl_hw.cpp +67 -0
  1014. data/vendor/ggml/src/ggml-sycl/sycl_hw.hpp +38 -0
  1015. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq112-dv112.cpp +5 -0
  1016. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq128-dv128.cpp +5 -0
  1017. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq256-dv256.cpp +5 -0
  1018. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq40-dv40.cpp +5 -0
  1019. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq512-dv512.cpp +6 -0
  1020. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq576-dv512.cpp +5 -0
  1021. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq64-dv64.cpp +5 -0
  1022. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq72-dv72.cpp +5 -0
  1023. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq80-dv80.cpp +5 -0
  1024. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-tile-instance-dkq96-dv96.cpp +5 -0
  1025. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-f16-f16.cpp +8 -0
  1026. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-f16-q4_0.cpp +8 -0
  1027. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-f16-q4_1.cpp +8 -0
  1028. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-f16-q5_0.cpp +8 -0
  1029. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-f16-q5_1.cpp +8 -0
  1030. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-f16-q8_0.cpp +8 -0
  1031. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_0-f16.cpp +8 -0
  1032. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_0-q4_0.cpp +8 -0
  1033. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_0-q4_1.cpp +8 -0
  1034. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_0-q5_0.cpp +8 -0
  1035. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_0-q5_1.cpp +8 -0
  1036. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_0-q8_0.cpp +8 -0
  1037. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_1-f16.cpp +8 -0
  1038. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_1-q4_0.cpp +8 -0
  1039. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_1-q4_1.cpp +8 -0
  1040. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_1-q5_0.cpp +8 -0
  1041. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_1-q5_1.cpp +8 -0
  1042. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q4_1-q8_0.cpp +8 -0
  1043. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_0-f16.cpp +8 -0
  1044. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_0-q4_0.cpp +8 -0
  1045. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_0-q4_1.cpp +8 -0
  1046. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_0-q5_0.cpp +8 -0
  1047. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_0-q5_1.cpp +8 -0
  1048. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_0-q8_0.cpp +8 -0
  1049. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_1-f16.cpp +8 -0
  1050. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_1-q4_0.cpp +8 -0
  1051. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_1-q4_1.cpp +8 -0
  1052. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_1-q5_0.cpp +8 -0
  1053. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_1-q5_1.cpp +8 -0
  1054. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q5_1-q8_0.cpp +8 -0
  1055. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q8_0-f16.cpp +8 -0
  1056. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q8_0-q4_0.cpp +8 -0
  1057. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q8_0-q4_1.cpp +8 -0
  1058. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q8_0-q5_0.cpp +8 -0
  1059. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q8_0-q5_1.cpp +8 -0
  1060. data/vendor/ggml/src/ggml-sycl/template-instances/fattn-vec-instance-q8_0-q8_0.cpp +8 -0
  1061. data/vendor/ggml/src/ggml-sycl/topk-moe.cpp +620 -0
  1062. data/vendor/ggml/src/ggml-sycl/topk-moe.hpp +12 -0
  1063. data/vendor/ggml/src/ggml-sycl/tsembd.cpp +73 -0
  1064. data/vendor/ggml/src/ggml-sycl/tsembd.hpp +20 -0
  1065. data/vendor/ggml/src/ggml-sycl/type.hpp +112 -0
  1066. data/vendor/ggml/src/ggml-sycl/upscale.cpp +410 -0
  1067. data/vendor/ggml/src/ggml-sycl/upscale.hpp +9 -0
  1068. data/vendor/ggml/src/ggml-sycl/vecdotq.hpp +1726 -0
  1069. data/vendor/ggml/src/ggml-sycl/wkv.cpp +293 -0
  1070. data/vendor/ggml/src/ggml-sycl/wkv.hpp +10 -0
  1071. data/vendor/ggml/src/ggml-threading.cpp +12 -0
  1072. data/vendor/ggml/src/ggml-threading.h +14 -0
  1073. data/vendor/ggml/src/ggml-version.h.in +4 -0
  1074. data/vendor/ggml/src/ggml-virtgpu/CMakeLists.txt +70 -0
  1075. data/vendor/ggml/src/ggml-virtgpu/apir_cs_ggml-rpc-front.cpp +87 -0
  1076. data/vendor/ggml/src/ggml-virtgpu/backend/CMakeLists.txt +21 -0
  1077. data/vendor/ggml/src/ggml-virtgpu/backend/apir_cs_ggml-rpc-back.cpp +115 -0
  1078. data/vendor/ggml/src/ggml-virtgpu/backend/backend-convert.h +13 -0
  1079. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched-backend.cpp +102 -0
  1080. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched-buffer-type.cpp +105 -0
  1081. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched-buffer.cpp +179 -0
  1082. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched-device.cpp +149 -0
  1083. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched.cpp +51 -0
  1084. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched.gen.h +73 -0
  1085. data/vendor/ggml/src/ggml-virtgpu/backend/backend-dispatched.h +27 -0
  1086. data/vendor/ggml/src/ggml-virtgpu/backend/backend-virgl-apir.h +32 -0
  1087. data/vendor/ggml/src/ggml-virtgpu/backend/backend.cpp +144 -0
  1088. data/vendor/ggml/src/ggml-virtgpu/backend/shared/api_remoting.h +95 -0
  1089. data/vendor/ggml/src/ggml-virtgpu/backend/shared/apir_backend.gen.h +94 -0
  1090. data/vendor/ggml/src/ggml-virtgpu/backend/shared/apir_backend.h +50 -0
  1091. data/vendor/ggml/src/ggml-virtgpu/backend/shared/apir_cs.h +378 -0
  1092. data/vendor/ggml/src/ggml-virtgpu/backend/shared/apir_cs_ggml.h +232 -0
  1093. data/vendor/ggml/src/ggml-virtgpu/backend/shared/apir_cs_rpc.h +58 -0
  1094. data/vendor/ggml/src/ggml-virtgpu/ggml-backend-buffer-type.cpp +81 -0
  1095. data/vendor/ggml/src/ggml-virtgpu/ggml-backend-buffer.cpp +123 -0
  1096. data/vendor/ggml/src/ggml-virtgpu/ggml-backend-device.cpp +160 -0
  1097. data/vendor/ggml/src/ggml-virtgpu/ggml-backend-reg.cpp +213 -0
  1098. data/vendor/ggml/src/ggml-virtgpu/ggml-backend.cpp +72 -0
  1099. data/vendor/ggml/src/ggml-virtgpu/ggml-remoting.h +71 -0
  1100. data/vendor/ggml/src/ggml-virtgpu/ggmlremoting_functions.yaml +166 -0
  1101. data/vendor/ggml/src/ggml-virtgpu/include/apir_hw.h +9 -0
  1102. data/vendor/ggml/src/ggml-virtgpu/regenerate_remoting.py +333 -0
  1103. data/vendor/ggml/src/ggml-virtgpu/virtgpu-apir.h +15 -0
  1104. data/vendor/ggml/src/ggml-virtgpu/virtgpu-forward-backend.cpp +58 -0
  1105. data/vendor/ggml/src/ggml-virtgpu/virtgpu-forward-buffer-type.cpp +110 -0
  1106. data/vendor/ggml/src/ggml-virtgpu/virtgpu-forward-buffer.cpp +173 -0
  1107. data/vendor/ggml/src/ggml-virtgpu/virtgpu-forward-device.cpp +194 -0
  1108. data/vendor/ggml/src/ggml-virtgpu/virtgpu-forward-impl.h +36 -0
  1109. data/vendor/ggml/src/ggml-virtgpu/virtgpu-forward.gen.h +54 -0
  1110. data/vendor/ggml/src/ggml-virtgpu/virtgpu-shm.cpp +99 -0
  1111. data/vendor/ggml/src/ggml-virtgpu/virtgpu-shm.h +23 -0
  1112. data/vendor/ggml/src/ggml-virtgpu/virtgpu-utils.cpp +179 -0
  1113. data/vendor/ggml/src/ggml-virtgpu/virtgpu-utils.h +86 -0
  1114. data/vendor/ggml/src/ggml-virtgpu/virtgpu.cpp +545 -0
  1115. data/vendor/ggml/src/ggml-virtgpu/virtgpu.h +115 -0
  1116. data/vendor/ggml/src/ggml-vulkan/CMakeLists.txt +254 -0
  1117. data/vendor/ggml/src/ggml-vulkan/cmake/host-toolchain.cmake.in +15 -0
  1118. data/vendor/ggml/src/ggml-vulkan/ggml-vulkan.cpp +20349 -0
  1119. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +43 -0
  1120. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/acc.comp +37 -0
  1121. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/add.comp +69 -0
  1122. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/add1.comp +28 -0
  1123. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/add_id.comp +42 -0
  1124. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/arange.comp +20 -0
  1125. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/argmax.comp +60 -0
  1126. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/argsort.comp +86 -0
  1127. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/argsort_large.comp +114 -0
  1128. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/col2im_1d.comp +61 -0
  1129. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/concat.comp +41 -0
  1130. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/contig_copy.comp +53 -0
  1131. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_dw.comp +105 -0
  1132. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +473 -0
  1133. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/conv3d_mm.comp +424 -0
  1134. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/conv_transpose_1d.comp +98 -0
  1135. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/copy.comp +25 -0
  1136. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/copy_from_quant.comp +51 -0
  1137. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/copy_to_quant.comp +350 -0
  1138. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/copy_transpose.comp +67 -0
  1139. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/copy_transpose_02.comp +61 -0
  1140. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/count_equal.comp +31 -0
  1141. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/count_experts.comp +135 -0
  1142. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/cross_entropy_loss.comp +78 -0
  1143. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/cross_entropy_loss_back.comp +75 -0
  1144. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/cumsum.comp +83 -0
  1145. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/cumsum_multipass1.comp +60 -0
  1146. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/cumsum_multipass2.comp +66 -0
  1147. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_f32.comp +20 -0
  1148. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs.glsl +741 -0
  1149. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs_cm2.glsl +1466 -0
  1150. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_head.glsl +13 -0
  1151. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq1_m.comp +42 -0
  1152. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq1_s.comp +35 -0
  1153. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_s.comp +44 -0
  1154. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_xs.comp +43 -0
  1155. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_xxs.comp +49 -0
  1156. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq3_s.comp +40 -0
  1157. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq3_xxs.comp +51 -0
  1158. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq4_nl.comp +32 -0
  1159. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq4_xs.comp +34 -0
  1160. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_mxfp4.comp +32 -0
  1161. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_nvfp4.comp +32 -0
  1162. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q1_0.comp +29 -0
  1163. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q2_0.comp +29 -0
  1164. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q2_k.comp +34 -0
  1165. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q3_k.comp +42 -0
  1166. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_0.comp +30 -0
  1167. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_1.comp +32 -0
  1168. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_k.comp +68 -0
  1169. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_0.comp +34 -0
  1170. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_1.comp +35 -0
  1171. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_k.comp +70 -0
  1172. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q6_k.comp +33 -0
  1173. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q8_0.comp +42 -0
  1174. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dequant_tq2_0.comp +31 -0
  1175. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/diag.comp +28 -0
  1176. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/diag_mask_inf.comp +34 -0
  1177. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/div.comp +27 -0
  1178. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/dot_product_funcs.glsl +27 -0
  1179. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/fa_types.glsl +55 -0
  1180. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/bfloat16.comp +7 -0
  1181. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/coopmat.comp +7 -0
  1182. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/coopmat2.comp +7 -0
  1183. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/coopmat2_decode_vector.comp +7 -0
  1184. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/float_e2m1.comp +7 -0
  1185. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/float_e4m3.comp +7 -0
  1186. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/feature-tests/integer_dot.comp +7 -0
  1187. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/fill.comp +19 -0
  1188. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +760 -0
  1189. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_base.glsl +223 -0
  1190. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +647 -0
  1191. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp +487 -0
  1192. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_dequant.glsl +146 -0
  1193. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_mask_opt.comp +162 -0
  1194. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_mmq_funcs.glsl +203 -0
  1195. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_split_k_reduce.comp +121 -0
  1196. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/fwht.comp +115 -0
  1197. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/gated_delta_net.comp +189 -0
  1198. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/geglu.comp +13 -0
  1199. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/geglu_erf.comp +27 -0
  1200. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/geglu_quick.comp +11 -0
  1201. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/generic_binary_head.glsl +65 -0
  1202. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/generic_head.glsl +11 -0
  1203. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl +75 -0
  1204. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/get_rows.comp +42 -0
  1205. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_back.comp +25 -0
  1206. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_quant.comp +51 -0
  1207. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/gla.comp +82 -0
  1208. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl +43 -0
  1209. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl +35 -0
  1210. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/group_norm.comp +66 -0
  1211. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/im2col.comp +138 -0
  1212. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/im2col_3d.comp +124 -0
  1213. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +41 -0
  1214. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/lightning_indexer.comp +151 -0
  1215. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/log.comp +17 -0
  1216. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul.comp +27 -0
  1217. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_split_k_reduce.comp +48 -0
  1218. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec.comp +264 -0
  1219. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_base.glsl +230 -0
  1220. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iface.glsl +35 -0
  1221. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq1_m.comp +132 -0
  1222. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq1_s.comp +95 -0
  1223. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_s.comp +90 -0
  1224. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_xs.comp +105 -0
  1225. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_xxs.comp +87 -0
  1226. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq3_s.comp +93 -0
  1227. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq3_xxs.comp +88 -0
  1228. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_nc.comp +124 -0
  1229. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_p021.comp +156 -0
  1230. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q2_k.comp +128 -0
  1231. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q3_k.comp +132 -0
  1232. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q4_k.comp +134 -0
  1233. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q5_k.comp +165 -0
  1234. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q6_k.comp +130 -0
  1235. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_tq2_0.comp +102 -0
  1236. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq.comp +141 -0
  1237. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq_funcs.glsl +564 -0
  1238. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +475 -0
  1239. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +690 -0
  1240. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_funcs.glsl +670 -0
  1241. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_id_funcs.glsl +89 -0
  1242. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq.comp +317 -0
  1243. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq_funcs.glsl +488 -0
  1244. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq_shmem_types.glsl +99 -0
  1245. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/multi_add.comp +194 -0
  1246. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +44 -0
  1247. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/opt_step_adamw.comp +42 -0
  1248. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/opt_step_sgd.comp +22 -0
  1249. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/out_prod.comp +59 -0
  1250. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/pad.comp +64 -0
  1251. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/pad_reflect_1d.comp +43 -0
  1252. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/pool1d.comp +65 -0
  1253. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/pool2d.comp +74 -0
  1254. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/quantize_q8_1.comp +127 -0
  1255. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/reglu.comp +9 -0
  1256. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/repeat.comp +26 -0
  1257. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +37 -0
  1258. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +150 -0
  1259. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm_back.comp +55 -0
  1260. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm_partials.comp +65 -0
  1261. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +46 -0
  1262. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_funcs.glsl +218 -0
  1263. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_head.glsl +19 -0
  1264. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_multi.comp +17 -0
  1265. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_neox.comp +17 -0
  1266. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp +17 -0
  1267. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_params.glsl +35 -0
  1268. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/rope_vision.comp +17 -0
  1269. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/scale.comp +24 -0
  1270. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/silu_back.comp +26 -0
  1271. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/snake.comp +49 -0
  1272. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp +195 -0
  1273. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_back.comp +54 -0
  1274. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_large1.comp +62 -0
  1275. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_large2.comp +79 -0
  1276. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_large3.comp +65 -0
  1277. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_large_common.glsl +53 -0
  1278. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/solve_tri.comp +81 -0
  1279. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/ssm_conv.comp +60 -0
  1280. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/ssm_scan.comp +134 -0
  1281. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/sub.comp +29 -0
  1282. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/sum_rows.comp +47 -0
  1283. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/sum_rows.glsl +19 -0
  1284. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/swiglu.comp +9 -0
  1285. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/swiglu_clamp.comp +12 -0
  1286. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/swiglu_oai.comp +14 -0
  1287. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/timestep_embedding.comp +42 -0
  1288. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/topk_argsort.comp +118 -0
  1289. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/topk_moe.comp +221 -0
  1290. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/topk_nary_search.comp +246 -0
  1291. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/topk_radix_select.comp +144 -0
  1292. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/tri.comp +42 -0
  1293. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/types.glsl +1938 -0
  1294. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/unary.comp +168 -0
  1295. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/upscale.comp +178 -0
  1296. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/utils.glsl +37 -0
  1297. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +1367 -0
  1298. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/wkv6.comp +87 -0
  1299. data/vendor/ggml/src/ggml-vulkan/vulkan-shaders/wkv7.comp +91 -0
  1300. data/vendor/ggml/src/ggml-webgpu/CMakeLists.txt +83 -0
  1301. data/vendor/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp +3457 -0
  1302. data/vendor/ggml/src/ggml-webgpu/ggml-webgpu.cpp +4790 -0
  1303. data/vendor/ggml/src/ggml-webgpu/pre_wgsl.hpp +808 -0
  1304. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/add_id.wgsl +64 -0
  1305. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/argmax.wgsl +72 -0
  1306. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/argsort.wgsl +102 -0
  1307. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/argsort_merge.wgsl +134 -0
  1308. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/binary.wgsl +142 -0
  1309. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/common_decls.tmpl +967 -0
  1310. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/concat.wgsl +92 -0
  1311. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/conv2d.wgsl +127 -0
  1312. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/conv2d_dw.wgsl +100 -0
  1313. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/cpy.wgsl +84 -0
  1314. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/cumsum.wgsl +66 -0
  1315. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/embed_wgsl.py +89 -0
  1316. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn.wgsl +408 -0
  1317. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_decls.tmpl +134 -0
  1318. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_staging.tmpl +136 -0
  1319. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_tile.wgsl +240 -0
  1320. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_blk.wgsl +101 -0
  1321. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_reduce.wgsl +84 -0
  1322. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl +503 -0
  1323. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/gated_delta_net.wgsl +149 -0
  1324. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/get_rows.wgsl +794 -0
  1325. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/glu.wgsl +178 -0
  1326. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/im2col.wgsl +77 -0
  1327. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/memset.wgsl +40 -0
  1328. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_decls.tmpl +1052 -0
  1329. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id.wgsl +195 -0
  1330. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_gather.wgsl +52 -0
  1331. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_vec.wgsl +154 -0
  1332. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_reg_tile.wgsl +159 -0
  1333. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_subgroup_matrix.wgsl +210 -0
  1334. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec.wgsl +167 -0
  1335. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_acc.tmpl +1560 -0
  1336. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_q_acc.tmpl +297 -0
  1337. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/pad.wgsl +86 -0
  1338. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/quant_inner_loops.tmpl +21 -0
  1339. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/quantize_q8.wgsl +178 -0
  1340. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/repeat.wgsl +70 -0
  1341. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/rms_norm_mul.wgsl +151 -0
  1342. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/rope.wgsl +228 -0
  1343. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/row_norm.wgsl +152 -0
  1344. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/scale.wgsl +65 -0
  1345. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/set.wgsl +109 -0
  1346. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/set_rows.wgsl +108 -0
  1347. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/set_rows_quant.wgsl +224 -0
  1348. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/soft_max.wgsl +210 -0
  1349. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/solve_tri.wgsl +120 -0
  1350. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/ssm_conv.wgsl +65 -0
  1351. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/ssm_scan.wgsl +247 -0
  1352. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/sum_rows.wgsl +55 -0
  1353. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/unary.wgsl +213 -0
  1354. data/vendor/ggml/src/ggml-webgpu/wgsl-shaders/upscale.wgsl +240 -0
  1355. data/vendor/ggml/src/ggml-zdnn/CMakeLists.txt +36 -0
  1356. data/vendor/ggml/src/ggml-zdnn/common.hpp +59 -0
  1357. data/vendor/ggml/src/ggml-zdnn/ggml-zdnn.cpp +638 -0
  1358. data/vendor/ggml/src/ggml-zdnn/mmf.cpp +80 -0
  1359. data/vendor/ggml/src/ggml-zdnn/mmf.hpp +12 -0
  1360. data/vendor/ggml/src/ggml-zdnn/utils.cpp +79 -0
  1361. data/vendor/ggml/src/ggml-zdnn/utils.hpp +19 -0
  1362. data/vendor/ggml/src/ggml-zendnn/CMakeLists.txt +91 -0
  1363. data/vendor/ggml/src/ggml-zendnn/ggml-zendnn.cpp +838 -0
  1364. data/vendor/ggml/src/ggml.c +8088 -0
  1365. data/vendor/ggml/src/ggml.cpp +26 -0
  1366. data/vendor/ggml/src/gguf.cpp +1706 -0
  1367. metadata +1459 -0
@@ -0,0 +1,1496 @@
1
+ #include "utils.h"
2
+
3
+ #include "ggml-impl.h"
4
+ #include "ggml-openvino-extra.h"
5
+ #include "ggml-openvino/ggml-decoder.h"
6
+ #include "ggml.h"
7
+ #include "model-cache.h"
8
+ #include "openvino/frontend.h"
9
+ #include "openvino/input_model.h"
10
+
11
+ #include <algorithm>
12
+ #include <cassert>
13
+ #include <cmath>
14
+ #include <cstddef>
15
+ #include <cstdint>
16
+ #include <cstdlib>
17
+ #include <cstring>
18
+ #include <fstream>
19
+ #include <functional>
20
+ #include <future>
21
+ #include <iomanip>
22
+ #include <iostream>
23
+ #include <memory>
24
+ #include <openvino/core/any.hpp>
25
+ #include <openvino/core/graph_util.hpp>
26
+ #include <openvino/core/shape.hpp>
27
+ #include <openvino/core/type/float16.hpp>
28
+ #include <openvino/frontend/manager.hpp>
29
+ #include <openvino/openvino.hpp>
30
+ #include <openvino/runtime/compiled_model.hpp>
31
+ #include <openvino/runtime/infer_request.hpp>
32
+ #include <openvino/runtime/intel_gpu/ocl/ocl.hpp>
33
+ #include <openvino/runtime/intel_npu/properties.hpp>
34
+ #include <openvino/runtime/properties.hpp>
35
+ #include <openvino/runtime/tensor.hpp>
36
+ #include <optional>
37
+ #include <string>
38
+ #include <unordered_map>
39
+ #include <vector>
40
+
41
+ // Suppress deprecation warning for ov::Tensor::data()
42
+ #pragma GCC diagnostic push
43
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
44
+
45
+ enum ggml_status ov_graph_compute(ggml_cgraph * cgraph, ggml_backend_t backend) {
46
+ ggml_backend_openvino_context * ctx = (ggml_backend_openvino_context *) backend->context;
47
+ try {
48
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DUMP_CGRAPH")) {
49
+ std::string filename = "cgraph_ov.txt";
50
+ GgmlOvDecoder::dump_cgraph(cgraph, filename);
51
+ }
52
+
53
+ const auto is_static = ggml_openvino_is_npu() || ggml_openvino_getenv_int("GGML_OPENVINO_FORCE_STATIC");
54
+
55
+ GGML_ASSERT(ctx->runtime_context != nullptr);
56
+ std::shared_ptr<ov_runtime_context> r_ctx = std::static_pointer_cast<ov_runtime_context>(ctx->runtime_context);
57
+
58
+ return is_static ? ov_graph_compute_static(cgraph, r_ctx) : ov_graph_compute_dynamic(cgraph, r_ctx);
59
+ } catch (const ov::Exception & e) {
60
+ GGML_LOG_ERROR("GGML OpenVINO backend ov::Exception: %s\n", e.what());
61
+ return GGML_STATUS_FAILED;
62
+ } catch (const std::exception & e) {
63
+ GGML_LOG_ERROR("GGML OpenVINO backend std::exception: %s\n", e.what());
64
+ return GGML_STATUS_FAILED;
65
+ } catch (...) {
66
+ GGML_LOG_ERROR("GGML OpenVINO backend unknown exception\n");
67
+ return GGML_STATUS_FAILED;
68
+ }
69
+ }
70
+
71
+ // For a KV cache input, return an ov::Tensor sized to n_kv (== attention_size
72
+ // for that layer) instead of the fully-allocated ctx_per_seq. Pre-conditions:
73
+ // * non-static (CPU/GPU) backend, single sequence, seq_active_start == 0
74
+ // * ggml KV layout is a contiguous [1, 1, ctx_per_seq, n_heads_kv*head_size]
75
+ // so the first n_kv rows are the live prefix and shrinking the ctx axis
76
+ // gives a valid tensor over the same host storage
77
+ // * not an SWA layer (ring cache): once the window has wrapped the first
78
+ // n_kv rows no longer contain the live prefix
79
+ // On any unmet pre-condition returns std::nullopt; the caller falls back to
80
+ // the full-size tensor.
81
+ static std::optional<ov::Tensor> try_make_kv_sliced_tensor(std::shared_ptr<GgmlOvDecoder> ggml_decoder,
82
+ const std::string & name,
83
+ const ggml_tensor * ggml_tensor) {
84
+ static const bool kv_slice_disabled = ggml_openvino_getenv_int("GGML_OPENVINO_DISABLE_KV_SLICE");
85
+ if (kv_slice_disabled) {
86
+ return std::nullopt;
87
+ }
88
+ if (ggml_decoder->is_static() || ggml_decoder->is_stateful()) {
89
+ return std::nullopt;
90
+ }
91
+ if (ggml_tensor->op != GGML_OP_NONE || ggml_tensor->view_src != nullptr) {
92
+ return std::nullopt;
93
+ }
94
+ const auto * op = ggml_decoder->get_tensor_used_op(ggml_tensor);
95
+ if (!GgmlOvDecoder::is_kvcache(ggml_tensor, op)) {
96
+ return std::nullopt;
97
+ }
98
+
99
+ const auto & compute_params = ggml_decoder->get_compute_params();
100
+ if (compute_params.n_seq_active != 1 || compute_params.seq_active_start != 0) {
101
+ return std::nullopt;
102
+ }
103
+
104
+ int layer;
105
+ if (auto layer_opt = extract_layer_from_name(name); layer_opt.has_value()) {
106
+ layer = layer_opt.value();
107
+ } else {
108
+ return std::nullopt;
109
+ }
110
+
111
+ const bool is_swa = ggml_decoder->is_swa_layer(layer);
112
+ if (is_swa) {
113
+ return std::nullopt;
114
+ }
115
+ const int ctx_per_seq = ggml_decoder->get_ctx_per_seq();
116
+ const int n_kv = compute_params.attention_size;
117
+ if (ctx_per_seq <= 0 || n_kv <= 0 || n_kv >= ctx_per_seq) {
118
+ return std::nullopt;
119
+ }
120
+
121
+ ov::Shape full_shape = ggml_decoder->get_shape(ggml_tensor);
122
+ if (full_shape.size() != 4 || full_shape[0] != 1 || full_shape[1] != 1 ||
123
+ static_cast<int>(full_shape[2]) != ctx_per_seq) {
124
+ return std::nullopt;
125
+ }
126
+
127
+ ov::Shape sliced_shape = full_shape;
128
+ sliced_shape[2] = static_cast<size_t>(n_kv);
129
+
130
+ // Disabling for now as gpu has bug with in-place ScatterUpdate with remote tensors, can re-enable once CVS-186519 is fixed
131
+ // if (ggml_openvino_buffer_is_remote(ggml_tensor)) {
132
+ // auto remote_context = ggml_openvino_get_remote_context();
133
+ // auto gpu_context = remote_context->as<ov::intel_gpu::ocl::ClContext>();
134
+ // return gpu_context.create_tensor(ggml_decoder->get_ov_type(ggml_tensor), sliced_shape, ggml_tensor->data);
135
+ // }
136
+
137
+ return ov::Tensor(ggml_decoder->get_ov_type(ggml_tensor), sliced_shape, ggml_tensor->data);
138
+ }
139
+
140
+ static uint64_t ggml_openvino_model_cache_extra_cfg(const std::string & device, bool stateful) {
141
+ const char * manual_gqa_env = ggml_openvino_getenv_str("GGML_OPENVINO_MANUAL_GQA_ATTN");
142
+ const bool manual_gqa_enabled = manual_gqa_env != nullptr ?
143
+ ggml_openvino_getenv_int("GGML_OPENVINO_MANUAL_GQA_ATTN") > 0 :
144
+ device == "GPU";
145
+
146
+ uint64_t extra_cfg = 0;
147
+ extra_cfg = extra_cfg * 131 + (stateful ? 1u : 0u);
148
+ extra_cfg = extra_cfg * 131 + (ggml_openvino_reduce_compile_mem_enabled() ? 1u : 0u);
149
+ extra_cfg = extra_cfg * 131 + (ggml_openvino_getenv_int("GGML_OPENVINO_DISABLE_KV_SLICE") ? 1u : 0u);
150
+ extra_cfg = extra_cfg * 131 + (manual_gqa_enabled ? 1u : 0u);
151
+ return extra_cfg;
152
+ }
153
+
154
+ ov::Tensor create_ov_output_tensor(std::shared_ptr<GgmlOvDecoder> ggml_decoder,
155
+ std::shared_ptr<ov::InferRequest> infer_request,
156
+ int output_index,
157
+ const ggml_tensor * ggml_tensor) {
158
+ if (auto sliced = try_make_kv_sliced_tensor(ggml_decoder, std::string(ggml_tensor->name), ggml_tensor)) {
159
+ return *sliced;
160
+ }
161
+
162
+ // Disabling for now as gpu has bug with in-place ScatterUpdate with remote tensors, can re-enable once CVS-186519 is fixed
163
+ // if (ggml_tensor->extra != nullptr && !ggml_decoder->is_splited_model()) {
164
+ // auto * extra_base = static_cast<ggml_openvino_extra_base *>(ggml_tensor->extra);
165
+ // if (extra_base->type == ggml_openvino_extra_base::Type::TENSOR) {
166
+ // auto * tensor_extra = static_cast<ggml_openvino_tensor_extra *>(extra_base);
167
+ // return *tensor_extra->tensor;
168
+ // }
169
+ // }
170
+
171
+ auto output_type = ggml_decoder->get_ov_type(ggml_tensor);
172
+ ov::Shape output_shape;
173
+ void * output_data = ggml_tensor->data;
174
+ if (ggml_decoder->is_static()) {
175
+ output_shape = infer_request->get_output_tensor(output_index).get_shape();
176
+ } else {
177
+ // For a CPY into a padded view_src (e.g. a padded KV cache buffer), the
178
+ // OV ScatterUpdate node outputs the full view_src shape, not the CPY node's
179
+ // own (smaller) shape. Using the CPY shape here causes set_output_tensor to
180
+ // fail with a shape-incompatibility error. Use view_src's shape and data
181
+ // pointer instead so the OV tensor matches the model output exactly.
182
+ if (ggml_tensor->op == GGML_OP_CPY && ggml_tensor->view_src != nullptr &&
183
+ ggml_nbytes(ggml_tensor) != ggml_nbytes(ggml_tensor->view_src)) {
184
+ output_shape = ggml_decoder->get_shape(ggml_tensor->view_src);
185
+ output_data = ggml_tensor->view_src->data;
186
+ } else {
187
+ output_shape = ggml_decoder->get_shape(ggml_tensor);
188
+ }
189
+ }
190
+ ov::Tensor output_tensor(output_type, output_shape, output_data);
191
+ return output_tensor;
192
+ }
193
+
194
+ enum ggml_status ov_graph_compute_dynamic(ggml_cgraph * cgraph, std::shared_ptr<ov_runtime_context> r_ctx) {
195
+ auto & core = ov_singleton_core();
196
+ const auto & config = ggml_openvino_get_compile_config();
197
+ const auto & device = r_ctx->device;
198
+ const auto & stateful = r_ctx->stateful;
199
+ static auto is_static = false;
200
+
201
+ static const bool cache_disabled = ggml_openvino_getenv_int("GGML_OPENVINO_DISABLE_CACHE");
202
+
203
+ // is_model_splitted is O(n_nodes^2) plus a create_weight_nodes scan and takes ~20 ms
204
+ // on a Llama-1B decode graph. It is called once per graph_compute invocation but the
205
+ // graph shape is identical across all decode steps, so memoize by graph_key: compute
206
+ // graph_key first (a few hundred us), and if the same key is already in decoder_cache
207
+ // we know the graph is not splitted (only not-splitted graphs get inserted there).
208
+ graph_key key(cgraph);
209
+ bool key_seen = false;
210
+ if (!cache_disabled) {
211
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
212
+ key_seen = r_ctx->decoder_cache.find(key) != r_ctx->decoder_cache.end();
213
+ }
214
+
215
+ bool model_is_splitted = key_seen ? false : is_model_splitted(cgraph);
216
+
217
+ if (is_naive(cgraph)) {
218
+ if (!model_is_splitted) {
219
+ return naive_compute(cgraph, core, device, config);
220
+ }
221
+ }
222
+
223
+ auto start_time = ggml_time_us();
224
+
225
+ std::shared_ptr<GgmlOvDecoder> ggml_decoder;
226
+ std::shared_ptr<ov::InferRequest> infer_request;
227
+ ModelParams m_params;
228
+ ComputeParams c_params;
229
+ std::tie(m_params, c_params) = GgmlOvDecoder::compute_llm_params(cgraph, is_static);
230
+
231
+ const bool cache_enabled = !model_is_splitted && !cache_disabled;
232
+ bool cache_hit = false;
233
+
234
+ int64_t decoder_end_time;
235
+ int64_t conversion_end_time;
236
+ int64_t compile_end_time;
237
+ int64_t infer_end_time;
238
+ int64_t ov_raw_infer_start;
239
+
240
+ {
241
+ std::shared_ptr<decoder_runtime_ctx> entry;
242
+ ModelParams old_m_params;
243
+
244
+ if (cache_enabled) {
245
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
246
+ auto it = r_ctx->decoder_cache.find(key);
247
+ cache_hit = it != r_ctx->decoder_cache.end();
248
+ if (cache_hit) {
249
+ entry = it->second;
250
+ } else {
251
+ r_ctx->clear_caches_locked();
252
+ auto mutex = std::make_shared<std::mutex>();
253
+ entry = std::make_shared<decoder_runtime_ctx>(mutex);
254
+ r_ctx->decoder_cache[key] = entry;
255
+ }
256
+ } else {
257
+ auto mutex = std::make_shared<std::mutex>();
258
+ entry = std::make_shared<decoder_runtime_ctx>(mutex);
259
+ cache_hit = false;
260
+ }
261
+
262
+ std::lock_guard<std::mutex> lock(*(entry->mutex));
263
+
264
+ if (cache_hit) {
265
+ ggml_decoder = entry->ptr;
266
+ old_m_params = ggml_decoder->get_model_params();
267
+ if (!ggml_decoder->is_splited_model()) {
268
+ cache_hit = old_m_params.can_reuse_dynamically(m_params);
269
+ }
270
+ }
271
+
272
+ std::vector<std::string> ov_input_names;
273
+ std::vector<std::string> ov_output_names;
274
+
275
+ if (cache_hit) {
276
+ std::map<std::string, std::shared_ptr<ov::Node>> model_weights;
277
+ ggml_decoder->set_compute_params(c_params);
278
+ ggml_decoder->set_model_params(m_params);
279
+ if (old_m_params.kv_buffer_changed(m_params)) {
280
+ ggml_decoder->update_io(cgraph);
281
+ }
282
+ ggml_decoder->add_extra_inputs();
283
+ {
284
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
285
+ infer_request = r_ctx->infer_request_cache.at(key);
286
+ ov_input_names = r_ctx->ov_input_names_cache.at(key);
287
+ ov_output_names = r_ctx->ov_output_names_cache.at(key);
288
+ }
289
+
290
+ if (stateful) {
291
+ const auto * inp_pos = get_inp_pos_tensor(cgraph);
292
+ int32_t * pos_data = (int32_t *) inp_pos->data;
293
+ auto pos_shape = ggml_decoder->get_shape(inp_pos);
294
+ if (pos_data[0] == 0) {
295
+ infer_request->reset_state();
296
+ r_ctx->stateful_kv_size = pos_shape[3];
297
+ } else if (r_ctx->stateful_kv_size == static_cast<size_t>(pos_data[0])) {
298
+ r_ctx->stateful_kv_size += pos_shape[3];
299
+ } else {
300
+ auto states = infer_request->query_state();
301
+ for (auto state : states) {
302
+ auto state_tensor = state.get_state();
303
+ auto state_tensor_shape = state_tensor.get_shape();
304
+ if (static_cast<uint32_t>(pos_data[0]) > r_ctx->stateful_kv_size) {
305
+ std::string state_name;
306
+ try {
307
+ state_name = r_ctx->kv_state_input_name_map.at(state.get_name());
308
+ } catch (...) {
309
+ GGML_LOG_ERROR(
310
+ "GGML OpenVINO backend stateful inference failed: no input found for the state\n");
311
+ return GGML_STATUS_FAILED;
312
+ }
313
+ auto kv_tensor = get_ov_input_tensor(ggml_decoder, state_name);
314
+ kv_tensor.set_shape({state_tensor_shape[0], kv_tensor.get_shape()[2], state_tensor_shape[2],
315
+ state_tensor_shape[3]});
316
+ state_tensor = kv_tensor;
317
+ state_tensor_shape = state_tensor.get_shape();
318
+ }
319
+ ov::Coordinate begin = {0, 0, 0, 0};
320
+ ov::Coordinate end = {state_tensor_shape[0], static_cast<uint32_t>(pos_data[0]),
321
+ state_tensor_shape[2], state_tensor_shape[3]};
322
+ ov::Tensor new_state_tensor(state_tensor, begin, end);
323
+ state.set_state(new_state_tensor);
324
+ }
325
+ r_ctx->stateful_kv_size = pos_data[0] + pos_shape[3];
326
+ }
327
+ }
328
+
329
+ decoder_end_time = ggml_time_us();
330
+ conversion_end_time = decoder_end_time;
331
+ compile_end_time = decoder_end_time;
332
+ } else {
333
+ // Fail fast: a cache-miss recompile feeds weight data to compile_model, but
334
+ // GGML_OPENVINO_RELEASE_WEIGHTS (or GGML_OPENVINO_MEMORY_OPTIMIZE on GPU)
335
+ // may have already dropped the host weight pages
336
+ // (they would read as zeros). That mode requires stable graph shapes.
337
+ if (ggml_openvino_weight_buffers_released()) {
338
+ GGML_ABORT(
339
+ "ggml-openvino: a new graph needs to be compiled but host weight buffers were already "
340
+ "released via GGML_OPENVINO_RELEASE_WEIGHTS/GGML_OPENVINO_MEMORY_OPTIMIZE. This mode requires "
341
+ "stable graph shapes; disable host weight release for dynamic workloads.");
342
+ }
343
+ if (cache_enabled) {
344
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
345
+ r_ctx->infer_request_cache.erase(key);
346
+ }
347
+
348
+ // Frontend-level compiled-model cache (GGML_OPENVINO_COMPILED_MODEL_CACHE_DIR): if this model
349
+ // was compiled before, import the saved blob and skip requant + convert +
350
+ // compile. Only the dynamic single-model path is cached (split models compile
351
+ // two graphs and are left to the plugin-level ov::cache_dir). The decoder is
352
+ // still needed for I/O mapping, but can be built without weight nodes since
353
+ // the weights are baked into the imported CompiledModel.
354
+ const std::string model_cache_dir = ggml_openvino_model_cache_dir();
355
+ uint64_t model_fp = 0;
356
+ std::string blob_path, manifest_path;
357
+ bool imported = false;
358
+ // When the frontend model cache is active it supersedes the plugin-level
359
+ // ov::cache_dir: a blob exported from a model compiled WITH cache_dir cannot
360
+ // be re-imported (import returns an uninitialized model). Strip cache_dir /
361
+ // cache_mode from the config used for the cached compile and the import.
362
+ ov::AnyMap mc_config = config;
363
+ if (!model_cache_dir.empty()) {
364
+ mc_config.erase("CACHE_DIR");
365
+ mc_config.erase("CACHE_MODE");
366
+ }
367
+ if (!model_cache_dir.empty() && !model_is_splitted) {
368
+ const uint64_t extra_cfg = ggml_openvino_model_cache_extra_cfg(device, stateful);
369
+ model_fp = ggml_openvino_model_fingerprint(cgraph, device, /*fa=*/true, m_params.rope_params,
370
+ 15, extra_cfg);
371
+ blob_path = ggml_openvino_model_cache_blob_path(model_cache_dir, model_fp);
372
+ manifest_path = ggml_openvino_model_cache_manifest_path(model_cache_dir, model_fp);
373
+
374
+ std::ifstream blob_in(blob_path, std::ios::binary);
375
+ bool blob_ok = blob_in.is_open();
376
+ bool manifest_ok = blob_ok && ggml_openvino_model_cache_verify_manifest(manifest_path, cgraph, model_fp);
377
+ if (blob_ok && manifest_ok) {
378
+ int64_t import_start = ggml_time_us();
379
+ try {
380
+ ov::CompiledModel cm;
381
+ auto remote_context = ggml_openvino_get_remote_context();
382
+ if (remote_context.has_value()) {
383
+ cm = core.import_model(blob_in, remote_context.value(), mc_config);
384
+ } else {
385
+ cm = core.import_model(blob_in, device, mc_config);
386
+ }
387
+ // Lightweight decoder: names-only weight map (membership is all the
388
+ // decoder needs; weights live in the imported model).
389
+ std::map<std::string, std::shared_ptr<ov::Node>> weight_names;
390
+ for (const auto & n : GgmlOvDecoder::collect_weight_names(cgraph)) {
391
+ weight_names[n] = nullptr;
392
+ }
393
+ ggml_decoder = std::make_shared<GgmlOvDecoder>(cgraph, m_params, c_params, weight_names,
394
+ is_static, stateful, model_is_splitted);
395
+ infer_request = std::make_shared<ov::InferRequest>(cm.create_infer_request());
396
+ entry->ptr = ggml_decoder;
397
+ // Names must match the decoder's ggml-tensor keys. The non-cached
398
+ // path keys off Parameter/Result *friendly names* (set by the
399
+ // frontend); export_model preserves these, and each compiled-model
400
+ // port's node is exactly that Parameter/Result. Use the port nodes
401
+ // directly (NOT get_runtime_model(), whose graph differs and is
402
+ // unsafe to deref this way).
403
+ for (const auto & p : cm.inputs()) {
404
+ ov_input_names.push_back(p.get_node()->get_friendly_name());
405
+ }
406
+ for (const auto & o : cm.outputs()) {
407
+ ov_output_names.push_back(o.get_node()->get_friendly_name());
408
+ }
409
+ imported = true;
410
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_PROFILING")) {
411
+ GGML_LOG_INFO(" - Model cache import time: %.3f ms \n",
412
+ (ggml_time_us() - import_start) / 1000.0);
413
+ }
414
+ GGML_LOG_INFO("ggml-openvino: model cache HIT %s\n", blob_path.c_str());
415
+ } catch (const std::exception & e) {
416
+ GGML_LOG_WARN("ggml-openvino: model cache import failed (%s), recompiling\n", e.what());
417
+ imported = false;
418
+ }
419
+ }
420
+ }
421
+
422
+ std::shared_ptr<ov::Model> model;
423
+ if (imported) {
424
+ decoder_end_time = conversion_end_time = compile_end_time = ggml_time_us();
425
+ } else {
426
+ auto model_weights = GgmlOvDecoder::create_weight_nodes(cgraph);
427
+
428
+ ggml_decoder = std::make_shared<GgmlOvDecoder>(cgraph, m_params, c_params, model_weights, is_static,
429
+ stateful, model_is_splitted);
430
+ decoder_end_time = ggml_time_us();
431
+
432
+ auto input_model = std::make_shared<ov::frontend::ggml::InputModel>(ggml_decoder);
433
+ model = ov::frontend::ggml::FrontEnd::convert(input_model);
434
+ ggml_decoder->clear_model_weights();
435
+ conversion_end_time = ggml_time_us();
436
+
437
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DUMP_IR")) {
438
+ char timestamped_filename[64];
439
+ auto timestamp = (long long) ggml_time_us();
440
+ snprintf(timestamped_filename, sizeof(timestamped_filename), "model_%lld.xml", timestamp);
441
+ ov::serialize(model, timestamped_filename);
442
+ }
443
+
444
+ // Use the cache-stripped config when the frontend model cache is active, so
445
+ // the resulting CompiledModel can be exported and later re-imported.
446
+ const ov::AnyMap & compile_config = model_cache_dir.empty() ? config : mc_config;
447
+ ov::CompiledModel compiled_model;
448
+ auto remote_context = ggml_openvino_get_remote_context();
449
+ if (remote_context.has_value()) {
450
+ compiled_model = core.compile_model(model, remote_context.value(), compile_config);
451
+ } else {
452
+ compiled_model = core.compile_model(model, device, compile_config);
453
+ }
454
+ compile_end_time = ggml_time_us();
455
+
456
+ // Export to the frontend model cache for next time. Publish the blob first,
457
+ // then the manifest, so a cache hit only sees fully written artifacts.
458
+ if (!model_cache_dir.empty() && !model_is_splitted && model_fp != 0) {
459
+ try {
460
+ const std::string blob_tmp = blob_path + ".tmp";
461
+ const std::string manifest_tmp = manifest_path + ".tmp";
462
+ if (ggml_openvino_model_cache_write_manifest(manifest_tmp, cgraph, model_fp)) {
463
+ std::ofstream blob_out(blob_tmp, std::ios::binary | std::ios::trunc);
464
+ if (blob_out.is_open()) {
465
+ compiled_model.export_model(blob_out);
466
+ blob_out.close();
467
+ if (blob_out.good()) {
468
+ if (std::rename(blob_tmp.c_str(), blob_path.c_str()) == 0 &&
469
+ std::rename(manifest_tmp.c_str(), manifest_path.c_str()) == 0) {
470
+ GGML_LOG_INFO("ggml-openvino: model cache WROTE %s\n", blob_path.c_str());
471
+ } else {
472
+ std::remove(blob_tmp.c_str());
473
+ std::remove(manifest_tmp.c_str());
474
+ }
475
+ } else {
476
+ std::remove(blob_tmp.c_str());
477
+ std::remove(manifest_tmp.c_str());
478
+ }
479
+ } else {
480
+ std::remove(manifest_tmp.c_str());
481
+ }
482
+ }
483
+ } catch (const std::exception & e) {
484
+ GGML_LOG_WARN("ggml-openvino: model cache export failed: %s\n", e.what());
485
+ }
486
+ }
487
+
488
+ infer_request = std::make_shared<ov::InferRequest>(compiled_model.create_infer_request());
489
+ entry->ptr = ggml_decoder;
490
+
491
+ for (const auto & ov_param : model->get_parameters()) {
492
+ ov_input_names.push_back(ov_param->get_friendly_name());
493
+ }
494
+ for (const auto & ov_output : model->get_results()) {
495
+ ov_output_names.push_back(ov_output->get_friendly_name());
496
+ }
497
+ } // end non-imported (compile) path
498
+
499
+ if (cache_enabled) {
500
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
501
+ r_ctx->infer_request_cache[key] = infer_request;
502
+ r_ctx->ov_input_names_cache[key] = ov_input_names;
503
+ r_ctx->ov_output_names_cache[key] = ov_output_names;
504
+ }
505
+
506
+ if (stateful && cache_enabled) {
507
+ const auto * inp_pos = get_inp_pos_tensor(cgraph);
508
+ auto pos_shape = ggml_decoder->get_shape(inp_pos);
509
+ r_ctx->stateful_kv_size = pos_shape[3];
510
+ const auto kv_param_res_names = ggml_decoder->get_kv_param_res_names();
511
+ for (const auto & pair : kv_param_res_names) {
512
+ r_ctx->kv_state_input_name_map[pair.first + pair.second] = pair.first;
513
+ }
514
+ }
515
+ }
516
+
517
+ for (size_t i = 0; i < ov_input_names.size(); i++) {
518
+ auto param_name = ov_input_names[i];
519
+ auto input_tensor = get_ov_input_tensor(ggml_decoder, param_name);
520
+ infer_request->set_input_tensor(i, input_tensor);
521
+
522
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_INPUT")) {
523
+ print_input_tensor_info(param_name, input_tensor);
524
+ }
525
+ }
526
+
527
+ for (size_t i = 0; i < ov_output_names.size(); i++) {
528
+ // Debug-only outputs added via GGML_OPENVINO_DEBUG_NODE (see
529
+ // translate_session.cpp) have no corresponding ggml tensor; leave
530
+ // them unbound so OpenVINO allocates its own tensor for them,
531
+ // rather than aliasing a ggml buffer that may be overwritten by a
532
+ // later in-place op before we get to read it.
533
+ const auto & model_outputs = ggml_decoder->get_model_outputs();
534
+ auto model_output_it = model_outputs.find(ov_output_names[i]);
535
+ if (model_output_it == model_outputs.end()) {
536
+ continue;
537
+ }
538
+ auto * ggml_tensor = model_output_it->second;
539
+ if (ggml_nbytes(ggml_tensor) == 0) {
540
+ continue;
541
+ }
542
+ auto output_tensor = create_ov_output_tensor(ggml_decoder, infer_request, i, ggml_tensor);
543
+ infer_request->set_output_tensor(i, output_tensor);
544
+ }
545
+
546
+ ov_raw_infer_start = ggml_time_us();
547
+ infer_request->infer();
548
+ infer_end_time = ggml_time_us();
549
+
550
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_OUTPUT") ||
551
+ ggml_openvino_getenv_str("GGML_OPENVINO_DEBUG_NODE")) {
552
+ for (size_t i = 0; i < ov_output_names.size(); i++) {
553
+ const auto output_tensor = infer_request->get_output_tensor(i);
554
+ print_output_tensor_info(ov_output_names[i], output_tensor, output_tensor.data());
555
+ }
556
+ }
557
+
558
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_PROFILING")) {
559
+ GGML_LOG_INFO("\nGGML OpenVINO Backend: \n");
560
+ GGML_LOG_INFO(" - Graph decoder time: %.3f ms \n", (decoder_end_time - start_time) / 1000.0);
561
+ if (!cache_hit) {
562
+ GGML_LOG_INFO(" - Graph conversion time: %.3f ms \n",
563
+ (conversion_end_time - decoder_end_time) / 1000.0);
564
+ GGML_LOG_INFO(" - Graph compile time: %.3f ms \n", (compile_end_time - conversion_end_time) / 1000.0);
565
+ }
566
+ GGML_LOG_INFO(" - Graph inference time: %.3f ms \n", (infer_end_time - compile_end_time) / 1000.0);
567
+ GGML_LOG_INFO(" - OV raw infer time: %.3f ms \n", (infer_end_time - ov_raw_infer_start) / 1000.0);
568
+ }
569
+ }
570
+
571
+ // GGML_OPENVINO_RELEASE_WEIGHTS (or GGML_OPENVINO_MEMORY_OPTIMIZE on GPU): the plugin holds its own device copy of
572
+ // every weight after compile, so the host weight buffers can be dropped to reclaim
573
+ // RSS. The GPU backend uses a single dynamic-shape model for both prefill and decode,
574
+ // so once a graph is compiled it is reused for the whole session — the only thing
575
+ // that forces a recompile is clear_caches() on backend teardown. We therefore release
576
+ // on the first cache-hit (model compiled, plugin has its copy) and, crucially, pin the
577
+ // compiled-model cache so it survives backend teardown (see ggml_backend_openvino_free).
578
+ // Without the pin, a later test/context would recompile against the now-dropped pages.
579
+ // A genuinely new graph still fails fast at the cache-miss compile branch.
580
+ if (cache_hit && ggml_openvino_release_weights_enabled(device) &&
581
+ !ggml_openvino_weight_buffers_released()) {
582
+ ggml_openvino_release_weight_buffers();
583
+ }
584
+
585
+ return GGML_STATUS_SUCCESS;
586
+ }
587
+
588
+ enum ggml_status ov_graph_compute_static(ggml_cgraph * cgraph, std::shared_ptr<ov_runtime_context> r_ctx) {
589
+ auto & core = ov_singleton_core();
590
+
591
+ auto get_prefill_chunk_size = [] {
592
+ static const int chunk_size = []() {
593
+ int env_prefill_chunk_size = ggml_openvino_getenv_int("GGML_OPENVINO_PREFILL_CHUNK_SIZE");
594
+ return env_prefill_chunk_size > 0 ? env_prefill_chunk_size : 256;
595
+ }();
596
+ return chunk_size;
597
+ };
598
+
599
+ // Normally NPU, but honors GGML_OPENVINO_DEVICE so GGML_OPENVINO_FORCE_STATIC can run the
600
+ // static-shape path on CPU/GPU to isolate translation bugs from NPUW/NPU-driver issues.
601
+ static std::string device = ggml_openvino_get_device_name();
602
+ static auto is_static = true;
603
+ static auto stateful = false;
604
+
605
+ auto prefill_chunk_size = get_prefill_chunk_size();
606
+ const auto & config = ggml_openvino_get_compile_config();
607
+
608
+ if (is_naive(cgraph)) {
609
+ return naive_compute(cgraph, core, device, config);
610
+ }
611
+
612
+ auto start_time = ggml_time_us();
613
+
614
+ std::shared_ptr<GgmlOvDecoder> ggml_decoder;
615
+ std::shared_ptr<ov::InferRequest> infer_request;
616
+ ModelParams m_params;
617
+ ComputeParams c_params;
618
+ std::tie(m_params, c_params) = GgmlOvDecoder::compute_llm_params(cgraph, is_static);
619
+
620
+ const auto * inp_pos = get_inp_pos_tensor(cgraph);
621
+ const auto is_prefill = get_is_prefill(cgraph, inp_pos);
622
+ graph_key key(cgraph);
623
+ static const bool cache_enabled = !ggml_openvino_getenv_int("GGML_OPENVINO_DISABLE_CACHE");
624
+ bool cache_hit = false;
625
+
626
+ int64_t decoder_end_time;
627
+ int64_t conversion_end_time;
628
+ int64_t compile_end_time;
629
+ int64_t infer_end_time;
630
+ int64_t ov_raw_infer_start;
631
+ int64_t ov_raw_infer_total = 0;
632
+
633
+ std::shared_ptr<decoder_runtime_ctx> entry;
634
+ ModelParams old_m_params;
635
+
636
+ if (cache_enabled) {
637
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
638
+ auto it = r_ctx->decoder_cache.find(key);
639
+ cache_hit = it != r_ctx->decoder_cache.end();
640
+ if (cache_hit) {
641
+ entry = it->second;
642
+ } else {
643
+ r_ctx->clear_caches_locked();
644
+ auto mutex = std::make_shared<std::mutex>();
645
+ entry = std::make_shared<decoder_runtime_ctx>(mutex);
646
+ r_ctx->decoder_cache[key] = entry;
647
+ }
648
+ } else {
649
+ auto mutex = std::make_shared<std::mutex>();
650
+ entry = std::make_shared<decoder_runtime_ctx>(mutex);
651
+ cache_hit = false;
652
+ }
653
+
654
+ std::lock_guard<std::mutex> lock(*(entry->mutex));
655
+
656
+ if (cache_hit) {
657
+ ggml_decoder = entry->ptr;
658
+ old_m_params = ggml_decoder->get_model_params();
659
+ cache_hit = old_m_params.can_reuse_statically(m_params);
660
+ }
661
+
662
+ std::vector<std::string> ov_input_names_local;
663
+ std::vector<std::string> ov_output_names_local;
664
+
665
+ if (cache_hit) {
666
+ std::map<std::string, std::shared_ptr<ov::Node>> model_weights;
667
+ ggml_decoder->m_is_prefill = is_prefill;
668
+ ggml_decoder->set_model_params(m_params);
669
+ ggml_decoder->set_compute_params(c_params);
670
+ if (old_m_params.kv_buffer_changed(m_params)) {
671
+ ggml_decoder->update_io(cgraph);
672
+ }
673
+ ggml_decoder->add_extra_inputs();
674
+ {
675
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
676
+ infer_request =
677
+ is_prefill ? r_ctx->infer_request_cache_prefill.at(key) : r_ctx->infer_request_cache.at(key);
678
+ ov_input_names_local = r_ctx->ov_input_names_cache.at(key);
679
+ ov_output_names_local = r_ctx->ov_output_names_cache.at(key);
680
+ }
681
+
682
+ decoder_end_time = ggml_time_us();
683
+ conversion_end_time = decoder_end_time;
684
+ compile_end_time = decoder_end_time;
685
+ } else {
686
+ if (cache_enabled) {
687
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
688
+ r_ctx->infer_request_cache.erase(key);
689
+ r_ctx->infer_request_cache_prefill.erase(key);
690
+ }
691
+
692
+ std::shared_ptr<ov::Model> model;
693
+ auto model_weights = GgmlOvDecoder::create_weight_nodes(cgraph);
694
+
695
+ if (m_params.n_heads_kv == -1) {
696
+ // graph is not a LLM, e.g. context-shift graph
697
+ prefill_chunk_size = inp_pos->ne[0];
698
+ }
699
+ auto ggml_decoder_prefill = std::make_shared<GgmlOvDecoder>(
700
+ cgraph, m_params, c_params, model_weights, is_static, stateful, false, true, prefill_chunk_size);
701
+ auto ggml_decoder_decode = std::make_shared<GgmlOvDecoder>(cgraph, m_params, c_params, model_weights, is_static,
702
+ stateful, false, false, prefill_chunk_size);
703
+ decoder_end_time = ggml_time_us();
704
+
705
+ const bool dump_ir = ggml_openvino_getenv_int("GGML_OPENVINO_DUMP_IR");
706
+ const auto dump_ir_timestamp = static_cast<long long>(ggml_time_us());
707
+
708
+ auto build_static_model = [&core, &config, dump_ir, dump_ir_timestamp](
709
+ std::shared_ptr<GgmlOvDecoder> decoder,
710
+ const char * tag,
711
+ std::shared_ptr<ov::Model> & model,
712
+ ov::CompiledModel & compiled_model,
713
+ std::shared_ptr<ov::InferRequest> & infer_request,
714
+ int64_t & local_conversion_end_time,
715
+ int64_t & local_compile_end_time) {
716
+ auto input_model = std::make_shared<ov::frontend::ggml::InputModel>(decoder);
717
+ model = ov::frontend::ggml::FrontEnd::convert(input_model);
718
+ decoder->clear_model_weights();
719
+ local_conversion_end_time = ggml_time_us();
720
+
721
+ if (dump_ir) {
722
+ char timestamped_filename[64];
723
+ snprintf(timestamped_filename, sizeof(timestamped_filename), "model_%s_%lld.xml", tag,
724
+ dump_ir_timestamp);
725
+ ov::serialize(model, timestamped_filename);
726
+ }
727
+
728
+ compiled_model = core.compile_model(model, device, config);
729
+ infer_request = std::make_shared<ov::InferRequest>(compiled_model.create_infer_request());
730
+ local_compile_end_time = ggml_time_us();
731
+ };
732
+ std::shared_ptr<ov::Model> model_prefill;
733
+ std::shared_ptr<ov::Model> model_decode;
734
+ ov::CompiledModel compiled_model_prefill;
735
+ ov::CompiledModel compiled_model_decode;
736
+ std::shared_ptr<ov::InferRequest> infer_request_prefill;
737
+ std::shared_ptr<ov::InferRequest> infer_request_decode;
738
+ int64_t prefill_conversion_end_time;
739
+ int64_t decode_conversion_end_time;
740
+ int64_t prefill_compile_end_time;
741
+ int64_t decode_compile_end_time;
742
+ auto prefill_future = std::async(std::launch::async, build_static_model, ggml_decoder_prefill, "prefill",
743
+ std::ref(model_prefill), std::ref(compiled_model_prefill),
744
+ std::ref(infer_request_prefill), std::ref(prefill_conversion_end_time),
745
+ std::ref(prefill_compile_end_time));
746
+ auto decode_future = std::async(std::launch::async, build_static_model, ggml_decoder_decode, "decode",
747
+ std::ref(model_decode), std::ref(compiled_model_decode),
748
+ std::ref(infer_request_decode), std::ref(decode_conversion_end_time),
749
+ std::ref(decode_compile_end_time));
750
+ prefill_future.get();
751
+ decode_future.get();
752
+ conversion_end_time = std::max(prefill_conversion_end_time, decode_conversion_end_time);
753
+ compile_end_time = std::max(prefill_compile_end_time, decode_compile_end_time);
754
+
755
+ model = is_prefill ? model_prefill : model_decode;
756
+ ggml_decoder = is_prefill ? ggml_decoder_prefill : ggml_decoder_decode;
757
+ infer_request = is_prefill ? infer_request_prefill : infer_request_decode;
758
+ entry->ptr = ggml_decoder;
759
+
760
+ for (const auto & ov_param : model->get_parameters()) {
761
+ ov_input_names_local.push_back(ov_param->get_friendly_name());
762
+ }
763
+ for (const auto & ov_output : model->get_results()) {
764
+ ov_output_names_local.push_back(ov_output->get_friendly_name());
765
+ }
766
+
767
+ if (cache_enabled) {
768
+ std::lock_guard<std::mutex> map_lock(r_ctx->ctx_mutex);
769
+ r_ctx->infer_request_cache_prefill[key] = infer_request_prefill;
770
+ r_ctx->infer_request_cache[key] = infer_request_decode;
771
+ r_ctx->ov_input_names_cache[key] = ov_input_names_local;
772
+ r_ctx->ov_output_names_cache[key] = ov_output_names_local;
773
+ }
774
+ }
775
+
776
+ if (is_prefill) {
777
+ auto inp_len = get_inp_pos_n_tokens(cgraph, inp_pos);
778
+ for (int chunk_index = 0; chunk_index * prefill_chunk_size < inp_len; chunk_index++) {
779
+ for (size_t i = 0; i < ov_input_names_local.size(); i++) {
780
+ auto param_name = ov_input_names_local[i];
781
+ auto input_tensor = get_ov_input_tensor_static_prefill(ggml_decoder, param_name, chunk_index);
782
+ infer_request->set_input_tensor(i, input_tensor);
783
+
784
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_INPUT")) {
785
+ const auto input_tensor = infer_request->get_input_tensor(i);
786
+ print_input_tensor_info(param_name, input_tensor);
787
+ }
788
+ }
789
+
790
+ for (size_t i = 0; i < ov_output_names_local.size(); i++) {
791
+ const auto & model_outputs = ggml_decoder->get_model_outputs();
792
+ auto model_output_it = model_outputs.find(ov_output_names_local[i]);
793
+ if (model_output_it == model_outputs.end()) {
794
+ continue;
795
+ }
796
+ auto * ggml_tensor = model_output_it->second;
797
+ if (ggml_nbytes(ggml_tensor) == 0) {
798
+ // Zero-row in-place writeback (e.g. the empty s_copy defrag remainder). The OV
799
+ // Result is the full cache, so binding it over this 0-byte buffer overflows it.
800
+ continue;
801
+ }
802
+ auto output_tensor = create_ov_output_tensor(ggml_decoder, infer_request, i, ggml_tensor);
803
+ infer_request->set_output_tensor(i, output_tensor);
804
+ }
805
+
806
+ ov_raw_infer_start = ggml_time_us();
807
+ infer_request->infer();
808
+ ov_raw_infer_total += ggml_time_us() - ov_raw_infer_start;
809
+
810
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_OUTPUT") ||
811
+ ggml_openvino_getenv_str("GGML_OPENVINO_DEBUG_NODE")) {
812
+ for (size_t i = 0; i < ov_output_names_local.size(); i++) {
813
+ const auto output_tensor = infer_request->get_output_tensor(i);
814
+ print_output_tensor_info(ov_output_names_local[i], output_tensor, output_tensor.data());
815
+ }
816
+ }
817
+ }
818
+ infer_end_time = ggml_time_us();
819
+ } else {
820
+ for (size_t i = 0; i < ov_input_names_local.size(); i++) {
821
+ auto param_name = ov_input_names_local[i];
822
+ auto input_tensor = get_ov_input_tensor_static_decode(ggml_decoder, param_name);
823
+ infer_request->set_input_tensor(i, input_tensor);
824
+
825
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_INPUT")) {
826
+ const auto input_tensor = infer_request->get_input_tensor(i);
827
+ print_input_tensor_info(param_name, input_tensor);
828
+ }
829
+ }
830
+
831
+ for (size_t i = 0; i < ov_output_names_local.size(); i++) {
832
+ const auto & model_outputs = ggml_decoder->get_model_outputs();
833
+ auto model_output_it = model_outputs.find(ov_output_names_local[i]);
834
+ if (model_output_it == model_outputs.end()) {
835
+ continue;
836
+ }
837
+ auto * ggml_tensor = model_output_it->second;
838
+ if (ggml_nbytes(ggml_tensor) == 0) {
839
+ continue;
840
+ }
841
+ auto output_tensor = create_ov_output_tensor(ggml_decoder, infer_request, i, ggml_tensor);
842
+ infer_request->set_output_tensor(i, output_tensor);
843
+ }
844
+
845
+ ov_raw_infer_start = ggml_time_us();
846
+ infer_request->infer();
847
+ infer_end_time = ggml_time_us();
848
+ ov_raw_infer_total = infer_end_time - ov_raw_infer_start;
849
+
850
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_OUTPUT") ||
851
+ ggml_openvino_getenv_str("GGML_OPENVINO_DEBUG_NODE")) {
852
+ for (size_t i = 0; i < ov_output_names_local.size(); i++) {
853
+ const auto output_tensor = infer_request->get_output_tensor(i);
854
+ print_output_tensor_info(ov_output_names_local[i], output_tensor, output_tensor.data());
855
+ }
856
+ }
857
+ }
858
+
859
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_PROFILING")) {
860
+ GGML_LOG_INFO("\nGGML OpenVINO Backend: \n");
861
+ GGML_LOG_INFO(" - Graph decoder time: %.3f ms \n", (decoder_end_time - start_time) / 1000.0);
862
+ if (!cache_hit) {
863
+ GGML_LOG_INFO(" - Graph conversion time: %.3f ms \n", (conversion_end_time - decoder_end_time) / 1000.0);
864
+ GGML_LOG_INFO(" - Graph compile time: %.3f ms \n", (compile_end_time - conversion_end_time) / 1000.0);
865
+ }
866
+ GGML_LOG_INFO(" - Graph inference time: %.3f ms \n", (infer_end_time - compile_end_time) / 1000.0);
867
+ GGML_LOG_INFO(" - OV raw infer time: %.3f ms \n", ov_raw_infer_total / 1000.0);
868
+ }
869
+
870
+ return GGML_STATUS_SUCCESS;
871
+ }
872
+
873
+ // Detect whether a cgraph is a split subgraph or not.
874
+ // Step 1 compares each node's recorded use_count with actual fan-out references in node->src.
875
+ // Step 2 verifies that node inputs come from model nodes/weights/leafs; external sources imply split.
876
+ bool is_model_splitted(ggml_cgraph * cgraph) {
877
+ static const bool fallback_enabled = ggml_openvino_getenv_int("GGML_OPENVINO_ENABLE_FALLBACK") != 0;
878
+ if (!fallback_enabled) {
879
+ return false;
880
+ }
881
+
882
+ // Backend op tests execute each node through ggml_graph_view(), which preserves the original
883
+ // graph use_counts while exposing only one node. Treat those single-node views as regular
884
+ // naive graphs so intermediate ops do not look like split-model fragments.
885
+ if (cgraph->n_nodes <= 1 && cgraph->n_leafs == 0) {
886
+ return false;
887
+ }
888
+
889
+ // check the nodes of the model are used by the following nodes, through compare the node's use count and the count of nodes that use it as input. If does not match, return true, else return false.
890
+ for (int i = 0; i < cgraph->n_nodes; i++) {
891
+ ggml_tensor * node = cgraph->nodes[i];
892
+ int use_count = cgraph->use_counts[ggml_hash_find(&cgraph->visited_hash_set, node)];
893
+ // TODO: this is a workround for the tests case from llama.cpp, fix should from the root cause in the future.
894
+ if ((cgraph->n_nodes <= 1 && use_count == 0) ||
895
+ (cgraph->n_nodes <= 1 && node->op == GGML_OP_VIEW && use_count == 1 && node->src[0] != nullptr &&
896
+ node->src[0]->op == GGML_OP_NONE)) {
897
+ return false;
898
+ }
899
+ if (cgraph->n_nodes == 1 &&
900
+ (cgraph->nodes[0]->op == GGML_OP_TRANSPOSE || cgraph->nodes[0]->op == GGML_OP_PERMUTE)) {
901
+ return false;
902
+ }
903
+ int input_use_count = 0;
904
+ for (int j = 0; j < cgraph->n_nodes; j++) {
905
+ ggml_tensor * other_node = cgraph->nodes[j];
906
+ for (int k = 0; k < GGML_MAX_SRC; k++) {
907
+ if (other_node->src[k] == node) {
908
+ input_use_count++;
909
+ }
910
+ }
911
+ }
912
+ if (use_count != input_use_count && node->op != GGML_OP_NONE) {
913
+ return true;
914
+ }
915
+ }
916
+ // if all nodes's src node's src is not come from the nodes in the model, we think the model is splitted. This is a complementary check for the above check, because for some special case like the output node is not used by any node, the use count and input use count are both 0, we can not determine whether the model is splitted or not just based on the first check.
917
+ // Only weight-name membership is needed below. With GGML_OPENVINO_REDUCE_COMPILE_MEM
918
+ // use the name-only collector (no weight extraction); otherwise keep the original
919
+ // behavior of building (naive) weight nodes and take their names.
920
+ std::set<std::string> model_weights;
921
+ if (ggml_openvino_reduce_compile_mem_enabled()) {
922
+ model_weights = GgmlOvDecoder::collect_weight_names(cgraph);
923
+ } else {
924
+ for (const auto & kv : GgmlOvDecoder::create_weight_nodes(cgraph, true)) {
925
+ model_weights.insert(kv.first);
926
+ }
927
+ }
928
+ std::set<ggml_tensor *> model_nodes(cgraph->nodes, cgraph->nodes + cgraph->n_nodes);
929
+ // leaf nodes
930
+ std::set<ggml_tensor *> model_leafs(cgraph->leafs, cgraph->leafs + cgraph->n_leafs);
931
+ for (int i = 0; i < cgraph->n_nodes; i++) {
932
+ ggml_tensor * node = cgraph->nodes[i];
933
+ for (int j = 0; j < GGML_MAX_SRC; j++) {
934
+ ggml_tensor * src = node->src[j];
935
+ // the src is also not the model weights, we think the model is splitted.
936
+ // the src is also not in model leafs, we think the model is splitted.
937
+ if (src != nullptr && model_nodes.find(src) == model_nodes.end() &&
938
+ model_weights.find(std::string(src->name)) == model_weights.end() && !model_leafs.empty() == false &&
939
+ model_leafs.find(src) == model_leafs.end()) {
940
+ if (GgmlOvDecoder::is_inp_tok(src, node)) {
941
+ return false;
942
+ }
943
+ return true;
944
+ }
945
+ }
946
+ }
947
+ return false;
948
+ }
949
+
950
+ bool is_naive(ggml_cgraph * cgraph) {
951
+ constexpr int naive_graph_size_threshold = 20;
952
+ int count = 0;
953
+ for (int i = 0; i < cgraph->n_nodes; i++) {
954
+ if (cgraph->nodes[i]->op != GGML_OP_NONE) {
955
+ count++;
956
+ }
957
+ }
958
+ return count < naive_graph_size_threshold;
959
+ }
960
+
961
+ enum ggml_status naive_compute(ggml_cgraph * cgraph,
962
+ ov::Core & core,
963
+ const std::string & device,
964
+ const ov::AnyMap & config) {
965
+ if (cgraph->n_nodes == 1 && (cgraph->nodes[0]->op == GGML_OP_NONE || cgraph->nodes[0]->op == GGML_OP_VIEW)) {
966
+ return GGML_STATUS_SUCCESS;
967
+ }
968
+
969
+ bool naive = true;
970
+ auto model_weights = GgmlOvDecoder::create_weight_nodes(cgraph, naive);
971
+ auto decoder = std::make_shared<GgmlOvDecoder>(cgraph, model_weights);
972
+ auto input_model = std::make_shared<ov::frontend::ggml::InputModel>(decoder);
973
+ auto model = ov::frontend::ggml::FrontEnd::convert(input_model, naive);
974
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DUMP_IR")) {
975
+ ov::serialize(model, "IR_naive.xml");
976
+ }
977
+
978
+ std::shared_ptr<ov::InferRequest> infer_request;
979
+ auto remote_context = ggml_openvino_get_remote_context();
980
+ if (cgraph->nodes[0]->op == GGML_OP_MUL_MAT) {
981
+ // TODO ACCURACY hint triggers a bug in GPU plugin/driver on Lunar Lake. Remove once CVS-182166 is resolved
982
+ core.set_property(device, ov::hint::execution_mode(ov::hint::ExecutionMode::PERFORMANCE));
983
+ } else {
984
+ core.set_property(device, ov::hint::execution_mode(ov::hint::ExecutionMode::ACCURACY));
985
+ }
986
+ if (remote_context.has_value()) {
987
+ infer_request = std::make_shared<ov::InferRequest>(
988
+ core.compile_model(model, remote_context.value(), config).create_infer_request());
989
+ } else {
990
+ infer_request =
991
+ std::make_shared<ov::InferRequest>(core.compile_model(model, device, config).create_infer_request());
992
+ }
993
+
994
+ auto ov_params = model->get_parameters();
995
+ for (size_t i = 0; i < ov_params.size(); i++) {
996
+ auto param_name = ov_params[i]->get_friendly_name();
997
+ auto input_tensor = get_ov_input_tensor(decoder, param_name);
998
+ infer_request->set_input_tensor(i, input_tensor);
999
+ }
1000
+
1001
+ // Use get_output_tensor + memcpy instead of set_output_tensor to avoid memory overwritten
1002
+ // when i/o buffer overlaps, e.g. the cgraph is a single PERMUTE
1003
+
1004
+ infer_request->infer();
1005
+
1006
+ auto ov_results = model->get_results();
1007
+ for (size_t i = 0; i < ov_results.size(); i++) {
1008
+ auto output_tensor = infer_request->get_output_tensor(i);
1009
+ const auto & model_outputs = decoder->get_model_outputs();
1010
+ auto model_output_it = model_outputs.find(ov_results[i]->get_friendly_name());
1011
+ if (model_output_it == model_outputs.end()) {
1012
+ // Debug-only output added via GGML_OPENVINO_DEBUG_NODE; nothing to copy into.
1013
+ if (ggml_openvino_getenv_int("GGML_OPENVINO_DEBUG_OUTPUT") ||
1014
+ ggml_openvino_getenv_str("GGML_OPENVINO_DEBUG_NODE")) {
1015
+ print_output_tensor_info(ov_results[i]->get_friendly_name(), output_tensor, output_tensor.data());
1016
+ }
1017
+ continue;
1018
+ }
1019
+ auto * ggml_tensor = model_output_it->second;
1020
+ std::memcpy(ggml_tensor->data, output_tensor.data(), output_tensor.get_byte_size());
1021
+ }
1022
+ return GGML_STATUS_SUCCESS;
1023
+ }
1024
+
1025
+ namespace {
1026
+ template <typename T> void set_zero_diagonal(std::vector<T> & matrix, size_t rows, size_t cols, T zero_value = T{}) {
1027
+ for (size_t i = 0; i < rows; ++i) {
1028
+ size_t diag_col = std::min(i, cols - 1);
1029
+ matrix[i * cols + diag_col] = zero_value;
1030
+ }
1031
+ }
1032
+
1033
+ ov::Tensor make_contiguous_split_input_tensor(std::shared_ptr<GgmlOvDecoder> ggml_decoder,
1034
+ const struct ggml_tensor * ggml_tensor,
1035
+ const ov::Shape & input_shape) {
1036
+ const size_t element_size = ggml_type_size(ggml_tensor->type);
1037
+ const size_t block_size = ggml_blck_size(ggml_tensor->type);
1038
+
1039
+ GGML_ASSERT(block_size == 1 && "non-contiguous split inputs must be plain element types");
1040
+
1041
+ const struct ggml_tensor * source_tensor = ggml_tensor->view_src != nullptr ? ggml_tensor->view_src : ggml_tensor;
1042
+ const size_t source_offset = ggml_tensor->view_src != nullptr ? ggml_tensor->view_offs : 0;
1043
+
1044
+ std::vector<uint8_t> source_data(ggml_nbytes(source_tensor));
1045
+ ggml_backend_tensor_get(source_tensor, source_data.data(), 0, source_data.size());
1046
+
1047
+ ov::Tensor input_tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape);
1048
+ auto * dst = static_cast<uint8_t *>(input_tensor.data());
1049
+ size_t dst_offset = 0;
1050
+
1051
+ for (size_t i3 = 0; i3 < static_cast<size_t>(ggml_tensor->ne[3]); ++i3) {
1052
+ for (size_t i2 = 0; i2 < static_cast<size_t>(ggml_tensor->ne[2]); ++i2) {
1053
+ for (size_t i1 = 0; i1 < static_cast<size_t>(ggml_tensor->ne[1]); ++i1) {
1054
+ for (size_t i0 = 0; i0 < static_cast<size_t>(ggml_tensor->ne[0]); ++i0) {
1055
+ const size_t src_offset = source_offset + i3 * ggml_tensor->nb[3] + i2 * ggml_tensor->nb[2] +
1056
+ i1 * ggml_tensor->nb[1] + i0 * ggml_tensor->nb[0];
1057
+ std::memcpy(dst + dst_offset, source_data.data() + src_offset, element_size);
1058
+ dst_offset += element_size;
1059
+ }
1060
+ }
1061
+ }
1062
+ }
1063
+
1064
+ return input_tensor;
1065
+ }
1066
+
1067
+ ov::Tensor convert_ggml_input_to_ov(std::shared_ptr<GgmlOvDecoder> ggml_decoder, const std::string & name) {
1068
+ const auto * ggml_tensor = ggml_decoder->get_input_ggml_tensor(name);
1069
+
1070
+ if (auto sliced = try_make_kv_sliced_tensor(ggml_decoder, name, ggml_tensor)) {
1071
+ return *sliced;
1072
+ }
1073
+
1074
+ if (ggml_tensor->extra != nullptr && !ggml_decoder->is_splited_model()) {
1075
+ auto * extra_base = static_cast<ggml_openvino_extra_base *>(ggml_tensor->extra);
1076
+ if (extra_base->type == ggml_openvino_extra_base::Type::TENSOR) {
1077
+ // GGML_LOG_DEBUG("Using ggml_tensor->extra as ov::Tensor for input: %s\n", name.c_str());
1078
+ auto * tensor_extra = static_cast<ggml_openvino_tensor_extra *>(extra_base);
1079
+ return *tensor_extra->tensor;
1080
+ }
1081
+ }
1082
+
1083
+ // GGML_LOG_DEBUG("Converting ggml tensor to ov::Tensor for input: %s\n", name.c_str());
1084
+ auto * input_data = ggml_tensor->data;
1085
+ ov::Shape input_shape;
1086
+ if (ggml_tensor->op == GGML_OP_VIEW && !ggml_decoder->is_splited_model()) {
1087
+ // This case is added to make test-backend-ops work
1088
+ input_shape = ggml_decoder->get_shape(ggml_tensor->view_src);
1089
+ } else {
1090
+ input_shape = ggml_decoder->get_shape(ggml_tensor);
1091
+ }
1092
+
1093
+ if (ggml_decoder->is_splited_model() && !ggml_is_contiguous(ggml_tensor)) {
1094
+ return make_contiguous_split_input_tensor(ggml_decoder, ggml_tensor, input_shape);
1095
+ }
1096
+
1097
+ auto input_tensor = ov::Tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape, input_data);
1098
+ return input_tensor;
1099
+ }
1100
+ } // namespace
1101
+
1102
+ ov::Tensor get_ov_input_tensor(std::shared_ptr<GgmlOvDecoder> ggml_decoder, const std::string & param_name) {
1103
+ ov::Tensor input_tensor;
1104
+ auto extra_input = ggml_decoder->get_model_extra_inputs().find(param_name);
1105
+ if (extra_input != ggml_decoder->get_model_extra_inputs().end()) {
1106
+ input_tensor = ov::Tensor(extra_input->second.type, extra_input->second.shape);
1107
+ *input_tensor.data<int64_t>() = extra_input->second.value;
1108
+ } else {
1109
+ input_tensor = convert_ggml_input_to_ov(ggml_decoder, param_name);
1110
+ }
1111
+ return input_tensor;
1112
+ }
1113
+
1114
+ ov::Tensor get_ov_input_tensor_static_decode(std::shared_ptr<GgmlOvDecoder> ggml_decoder,
1115
+ const std::string & param_name) {
1116
+ // NPU decoding stage
1117
+ if (ggml_decoder->get_model_extra_inputs().count(param_name)) {
1118
+ return get_ov_input_tensor(ggml_decoder, param_name);
1119
+ }
1120
+ const auto * ggml_tensor = ggml_decoder->get_input_ggml_tensor(param_name);
1121
+ const auto * op = ggml_decoder->get_tensor_used_op(ggml_tensor);
1122
+
1123
+ if (GgmlOvDecoder::is_inp_tok(ggml_tensor, op) || GgmlOvDecoder::is_inp_pos(ggml_tensor, op) ||
1124
+ GgmlOvDecoder::is_kv_idx(ggml_tensor, op)) {
1125
+ // IMROPE's inp_pos holds one value per t/h/w/e plane instead of a single position;
1126
+ // with a single decode token the planes are still contiguous, so a flat copy works.
1127
+ const int n_planes = GgmlOvDecoder::is_inp_pos(ggml_tensor, op) ? GgmlOvDecoder::get_inp_pos_n_planes(op) : 1;
1128
+ assert(ggml_tensor->ne[0] == n_planes);
1129
+ ov::Shape input_shape = {1, 1, 1, (size_t) n_planes};
1130
+ ov::Tensor input_tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape);
1131
+ std::memcpy(input_tensor.data(), ggml_tensor->data, n_planes * ggml_type_size(ggml_tensor->type));
1132
+ return input_tensor;
1133
+ }
1134
+
1135
+ if (GgmlOvDecoder::is_output_idx(ggml_tensor, op)) {
1136
+ ov::Shape input_shape = {1, 1, 1, 1};
1137
+ ov::Tensor input_tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape);
1138
+ int32_t inp_out_id = *((int32_t *) ggml_tensor->data);
1139
+ assert(ggml_tensor->ne[0] == 1);
1140
+ assert(inp_out_id == 0);
1141
+ *input_tensor.data<int32_t>() = inp_out_id;
1142
+ return input_tensor;
1143
+ }
1144
+
1145
+ if (GgmlOvDecoder::is_inp_mask(ggml_tensor, op)) {
1146
+ size_t context_size = ggml_decoder->get_ctx_size();
1147
+ if (ggml_tensor->type == GGML_TYPE_F16) {
1148
+ std::vector<ggml_fp16_t> padded_data =
1149
+ pad_input<ggml_fp16_t>(ggml_tensor, 1, context_size, GGML_FP32_TO_FP16(-INFINITY));
1150
+ ov::Tensor input_tensor(ov::element::f16, ov::Shape{1, 1, 1, context_size});
1151
+ std::memcpy(input_tensor.data(), padded_data.data(), padded_data.size() * sizeof(ggml_fp16_t));
1152
+ return input_tensor;
1153
+ }
1154
+
1155
+ std::vector<float> padded_data = pad_input<float>(ggml_tensor, 1, context_size, -INFINITY);
1156
+ ov::Tensor input_tensor(ov::element::f32, ov::Shape{1, 1, 1, context_size});
1157
+ auto * data_ptr = input_tensor.data<float>();
1158
+ std::copy(padded_data.begin(), padded_data.begin() + context_size, data_ptr);
1159
+ return input_tensor;
1160
+ }
1161
+
1162
+ return get_ov_input_tensor(ggml_decoder, param_name);
1163
+ }
1164
+
1165
+ ov::Tensor get_ov_input_tensor_static_prefill(std::shared_ptr<GgmlOvDecoder> ggml_decoder,
1166
+ const std::string & param_name,
1167
+ int chunk_index) {
1168
+ // NPU prompt processing stage
1169
+ const size_t input_len = ggml_decoder->get_input_len();
1170
+ const size_t chunk_size = ggml_decoder->m_prefill_chunk_size;
1171
+ const size_t chunk_valid_size = std::min(chunk_size, input_len - chunk_index * chunk_size);
1172
+ const size_t chunk_pad_size = chunk_size - chunk_valid_size;
1173
+
1174
+ if (param_name == "chunk_valid_len") {
1175
+ ov::Tensor input_tensor(ov::element::i64, ov::Shape{1});
1176
+ *input_tensor.data<int64_t>() = (int64_t) chunk_valid_size;
1177
+ return input_tensor;
1178
+ }
1179
+ if (chunk_index > 0 && param_name == "cache_rs_reset_len") {
1180
+ // The recurrent-state clear belongs to the start of the sequence. Re-applying it on every
1181
+ // chunk would wipe the state accumulated by the preceding chunks, so disable it (a zero
1182
+ // length makes scale.cpp's keep-mask select every slot) after the first chunk.
1183
+ ov::Tensor input_tensor(ov::element::i64, ov::Shape{1});
1184
+ *input_tensor.data<int64_t>() = 0;
1185
+ return input_tensor;
1186
+ }
1187
+ if (ggml_decoder->get_model_extra_inputs().count(param_name)) {
1188
+ return get_ov_input_tensor(ggml_decoder, param_name);
1189
+ }
1190
+ const auto * ggml_tensor = ggml_decoder->get_input_ggml_tensor(param_name);
1191
+ const auto * op = ggml_decoder->get_tensor_used_op(ggml_tensor);
1192
+
1193
+ if (GgmlOvDecoder::is_inp_pos(ggml_tensor, op) && GgmlOvDecoder::get_inp_pos_n_planes(op) > 1) {
1194
+ // IMROPE: inp_pos stacks n_planes (t/h/w/e) position planes, each of length
1195
+ // input_len; pad every plane independently so they stay aligned to chunk_size.
1196
+ const int n_planes = GgmlOvDecoder::get_inp_pos_n_planes(op);
1197
+ const size_t element_size = ggml_type_size(ggml_tensor->type);
1198
+ ov::Shape input_shape = {1, 1, 1, (size_t) n_planes * chunk_size};
1199
+ ov::Tensor input_tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape);
1200
+ for (int p = 0; p < n_planes; p++) {
1201
+ const char * src =
1202
+ (const char *) ggml_tensor->data + (p * input_len + chunk_index * chunk_size) * element_size;
1203
+ char * dst = (char *) input_tensor.data() + p * chunk_size * element_size;
1204
+ std::memcpy(dst, src, chunk_valid_size * element_size);
1205
+ if (chunk_pad_size > 0) {
1206
+ if (ggml_tensor->type == GGML_TYPE_I32) {
1207
+ int32_t last_value = *((const int32_t *) src + chunk_valid_size - 1);
1208
+ int32_t * out = (int32_t *) dst;
1209
+ std::fill(out + chunk_valid_size, out + chunk_size, last_value + 1);
1210
+ } else if (ggml_tensor->type == GGML_TYPE_I64) {
1211
+ int64_t last_value = *((const int64_t *) src + chunk_valid_size - 1);
1212
+ int64_t * out = (int64_t *) dst;
1213
+ std::fill(out + chunk_valid_size, out + chunk_size, last_value + 1);
1214
+ } else {
1215
+ throw std::runtime_error("Unexpected tensor type for " + param_name);
1216
+ }
1217
+ }
1218
+ }
1219
+ return input_tensor;
1220
+ }
1221
+
1222
+ if (GgmlOvDecoder::is_inp_tok(ggml_tensor, op) || GgmlOvDecoder::is_inp_pos(ggml_tensor, op) ||
1223
+ GgmlOvDecoder::is_kv_idx(ggml_tensor, op)) {
1224
+ ov::Shape input_shape = {1, 1, 1, chunk_size};
1225
+ ov::Tensor input_tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape);
1226
+ // copy the chunk_index-th chunk from ggml_tensor
1227
+ size_t element_size = ggml_type_size(ggml_tensor->type);
1228
+ void * input_data = (char *) ggml_tensor->data + chunk_index * chunk_size * element_size;
1229
+ std::memcpy(input_tensor.data(), input_data, chunk_valid_size * element_size);
1230
+ // pad the rest with last_value + 1, so that kv's of padded positions are inserted
1231
+ // to the next row after the valids row in the kvcache
1232
+ if (chunk_pad_size > 0) {
1233
+ if (ggml_tensor->type == GGML_TYPE_I32) {
1234
+ int32_t last_value =
1235
+ *((int32_t *) ggml_tensor->data + (chunk_index * chunk_size + chunk_valid_size - 1));
1236
+ int32_t * output_data = input_tensor.data<int32_t>();
1237
+ std::fill(output_data + chunk_valid_size, output_data + chunk_size, last_value + 1);
1238
+ } else if (ggml_tensor->type == GGML_TYPE_I64) {
1239
+ int64_t last_value =
1240
+ *((int64_t *) ggml_tensor->data + (chunk_index * chunk_size + chunk_valid_size - 1));
1241
+ int64_t * output_data = input_tensor.data<int64_t>();
1242
+ std::fill(output_data + chunk_valid_size, output_data + chunk_size, last_value + 1);
1243
+ } else {
1244
+ throw std::runtime_error("Unexpected tensor type for " + param_name);
1245
+ }
1246
+ }
1247
+ return input_tensor;
1248
+ }
1249
+
1250
+ if (GgmlOvDecoder::is_output_idx(ggml_tensor, op)) {
1251
+ size_t output_len = ggml_decoder->get_compute_params().output_len;
1252
+ ov::Shape input_shape = {1, 1, 1, output_len};
1253
+ ov::Tensor input_tensor(ggml_decoder->get_ov_type(ggml_tensor), input_shape);
1254
+ if (ggml_tensor->ne[0] == 0) {
1255
+ *input_tensor.data<int32_t>() = 0;
1256
+ } else {
1257
+ auto * data_addr = input_tensor.data<int32_t>();
1258
+ for (size_t i = 0; i < output_len; i++) {
1259
+ data_addr[i] = ((int32_t *) ggml_tensor->data)[i] % chunk_size;
1260
+ }
1261
+ }
1262
+ return input_tensor;
1263
+ }
1264
+
1265
+ if (GgmlOvDecoder::is_inp_mask(ggml_tensor, op)) {
1266
+ size_t cols = ggml_tensor->ne[0];
1267
+ size_t rows = ggml_tensor->ne[1];
1268
+ size_t chunk_valid_rows = std::min(chunk_size, rows - chunk_index * chunk_size);
1269
+ size_t context_size = ggml_decoder->get_ctx_size();
1270
+ if (ggml_tensor->type == GGML_TYPE_F16) {
1271
+ const auto * ggml_data =
1272
+ static_cast<const ggml_fp16_t *>(ggml_tensor->data) + chunk_index * chunk_size * cols;
1273
+ std::vector<ggml_fp16_t> padded_data = pad_input<ggml_fp16_t>(ggml_data, chunk_valid_rows, cols, chunk_size,
1274
+ context_size, GGML_FP32_TO_FP16(-INFINITY));
1275
+ set_zero_diagonal(padded_data, chunk_size, context_size, GGML_FP32_TO_FP16(0.0f));
1276
+ ov::Tensor input_tensor(ov::element::f16, ov::Shape{1, 1, chunk_size, context_size});
1277
+ std::memcpy(input_tensor.data(), padded_data.data(), padded_data.size() * sizeof(ggml_fp16_t));
1278
+ return input_tensor;
1279
+ }
1280
+
1281
+ const auto * ggml_data = static_cast<const float *>(ggml_tensor->data) + chunk_index * chunk_size * cols;
1282
+ std::vector<float> padded_data =
1283
+ pad_input<float>(ggml_data, chunk_valid_rows, cols, chunk_size, context_size, -INFINITY);
1284
+ set_zero_diagonal(padded_data, chunk_size, context_size);
1285
+ ov::Tensor input_tensor(ov::element::f32, ov::Shape{1, 1, chunk_size, context_size});
1286
+ auto * data_ptr = input_tensor.data<float>();
1287
+ std::copy(padded_data.begin(), padded_data.begin() + chunk_size * context_size, data_ptr);
1288
+ return input_tensor;
1289
+ }
1290
+
1291
+ return get_ov_input_tensor(ggml_decoder, param_name);
1292
+ }
1293
+
1294
+ size_t checksum(const void * data, size_t size) {
1295
+ const uint8_t * bytes = static_cast<const uint8_t *>(data);
1296
+ size_t sum = 0;
1297
+ for (size_t i = 0; i < size; ++i) {
1298
+ sum += (uint8_t) i;
1299
+ sum += bytes[i];
1300
+ }
1301
+ return sum;
1302
+ }
1303
+
1304
+ bool save_ggml_tensor_data_to_txt(const ggml_tensor * tensor, const std::string & file_path) {
1305
+ if (tensor == nullptr || tensor->data == nullptr) {
1306
+ return false;
1307
+ }
1308
+
1309
+ std::ofstream out(file_path);
1310
+ if (!out.is_open()) {
1311
+ return false;
1312
+ }
1313
+
1314
+ const size_t n = ggml_nelements(tensor);
1315
+ out << "name: " << tensor->name << ", type: " << ggml_type_name(tensor->type) << ", shape: [" << tensor->ne[0]
1316
+ << ", " << tensor->ne[1] << ", " << tensor->ne[2] << ", " << tensor->ne[3] << "]" << ", elements: " << n
1317
+ << ", data:" << '\n';
1318
+
1319
+ switch (tensor->type) {
1320
+ case GGML_TYPE_F32: {
1321
+ const auto * data = static_cast<const float *>(tensor->data);
1322
+ for (size_t i = 0; i < n; ++i) {
1323
+ out << data[i] << '\n';
1324
+ }
1325
+ break;
1326
+ }
1327
+ case GGML_TYPE_F16: {
1328
+ const auto * data = static_cast<const ggml_fp16_t *>(tensor->data);
1329
+ for (size_t i = 0; i < n; ++i) {
1330
+ out << ggml_fp16_to_fp32(data[i]) << '\n';
1331
+ }
1332
+ break;
1333
+ }
1334
+ case GGML_TYPE_BF16: {
1335
+ const auto * data = static_cast<const ggml_bf16_t *>(tensor->data);
1336
+ for (size_t i = 0; i < n; ++i) {
1337
+ out << ggml_bf16_to_fp32(data[i]) << '\n';
1338
+ }
1339
+ break;
1340
+ }
1341
+ case GGML_TYPE_I32: {
1342
+ const auto * data = static_cast<const int32_t *>(tensor->data);
1343
+ for (size_t i = 0; i < n; ++i) {
1344
+ out << data[i] << '\n';
1345
+ }
1346
+ break;
1347
+ }
1348
+ case GGML_TYPE_I64: {
1349
+ const auto * data = static_cast<const int64_t *>(tensor->data);
1350
+ for (size_t i = 0; i < n; ++i) {
1351
+ out << data[i] << '\n';
1352
+ }
1353
+ break;
1354
+ }
1355
+ default:
1356
+ out << "unsupported tensor type for text dump" << '\n';
1357
+ return false;
1358
+ }
1359
+
1360
+ return true;
1361
+ }
1362
+
1363
+ void print_input_tensor_info(const std::string & name, const ov::Tensor & tensor) {
1364
+ std::cout << "Input name: " << name << ", Input shape: " << tensor.get_shape() << ", Address: " << tensor.data()
1365
+ << std::endl;
1366
+ switch (tensor.get_element_type()) {
1367
+ case ov::element::f32: {
1368
+ if (name.find("self_kq_mask") == std::string::npos && name.find("KQ_mask") == std::string::npos) {
1369
+ std::cout << *(tensor.data<float>()) << std::endl;
1370
+ } else {
1371
+ size_t rows = tensor.get_shape()[2];
1372
+ size_t cols = tensor.get_shape()[3];
1373
+ auto * data = tensor.data<float>();
1374
+ for (size_t i = 0; i < rows; ++i) {
1375
+ for (size_t j = 0; j < cols; ++j) {
1376
+ float val = data[i * cols + j];
1377
+ if (std::isinf(val) && val < 0) {
1378
+ std::cout << std::setw(5) << "-inf";
1379
+ } else {
1380
+ std::cout << std::setw(5) << val;
1381
+ }
1382
+ }
1383
+ std::cout << std::endl;
1384
+ }
1385
+ }
1386
+
1387
+ break;
1388
+ }
1389
+ case ov::element::f16:
1390
+ std::cout << *(tensor.data<ov::float16>()) << std::endl;
1391
+ break;
1392
+ case ov::element::i32:
1393
+ for (size_t i = 0; i < tensor.get_size(); ++i) {
1394
+ std::cout << tensor.data<int32_t>()[i] << " ";
1395
+ }
1396
+ std::cout << std::endl;
1397
+ break;
1398
+ case ov::element::i64:
1399
+ for (size_t i = 0; i < tensor.get_size(); ++i) {
1400
+ std::cout << tensor.data<int64_t>()[i] << " ";
1401
+ }
1402
+ std::cout << std::endl;
1403
+ break;
1404
+ default:
1405
+ break;
1406
+ }
1407
+ }
1408
+
1409
+ void print_output_tensor_info(const std::string & name, const ov::Tensor & tensor, const void * output_dst) {
1410
+ std::cout << "Output name: " << name << ", Output shape: " << tensor.get_shape() << ", Address: " << output_dst
1411
+ << std::endl;
1412
+
1413
+ auto print_float_stats = [](const std::string & type_name, size_t size, auto get_value) {
1414
+ if (size == 0) {
1415
+ return;
1416
+ }
1417
+
1418
+ float first = get_value(0);
1419
+ float min = first;
1420
+ float max = first;
1421
+ double sum = first;
1422
+
1423
+ for (size_t i = 1; i < size; ++i) {
1424
+ float v = get_value(i);
1425
+ if (v < min) {
1426
+ min = v;
1427
+ }
1428
+ if (v > max) {
1429
+ max = v;
1430
+ }
1431
+ sum += v;
1432
+ }
1433
+ double mean = sum / size;
1434
+
1435
+ std::cout << std::right << std::setw(6) << type_name << std::right << std::setw(12) << "First" << std::setw(12)
1436
+ << "Min" << std::setw(12) << "Max" << std::setw(12) << "Mean" << std::endl;
1437
+ std::cout << std::right << std::setw(6) << "" << std::right << std::setw(12) << first << std::setw(12) << min
1438
+ << std::setw(12) << max << std::setw(12) << mean << std::endl;
1439
+ };
1440
+
1441
+ switch (tensor.get_element_type()) {
1442
+ case ov::element::f32: {
1443
+ const float * data = tensor.data<float>();
1444
+ size_t size = tensor.get_size();
1445
+ print_float_stats("[f32]", size, [data](size_t i) { return data[i]; });
1446
+ break;
1447
+ }
1448
+ case ov::element::f16: {
1449
+ const ov::float16 * data = tensor.data<ov::float16>();
1450
+ size_t size = tensor.get_size();
1451
+ print_float_stats("[f16]", size, [data](size_t i) { return static_cast<float>(data[i]); });
1452
+ break;
1453
+ }
1454
+ default:
1455
+ break;
1456
+ }
1457
+ }
1458
+
1459
+ const ggml_tensor * get_inp_pos_tensor(ggml_cgraph * cgraph) {
1460
+ for (int i = 0; i < cgraph->n_nodes; ++i) {
1461
+ auto * op = cgraph->nodes[i];
1462
+ for (int j = 0; j < GGML_MAX_SRC; ++j) {
1463
+ auto * src = op->src[j];
1464
+ if (src == nullptr) {
1465
+ break;
1466
+ }
1467
+ if (GgmlOvDecoder::is_inp_pos(src, op)) {
1468
+ return src;
1469
+ }
1470
+ }
1471
+ }
1472
+ GGML_LOG_ERROR("get_inp_pos_tensor: inp_pos not found in cgraph");
1473
+ throw std::runtime_error("get_inp_pos_tensor: inp_pos not found in cgraph");
1474
+ }
1475
+
1476
+ int64_t get_inp_pos_n_tokens(ggml_cgraph * cgraph, const ggml_tensor * inp_pos) {
1477
+ // IMROPE stacks n_planes (t/h/w/e) position planes into inp_pos, so ne[0] is
1478
+ // n_planes * n_tokens. Callers that need a token count must divide the planes out.
1479
+ int n_planes = 1;
1480
+ for (int i = 0; i < cgraph->n_nodes; ++i) {
1481
+ auto * op = cgraph->nodes[i];
1482
+ for (int j = 0; j < GGML_MAX_SRC; ++j) {
1483
+ if (op->src[j] == inp_pos) {
1484
+ n_planes = GgmlOvDecoder::get_inp_pos_n_planes(op);
1485
+ break;
1486
+ }
1487
+ }
1488
+ }
1489
+ return inp_pos->ne[0] / n_planes;
1490
+ }
1491
+
1492
+ bool get_is_prefill(ggml_cgraph * cgraph, const ggml_tensor * inp_pos) {
1493
+ return get_inp_pos_n_tokens(cgraph, inp_pos) > 1;
1494
+ }
1495
+
1496
+ #pragma GCC diagnostic pop