whispercpp 1.3.7 → 1.3.8

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 (308) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/ext/options.rb +1 -1
  4. data/ext/ruby_whisper.c +0 -1
  5. data/ext/ruby_whisper.h +7 -1
  6. data/ext/ruby_whisper_context.c +50 -1
  7. data/ext/ruby_whisper_log_settable.h +1 -2
  8. data/ext/ruby_whisper_params.c +9 -8
  9. data/ext/ruby_whisper_transcribe.cpp +0 -19
  10. data/ext/ruby_whisper_vad_context.c +30 -10
  11. data/ext/ruby_whisper_vad_context_detect.cpp +8 -9
  12. data/ext/ruby_whisper_vad_params.c +4 -4
  13. data/ext/ruby_whisper_vad_segment.c +2 -2
  14. data/ext/sources/CMakeLists.txt +2 -1
  15. data/ext/sources/cmake/parakeet.pc.in +2 -2
  16. data/ext/sources/cmake/whisper.pc.in +2 -2
  17. data/ext/sources/examples/cli/cli.cpp +9 -1
  18. data/ext/sources/examples/common-ggml.cpp +2 -0
  19. data/ext/sources/examples/vad-speech-segments/speech.cpp +3 -2
  20. data/ext/sources/ggml/CMakeLists.txt +3 -4
  21. data/ext/sources/ggml/include/ggml-cuda.h +0 -3
  22. data/ext/sources/ggml/include/ggml-sycl.h +8 -0
  23. data/ext/sources/ggml/include/ggml.h +3 -1
  24. data/ext/sources/ggml/src/CMakeLists.txt +8 -1
  25. data/ext/sources/ggml/src/ggml-backend-meta.cpp +7 -4
  26. data/ext/sources/ggml/src/ggml-common.h +13 -2
  27. data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +1 -1
  28. data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +5 -6
  29. data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +78 -4
  30. data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +142 -4
  31. data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +7 -2
  32. data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +14 -0
  33. data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +26 -19
  34. data/ext/sources/ggml/src/ggml-cpu/ops.cpp +129 -46
  35. data/ext/sources/ggml/src/ggml-cpu/quants.c +51 -0
  36. data/ext/sources/ggml/src/ggml-cpu/quants.h +3 -0
  37. data/ext/sources/ggml/src/ggml-cpu/simd-gemm.h +1 -1
  38. data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +11 -0
  39. data/ext/sources/ggml/src/ggml-cpu/vec.cpp +2 -2
  40. data/ext/sources/ggml/src/ggml-cuda/binbcast.cu +90 -46
  41. data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
  42. data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
  43. data/ext/sources/ggml/src/ggml-cuda/common.cuh +4 -0
  44. data/ext/sources/ggml/src/ggml-cuda/concat.cu +33 -21
  45. data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cu +14 -12
  46. data/ext/sources/ggml/src/ggml-cuda/convert.cu +86 -34
  47. data/ext/sources/ggml/src/ggml-cuda/cpy.cu +80 -29
  48. data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +9 -5
  49. data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +4 -0
  50. data/ext/sources/ggml/src/ggml-cuda/fattn-tile.cuh +9 -5
  51. data/ext/sources/ggml/src/ggml-cuda/fattn.cu +27 -21
  52. data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cu +40 -25
  53. data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cuh +10 -0
  54. data/ext/sources/ggml/src/ggml-cuda/getrows.cu +15 -12
  55. data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +718 -1248
  56. data/ext/sources/ggml/src/ggml-cuda/mmq.cu +7 -0
  57. data/ext/sources/ggml/src/ggml-cuda/mmvq.cu +77 -40
  58. data/ext/sources/ggml/src/ggml-cuda/out-prod.cu +55 -12
  59. data/ext/sources/ggml/src/ggml-cuda/set-rows.cu +64 -4
  60. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +1 -0
  61. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +1 -0
  62. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +1 -0
  63. data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +1 -0
  64. data/ext/sources/ggml/src/ggml-cuda/topk-moe.cu +7 -1
  65. data/ext/sources/ggml/src/ggml-cuda/vendors/hip.h +1 -0
  66. data/ext/sources/ggml/src/ggml-cuda/vendors/musa.h +1 -0
  67. data/ext/sources/ggml/src/ggml-hexagon/CMakeLists.txt +0 -5
  68. data/ext/sources/ggml/src/ggml-hexagon/ggml-hexagon.cpp +1634 -1293
  69. data/ext/sources/ggml/src/ggml-hexagon/htp/CMakeLists.txt +11 -40
  70. data/ext/sources/ggml/src/ggml-hexagon/htp/cmake-toolchain.cmake +13 -15
  71. data/ext/sources/ggml/src/ggml-hexagon/htp/concat-ops.c +1 -1
  72. data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.c +1749 -399
  73. data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.h +303 -0
  74. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-common.h +80 -0
  75. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-dma.h +26 -23
  76. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-profile.h +64 -0
  77. data/ext/sources/ggml/src/ggml-hexagon/htp/hex-utils.h +1 -83
  78. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-fa-kernels.h +555 -0
  79. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-mm-kernels-tiled.h +1303 -0
  80. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.c +9 -0
  81. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.h +27 -4
  82. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-utils.h +59 -37
  83. data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ctx.h +11 -3
  84. data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ops.h +52 -12
  85. data/ext/sources/ggml/src/ggml-hexagon/htp/htp-vtcm.h +19 -0
  86. data/ext/sources/ggml/src/ggml-hexagon/htp/htp_iface.idl +2 -1
  87. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-base.h +14 -30
  88. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-exp.h +39 -0
  89. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-fa-kernels.h +232 -0
  90. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-flat.h +1511 -0
  91. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-tiled.h +1200 -0
  92. data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-sigmoid.h +39 -0
  93. data/ext/sources/ggml/src/ggml-hexagon/htp/main.c +127 -32
  94. data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.c +3023 -4425
  95. data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.h +650 -0
  96. data/ext/sources/ggml/src/ggml-hexagon/htp/rope-ops.c +48 -13
  97. data/ext/sources/ggml/src/ggml-hexagon/htp/ssm-conv.c +10 -9
  98. data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.c +15 -3
  99. data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.h +8 -0
  100. data/ext/sources/ggml/src/ggml-hexagon/htp-opnode.h +168 -50
  101. data/ext/sources/ggml/src/ggml-hexagon/libggml-htp.inf +0 -4
  102. data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +5 -0
  103. data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.cpp +69 -5
  104. data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.h +4 -1
  105. data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.m +27 -6
  106. data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +38 -0
  107. data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.cpp +132 -2
  108. data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.h +2 -0
  109. data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +345 -87
  110. data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +13 -0
  111. data/ext/sources/ggml/src/ggml-opencl/fa_tune.h +92 -0
  112. data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +4060 -357
  113. data/ext/sources/ggml/src/ggml-opencl/kernels/cvt.cl +198 -0
  114. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +81 -41
  115. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +88 -39
  116. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +1995 -96
  117. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q4_0.cl +1615 -0
  118. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q8_0.cl +1486 -0
  119. data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_pre_f16.cl +156 -0
  120. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl +74 -6
  121. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl +74 -6
  122. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl +74 -6
  123. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl +71 -6
  124. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl +74 -6
  125. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl +74 -6
  126. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl +74 -6
  127. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl +74 -6
  128. data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q1_0_f32.cl +94 -0
  129. data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q1_0_f32.cl +121 -0
  130. data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q8_0_f32.cl +1 -1
  131. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mm_q1_0_f32_l4_lm.cl +156 -0
  132. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +1149 -0
  133. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32.cl +141 -0
  134. data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32_flat.cl +190 -0
  135. data/ext/sources/ggml/src/ggml-opencl/kernels/norm.cl +5 -2
  136. data/ext/sources/ggml/src/ggml-opencl/kernels/set_rows.cl +500 -0
  137. data/ext/sources/ggml/src/ggml-opencl/libdl.h +79 -0
  138. data/ext/sources/ggml/src/ggml-openvino/.clang-format +0 -5
  139. data/ext/sources/ggml/src/ggml-openvino/CMakeLists.txt +2 -4
  140. data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.cpp +733 -130
  141. data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.h +76 -23
  142. data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.cpp +57 -3
  143. data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.h +29 -8
  144. data/ext/sources/ggml/src/ggml-openvino/ggml-openvino.cpp +307 -59
  145. data/ext/sources/ggml/src/ggml-openvino/ggml-quants.cpp +66 -0
  146. data/ext/sources/ggml/src/ggml-openvino/ggml-quants.h +10 -4
  147. data/ext/sources/ggml/src/ggml-openvino/openvino/decoder.h +56 -16
  148. data/ext/sources/ggml/src/ggml-openvino/openvino/frontend.h +1 -1
  149. data/ext/sources/ggml/src/ggml-openvino/openvino/input_model.h +4 -4
  150. data/ext/sources/ggml/src/ggml-openvino/openvino/node_context.h +94 -37
  151. data/ext/sources/ggml/src/ggml-openvino/openvino/op/add_id.cpp +76 -0
  152. data/ext/sources/ggml/src/ggml-openvino/openvino/op/argsort.cpp +47 -0
  153. data/ext/sources/ggml/src/ggml-openvino/openvino/op/clamp.cpp +33 -0
  154. data/ext/sources/ggml/src/ggml-openvino/openvino/op/concat.cpp +48 -0
  155. data/ext/sources/ggml/src/ggml-openvino/openvino/op/cont.cpp +8 -16
  156. data/ext/sources/ggml/src/ggml-openvino/openvino/op/cpy.cpp +14 -1
  157. data/ext/sources/ggml/src/ggml-openvino/openvino/op/div.cpp +146 -0
  158. data/ext/sources/ggml/src/ggml-openvino/openvino/op/flash_attn_ext.cpp +108 -21
  159. data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.cpp +282 -0
  160. data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.hpp +65 -0
  161. data/ext/sources/ggml/src/ggml-openvino/openvino/op/get_rows.cpp +2 -9
  162. data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_geglu.cpp +21 -7
  163. data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_swiglu.cpp +41 -8
  164. data/ext/sources/ggml/src/ggml-openvino/openvino/op/im2col.cpp +120 -0
  165. data/ext/sources/ggml/src/ggml-openvino/openvino/op/l2_norm.cpp +44 -0
  166. data/ext/sources/ggml/src/ggml-openvino/openvino/op/mul_mat_id.cpp +226 -0
  167. data/ext/sources/ggml/src/ggml-openvino/openvino/op/mulmat.cpp +19 -9
  168. data/ext/sources/ggml/src/ggml-openvino/openvino/op/norm.cpp +58 -0
  169. data/ext/sources/ggml/src/ggml-openvino/openvino/op/pad.cpp +95 -0
  170. data/ext/sources/ggml/src/ggml-openvino/openvino/op/permute.cpp +58 -13
  171. data/ext/sources/ggml/src/ggml-openvino/openvino/op/repeat.cpp +74 -0
  172. data/ext/sources/ggml/src/ggml-openvino/openvino/op/reshape.cpp +13 -6
  173. data/ext/sources/ggml/src/ggml-openvino/openvino/op/rms_norm.cpp +1 -1
  174. data/ext/sources/ggml/src/ggml-openvino/openvino/op/rope.cpp +134 -38
  175. data/ext/sources/ggml/src/ggml-openvino/openvino/op/set_rows.cpp +3 -3
  176. data/ext/sources/ggml/src/ggml-openvino/openvino/op/softmax.cpp +126 -49
  177. data/ext/sources/ggml/src/ggml-openvino/openvino/op/ssm_conv.cpp +59 -0
  178. data/ext/sources/ggml/src/ggml-openvino/openvino/op/sum_rows.cpp +27 -0
  179. data/ext/sources/ggml/src/ggml-openvino/openvino/op/transpose.cpp +32 -1
  180. data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_silu.cpp +1 -1
  181. data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_softplus.cpp +38 -0
  182. data/ext/sources/ggml/src/ggml-openvino/openvino/op/view.cpp +90 -25
  183. data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.cpp +41 -23
  184. data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.h +18 -5
  185. data/ext/sources/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h +1 -1
  186. data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.cpp +43 -40
  187. data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.h +5 -4
  188. data/ext/sources/ggml/src/ggml-openvino/openvino/utils.cpp +548 -3
  189. data/ext/sources/ggml/src/ggml-openvino/openvino/utils.h +28 -26
  190. data/ext/sources/ggml/src/ggml-openvino/utils.cpp +383 -94
  191. data/ext/sources/ggml/src/ggml-openvino/utils.h +11 -8
  192. data/ext/sources/ggml/src/ggml-quants.c +76 -0
  193. data/ext/sources/ggml/src/ggml-quants.h +3 -0
  194. data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +5 -5
  195. data/ext/sources/ggml/src/ggml-sycl/backend.hpp +2 -0
  196. data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +12 -0
  197. data/ext/sources/ggml/src/ggml-sycl/col2im-1d.cpp +102 -0
  198. data/ext/sources/ggml/src/ggml-sycl/col2im-1d.hpp +8 -0
  199. data/ext/sources/ggml/src/ggml-sycl/common.cpp +6 -8
  200. data/ext/sources/ggml/src/ggml-sycl/common.hpp +19 -2
  201. data/ext/sources/ggml/src/ggml-sycl/concat.cpp +21 -1
  202. data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.cpp +158 -0
  203. data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.hpp +10 -0
  204. data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.cpp +125 -0
  205. data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.hpp +10 -0
  206. data/ext/sources/ggml/src/ggml-sycl/conv2d.cpp +150 -0
  207. data/ext/sources/ggml/src/ggml-sycl/conv2d.hpp +10 -0
  208. data/ext/sources/ggml/src/ggml-sycl/conv3d.cpp +224 -0
  209. data/ext/sources/ggml/src/ggml-sycl/conv3d.hpp +8 -0
  210. data/ext/sources/ggml/src/ggml-sycl/convert.cpp +6 -0
  211. data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +706 -0
  212. data/ext/sources/ggml/src/ggml-sycl/cpy.hpp +281 -0
  213. data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.cpp +255 -0
  214. data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.hpp +7 -0
  215. data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +15 -0
  216. data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +492 -319
  217. data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +15 -7
  218. data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +215 -115
  219. data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +2 -0
  220. data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +1006 -336
  221. data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +252 -67
  222. data/ext/sources/ggml/src/ggml-sycl/mmvq.hpp +17 -0
  223. data/ext/sources/ggml/src/ggml-sycl/norm.cpp +103 -49
  224. data/ext/sources/ggml/src/ggml-sycl/outprod.cpp +45 -9
  225. data/ext/sources/ggml/src/ggml-sycl/pool.cpp +185 -0
  226. data/ext/sources/ggml/src/ggml-sycl/pool.hpp +22 -0
  227. data/ext/sources/ggml/src/ggml-sycl/presets.hpp +3 -1
  228. data/ext/sources/ggml/src/ggml-sycl/set_rows.cpp +10 -2
  229. data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +9 -10
  230. data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +35 -0
  231. data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +5 -0
  232. data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +833 -215
  233. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/col2im_1d.comp +61 -0
  234. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +1 -1
  235. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv3d_mm.comp +431 -0
  236. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/diag.comp +3 -3
  237. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +1 -0
  238. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +1 -0
  239. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl +21 -19
  240. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_back.comp +25 -0
  241. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl +23 -4
  242. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl +14 -18
  243. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +4 -7
  244. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq.comp +21 -24
  245. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +31 -23
  246. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +6 -5
  247. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_funcs.glsl +84 -67
  248. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +10 -10
  249. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +3 -3
  250. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +3 -3
  251. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tri.comp +3 -3
  252. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/unary.comp +168 -0
  253. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +121 -74
  254. data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp +26 -19
  255. data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu.cpp +31 -36
  256. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/common_decls.tmpl +16 -2
  257. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl +7 -7
  258. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/get_rows.wgsl +21 -0
  259. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_decls.tmpl +439 -320
  260. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_vec.wgsl +2 -2
  261. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec.wgsl +45 -39
  262. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_acc.tmpl +586 -465
  263. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_q_acc.tmpl +63 -69
  264. data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/quantize_q8.wgsl +14 -9
  265. data/ext/sources/ggml/src/ggml.c +36 -14
  266. data/ext/sources/include/whisper.h +21 -0
  267. data/ext/sources/src/whisper.cpp +164 -14
  268. data/lib/whisper/log_settable.rb +5 -8
  269. data/lib/whisper/model/uri.rb +0 -7
  270. data/sig/whisper.rbs +6 -0
  271. data/test/test_vad.rb +9 -0
  272. data/test/test_vad_context.rb +2 -2
  273. data/whispercpp.gemspec +1 -1
  274. metadata +62 -37
  275. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c +0 -1878
  276. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-matmul-ops.c +0 -2066
  277. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.c +0 -6
  278. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.h +0 -88
  279. data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-profile.h +0 -34
  280. data/ext/sources/ggml/src/ggml-hexagon/htp/vtcm-utils.h +0 -16
  281. data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_gelu.cpp +0 -25
  282. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/abs.comp +0 -21
  283. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/ceil.comp +0 -22
  284. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +0 -17
  285. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +0 -17
  286. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/elu.comp +0 -27
  287. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/exp.comp +0 -20
  288. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/floor.comp +0 -22
  289. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +0 -25
  290. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp +0 -39
  291. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +0 -23
  292. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardsigmoid.comp +0 -22
  293. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardswish.comp +0 -22
  294. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +0 -22
  295. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/neg.comp +0 -20
  296. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +0 -21
  297. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/round.comp +0 -29
  298. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sgn.comp +0 -21
  299. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +0 -20
  300. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +0 -22
  301. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +0 -17
  302. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/softplus.comp +0 -23
  303. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sqrt.comp +0 -17
  304. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +0 -17
  305. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/step.comp +0 -22
  306. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +0 -20
  307. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/trunc.comp +0 -22
  308. data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/xielu.comp +0 -35
@@ -1,6 +1,7 @@
1
1
  #include "cpy.hpp"
2
2
 
3
3
  #include <float.h>
4
+ #include <vector>
4
5
 
5
6
  #include "dequantize.hpp"
6
7
  #include "ggml-sycl/common.hpp"
@@ -50,6 +51,57 @@ static void cpy_1_i32_i32(const char * cxi, char * cdsti) {
50
51
  *dsti = *xi;
51
52
  }
52
53
 
54
+ static void cpy_1_f32_i32(const char * cxi, char * cdsti) {
55
+ const float * xi = (const float *) cxi;
56
+ int32_t * dsti = (int32_t *) cdsti;
57
+
58
+ *dsti = (int32_t) *xi;
59
+ }
60
+
61
+ static void cpy_1_i32_f32(const char * cxi, char * cdsti) {
62
+ const int32_t * xi = (const int32_t *) cxi;
63
+ float * dsti = (float *) cdsti;
64
+
65
+ *dsti = (float) *xi;
66
+ }
67
+
68
+ #ifdef GGML_SYCL_HAS_BF16
69
+ static void cpy_1_f32_bf16(const char * cxi, char * cdsti) {
70
+ const float * xi = (const float *) cxi;
71
+ sycl::ext::oneapi::bfloat16 * dsti = (sycl::ext::oneapi::bfloat16 *) cdsti;
72
+
73
+ *dsti = sycl::ext::oneapi::bfloat16(*xi);
74
+ }
75
+
76
+ static void cpy_1_bf16_f32(const char * cxi, char * cdsti) {
77
+ const sycl::ext::oneapi::bfloat16 * xi = (const sycl::ext::oneapi::bfloat16 *) cxi;
78
+ float * dsti = (float *) cdsti;
79
+
80
+ *dsti = static_cast<float>(*xi);
81
+ }
82
+
83
+ static void cpy_1_bf16_bf16(const char * cxi, char * cdsti) {
84
+ const sycl::ext::oneapi::bfloat16 * xi = (const sycl::ext::oneapi::bfloat16 *) cxi;
85
+ sycl::ext::oneapi::bfloat16 * dsti = (sycl::ext::oneapi::bfloat16 *) cdsti;
86
+
87
+ *dsti = *xi;
88
+ }
89
+
90
+ static void cpy_1_f16_bf16(const char * cxi, char * cdsti) {
91
+ const sycl::half * xi = (const sycl::half *) cxi;
92
+ sycl::ext::oneapi::bfloat16 * dsti = (sycl::ext::oneapi::bfloat16 *) cdsti;
93
+
94
+ *dsti = sycl::ext::oneapi::bfloat16(static_cast<float>(*xi));
95
+ }
96
+
97
+ static void cpy_1_bf16_f16(const char * cxi, char * cdsti) {
98
+ const sycl::ext::oneapi::bfloat16 * xi = (const sycl::ext::oneapi::bfloat16 *) cxi;
99
+ sycl::half * dsti = (sycl::half *) cdsti;
100
+
101
+ *dsti = sycl::half(static_cast<float>(*xi));
102
+ }
103
+ #endif
104
+
53
105
  template <cpy_kernel_t cpy_1>
54
106
  static void cpy_f32_f16(const char * cx, char * cdst, const int ne, const int ne00, const int ne01, const int ne02,
55
107
  const int nb00, const int nb01, const int nb02, const int nb03, const int ne10, const int ne11,
@@ -247,6 +299,38 @@ static void ggml_cpy_f32_f16_sycl(const char * cx, char * cdst, const int ne, co
247
299
  }
248
300
  }
249
301
 
302
+ static void ggml_cpy_f32_i32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
303
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
304
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
305
+ const int nb12, const int nb13, queue_ptr stream) {
306
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
307
+ {
308
+ stream->parallel_for(
309
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
310
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
311
+ [=](sycl::nd_item<3> item_ct1) {
312
+ cpy_f32_f16<cpy_1_f32_i32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
313
+ nb10, nb11, nb12, nb13, item_ct1);
314
+ });
315
+ }
316
+ }
317
+
318
+ static void ggml_cpy_i32_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
319
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
320
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
321
+ const int nb12, const int nb13, queue_ptr stream) {
322
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
323
+ {
324
+ stream->parallel_for(
325
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
326
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
327
+ [=](sycl::nd_item<3> item_ct1) {
328
+ cpy_f32_f16<cpy_1_i32_f32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
329
+ nb10, nb11, nb12, nb13, item_ct1);
330
+ });
331
+ }
332
+ }
333
+
250
334
  static void ggml_cpy_f32_q8_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
251
335
  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
252
336
  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
@@ -376,6 +460,19 @@ static void ggml_cpy_q5_1_f32_sycl(const char * cx, char * cdst, const int ne, c
376
460
  });
377
461
  }
378
462
 
463
+ static void ggml_cpy_mxfp4_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
464
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
465
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
466
+ const int nb12, const int nb13, queue_ptr stream) {
467
+ const int num_blocks = ne;
468
+ stream->parallel_for(
469
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks), sycl::range<3>(1, 1, 1)), [=](sycl::nd_item<3> item_ct1) {
470
+ cpy_q_f32<cpy_blck_q_f32<dequantize_mxfp4, QK_MXFP4>, QK_MXFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00,
471
+ nb01, nb02, nb03, ne10, ne11, ne12,
472
+ nb10, nb11, nb12, nb13, item_ct1);
473
+ });
474
+ }
475
+
379
476
  static void ggml_cpy_f32_iq4_nl_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
380
477
  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
381
478
  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
@@ -389,6 +486,269 @@ static void ggml_cpy_f32_iq4_nl_sycl(const char * cx, char * cdst, const int ne,
389
486
  });
390
487
  }
391
488
 
489
+ static void cpy_blck_f16_q4_0(const char * cxi, char * cdsti) {
490
+ const sycl::half * xi = (const sycl::half *) cxi;
491
+ float xf[QK4_0];
492
+
493
+ for (int j = 0; j < QK4_0; ++j) {
494
+ xf[j] = (float) xi[j];
495
+ }
496
+
497
+ cpy_blck_f32_q4_0((const char *) xf, cdsti);
498
+ }
499
+
500
+ static void cpy_blck_f16_q4_1(const char * cxi, char * cdsti) {
501
+ const sycl::half * xi = (const sycl::half *) cxi;
502
+ float xf[QK4_1];
503
+
504
+ for (int j = 0; j < QK4_1; ++j) {
505
+ xf[j] = (float) xi[j];
506
+ }
507
+
508
+ cpy_blck_f32_q4_1((const char *) xf, cdsti);
509
+ }
510
+
511
+ static void cpy_blck_f16_q5_0(const char * cxi, char * cdsti) {
512
+ const sycl::half * xi = (const sycl::half *) cxi;
513
+ float xf[QK5_0];
514
+
515
+ for (int j = 0; j < QK5_0; ++j) {
516
+ xf[j] = (float) xi[j];
517
+ }
518
+
519
+ cpy_blck_f32_q5_0((const char *) xf, cdsti);
520
+ }
521
+
522
+ static void ggml_cpy_f16_q4_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
523
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
524
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
525
+ const int nb12, const int nb13, queue_ptr stream) {
526
+ GGML_ASSERT(ne % QK4_0 == 0);
527
+ const int num_blocks = ne / QK4_0;
528
+ stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks), sycl::range<3>(1, 1, 1)),
529
+ [=](sycl::nd_item<3> item_ct1) {
530
+ cpy_f32_q<cpy_blck_f16_q4_0, QK4_0>(cx, cdst, ne, ne00, ne01, ne02,
531
+ nb00, nb01, nb02, nb03,
532
+ ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
533
+ });
534
+ }
535
+
536
+ static void ggml_cpy_f16_q4_1_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
537
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
538
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
539
+ const int nb12, const int nb13, queue_ptr stream) {
540
+ GGML_ASSERT(ne % QK4_1 == 0);
541
+ const int num_blocks = ne / QK4_1;
542
+ stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks), sycl::range<3>(1, 1, 1)),
543
+ [=](sycl::nd_item<3> item_ct1) {
544
+ cpy_f32_q<cpy_blck_f16_q4_1, QK4_1>(cx, cdst, ne, ne00, ne01, ne02,
545
+ nb00, nb01, nb02, nb03,
546
+ ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
547
+ });
548
+ }
549
+
550
+ static void ggml_cpy_f16_q5_0_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
551
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
552
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
553
+ const int nb12, const int nb13, queue_ptr stream) {
554
+ GGML_ASSERT(ne % QK5_0 == 0);
555
+ const int num_blocks = ne / QK5_0;
556
+ stream->parallel_for(sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks), sycl::range<3>(1, 1, 1)),
557
+ [=](sycl::nd_item<3> item_ct1) {
558
+ cpy_f32_q<cpy_blck_f16_q5_0, QK5_0>(cx, cdst, ne, ne00, ne01, ne02,
559
+ nb00, nb01, nb02, nb03,
560
+ ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
561
+ });
562
+ }
563
+
564
+ static bool ggml_sycl_is_quantized_type(enum ggml_type type) {
565
+ switch (type) {
566
+ case GGML_TYPE_Q1_0:
567
+ case GGML_TYPE_Q4_0:
568
+ case GGML_TYPE_Q4_1:
569
+ case GGML_TYPE_Q5_0:
570
+ case GGML_TYPE_Q5_1:
571
+ case GGML_TYPE_Q8_0:
572
+ case GGML_TYPE_MXFP4:
573
+ case GGML_TYPE_NVFP4:
574
+ case GGML_TYPE_Q2_K:
575
+ case GGML_TYPE_Q3_K:
576
+ case GGML_TYPE_Q4_K:
577
+ case GGML_TYPE_Q5_K:
578
+ case GGML_TYPE_Q6_K:
579
+ case GGML_TYPE_IQ2_XXS:
580
+ case GGML_TYPE_IQ2_XS:
581
+ case GGML_TYPE_IQ2_S:
582
+ case GGML_TYPE_IQ3_XXS:
583
+ case GGML_TYPE_IQ3_S:
584
+ case GGML_TYPE_IQ1_S:
585
+ case GGML_TYPE_IQ1_M:
586
+ case GGML_TYPE_IQ4_NL:
587
+ case GGML_TYPE_IQ4_XS:
588
+ return true;
589
+ default:
590
+ return false;
591
+ }
592
+ }
593
+
594
+ static bool ggml_sycl_can_quantize_rows_sycl(enum ggml_type type) {
595
+ switch (type) {
596
+ case GGML_TYPE_Q1_0:
597
+ case GGML_TYPE_Q4_0:
598
+ case GGML_TYPE_Q4_1:
599
+ case GGML_TYPE_Q5_0:
600
+ case GGML_TYPE_Q5_1:
601
+ case GGML_TYPE_Q8_0:
602
+ case GGML_TYPE_MXFP4:
603
+ case GGML_TYPE_NVFP4:
604
+ case GGML_TYPE_Q2_K:
605
+ case GGML_TYPE_Q3_K:
606
+ case GGML_TYPE_Q4_K:
607
+ case GGML_TYPE_Q5_K:
608
+ case GGML_TYPE_Q6_K:
609
+ case GGML_TYPE_IQ4_NL:
610
+ case GGML_TYPE_IQ4_XS:
611
+ return true;
612
+ default:
613
+ return false;
614
+ }
615
+ }
616
+
617
+ template <typename SrcScalar>
618
+ static inline float ggml_sycl_src_to_f32(const SrcScalar & x) {
619
+ return (float) x;
620
+ }
621
+
622
+ #ifdef GGML_SYCL_HAS_BF16
623
+ template <>
624
+ inline float ggml_sycl_src_to_f32<sycl::ext::oneapi::bfloat16>(const sycl::ext::oneapi::bfloat16 & x) {
625
+ return static_cast<float>(x);
626
+ }
627
+
628
+ template <>
629
+ inline float ggml_sycl_src_to_f32<ggml_bf16_t>(const ggml_bf16_t & x) {
630
+ union {
631
+ uint32_t u32;
632
+ float f32;
633
+ } value;
634
+
635
+ value.u32 = (uint32_t) x.bits << 16;
636
+ return value.f32;
637
+ }
638
+ #endif
639
+
640
+ template <typename SrcScalar, cpy_kernel_t quantize_block, int qk>
641
+ static void ggml_sycl_quantize_rows_q(const char * cx, char * cdst, const int64_t ne,
642
+ const int64_t ne00, const int64_t ne01, const int64_t ne02,
643
+ const size_t nb00, const size_t nb01, const size_t nb02, const size_t nb03,
644
+ const int64_t ne10, const int64_t ne11, const int64_t ne12,
645
+ const size_t nb10, const size_t nb11, const size_t nb12, const size_t nb13,
646
+ queue_ptr stream) {
647
+ GGML_ASSERT(ne % qk == 0);
648
+ GGML_ASSERT(ne00 % qk == 0);
649
+
650
+ const int64_t total_blocks = ne / qk;
651
+ constexpr int block_size = 256;
652
+ const int64_t grid_size = ceil_div(total_blocks, (int64_t) block_size);
653
+
654
+ stream->parallel_for(sycl::nd_range<1>(grid_size * block_size, block_size), [=](sycl::nd_item<1> item_ct1) {
655
+ const int64_t block_idx = item_ct1.get_global_linear_id();
656
+ if (block_idx >= total_blocks) {
657
+ return;
658
+ }
659
+
660
+ const int64_t i = block_idx * qk;
661
+
662
+ const int64_t i03 = i / (ne00 * ne01 * ne02);
663
+ const int64_t i02 = (i - i03 * ne00 * ne01 * ne02) / (ne00 * ne01);
664
+ const int64_t i01 = (i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00) / ne00;
665
+ const int64_t i00 = i - i03 * ne00 * ne01 * ne02 - i02 * ne01 * ne00 - i01 * ne00;
666
+ const size_t x_offset = i00 * nb00 + i01 * nb01 + i02 * nb02 + i03 * nb03;
667
+
668
+ const int64_t i13 = i / (ne10 * ne11 * ne12);
669
+ const int64_t i12 = (i - i13 * ne10 * ne11 * ne12) / (ne10 * ne11);
670
+ const int64_t i11 = (i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11) / ne10;
671
+ const int64_t i10 = i - i13 * ne10 * ne11 * ne12 - i12 * ne10 * ne11 - i11 * ne10;
672
+ const size_t dst_offset = (i10 / qk) * nb10 + i11 * nb11 + i12 * nb12 + i13 * nb13;
673
+
674
+ float xf[qk];
675
+ if (nb00 == sizeof(SrcScalar)) {
676
+ const SrcScalar * src_row = (const SrcScalar *) (cx + x_offset);
677
+ for (int j = 0; j < qk; ++j) {
678
+ xf[j] = ggml_sycl_src_to_f32(src_row[j]);
679
+ }
680
+ } else {
681
+ for (int j = 0; j < qk; ++j) {
682
+ const SrcScalar * src_val = (const SrcScalar *) (cx + x_offset + j * nb00);
683
+ xf[j] = ggml_sycl_src_to_f32(*src_val);
684
+ }
685
+ }
686
+
687
+ quantize_block((const char *) xf, cdst + dst_offset);
688
+ });
689
+ }
690
+
691
+ template <typename SrcScalar>
692
+ static void ggml_sycl_quantize_rows_sycl(const char * cx, char * cdst, const ggml_tensor * src0, const ggml_tensor * src1,
693
+ const int64_t ne, const int64_t ne00, const int64_t ne01, const int64_t ne02,
694
+ const size_t nb00, const size_t nb01, const size_t nb02, const size_t nb03,
695
+ const int64_t ne10, const int64_t ne11, const int64_t ne12, const size_t nb10,
696
+ const size_t nb11, const size_t nb12, const size_t nb13, queue_ptr stream) {
697
+ GGML_UNUSED(src0);
698
+ GGML_UNUSED(src1);
699
+
700
+ switch (src1->type) {
701
+ case GGML_TYPE_Q8_0:
702
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q8_0, QK8_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
703
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11,
704
+ nb12, nb13, stream);
705
+ break;
706
+ case GGML_TYPE_Q1_0:
707
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q1_0, QK1_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
708
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11,
709
+ nb12, nb13, stream);
710
+ break;
711
+ case GGML_TYPE_Q5_1:
712
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q5_1, QK5_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
713
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11,
714
+ nb12, nb13, stream);
715
+ break;
716
+ case GGML_TYPE_Q5_0:
717
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q5_0, QK5_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
718
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11,
719
+ nb12, nb13, stream);
720
+ break;
721
+ case GGML_TYPE_Q4_1:
722
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q4_1, QK4_1>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
723
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11,
724
+ nb12, nb13, stream);
725
+ break;
726
+ case GGML_TYPE_Q4_0:
727
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_q4_0, QK4_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01,
728
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11,
729
+ nb12, nb13, stream);
730
+ break;
731
+ case GGML_TYPE_IQ4_NL:
732
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_iq4_nl, QK4_NL>(cx, cdst, ne, ne00, ne01, ne02, nb00,
733
+ nb01, nb02, nb03, ne10, ne11, ne12,
734
+ nb10, nb11, nb12, nb13, stream);
735
+ break;
736
+ case GGML_TYPE_MXFP4:
737
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_mxfp4, QK_MXFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00,
738
+ nb01, nb02, nb03, ne10, ne11, ne12,
739
+ nb10, nb11, nb12, nb13, stream);
740
+ break;
741
+ case GGML_TYPE_NVFP4:
742
+ ggml_sycl_quantize_rows_q<SrcScalar, cpy_blck_f32_nvfp4, QK_NVFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00,
743
+ nb01, nb02, nb03, ne10, ne11, ne12,
744
+ nb10, nb11, nb12, nb13, stream);
745
+ break;
746
+ default:
747
+ GGML_ABORT("unsupported quantized target type in sycl quantizer src1->type=%s\n",
748
+ ggml_type_name(src1->type));
749
+ }
750
+ }
751
+
392
752
  static void ggml_cpy_f16_f16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
393
753
  const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
394
754
  const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
@@ -509,8 +869,269 @@ static void ggml_cpy_q4_1_q4_1(const char * cx, char * cdst, const int ne, const
509
869
  });
510
870
  }
511
871
 
872
+ static void ggml_cpy_q1_0_q1_0(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
873
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
874
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
875
+ const int nb12, const int nb13, queue_ptr stream) {
876
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
877
+ stream->parallel_for(
878
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
879
+ cpy_q_q<block_q1_0, QK1_0>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
880
+ });
881
+ }
882
+
883
+ static void ggml_cpy_mxfp4_mxfp4(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
884
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
885
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
886
+ const int nb12, const int nb13, queue_ptr stream) {
887
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
888
+ stream->parallel_for(
889
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
890
+ cpy_q_q<block_mxfp4, QK_MXFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
891
+ });
892
+ }
893
+
894
+ static void ggml_cpy_nvfp4_nvfp4(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
895
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
896
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
897
+ const int nb12, const int nb13, queue_ptr stream) {
898
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
899
+ stream->parallel_for(
900
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
901
+ cpy_q_q<block_nvfp4, QK_NVFP4>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
902
+ });
903
+ }
904
+
905
+ static void ggml_cpy_q2_K_q2_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
906
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
907
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
908
+ const int nb12, const int nb13, queue_ptr stream) {
909
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
910
+ stream->parallel_for(
911
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
912
+ cpy_q_q<block_q2_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
913
+ });
914
+ }
915
+
916
+ static void ggml_cpy_q3_K_q3_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
917
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
918
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
919
+ const int nb12, const int nb13, queue_ptr stream) {
920
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
921
+ stream->parallel_for(
922
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
923
+ cpy_q_q<block_q3_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
924
+ });
925
+ }
926
+
927
+ static void ggml_cpy_q4_K_q4_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
928
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
929
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
930
+ const int nb12, const int nb13, queue_ptr stream) {
931
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
932
+ stream->parallel_for(
933
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
934
+ cpy_q_q<block_q4_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
935
+ });
936
+ }
937
+
938
+ static void ggml_cpy_q5_K_q5_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
939
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
940
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
941
+ const int nb12, const int nb13, queue_ptr stream) {
942
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
943
+ stream->parallel_for(
944
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
945
+ cpy_q_q<block_q5_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
946
+ });
947
+ }
948
+
949
+ static void ggml_cpy_q6_K_q6_K(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
950
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
951
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
952
+ const int nb12, const int nb13, queue_ptr stream) {
953
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
954
+ stream->parallel_for(
955
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
956
+ cpy_q_q<block_q6_K, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
957
+ });
958
+ }
959
+
960
+ static void ggml_cpy_iq2_xxs_iq2_xxs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
961
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
962
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
963
+ const int nb12, const int nb13, queue_ptr stream) {
964
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
965
+ stream->parallel_for(
966
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
967
+ cpy_q_q<block_iq2_xxs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
968
+ });
969
+ }
970
+
971
+ static void ggml_cpy_iq2_xs_iq2_xs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
972
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
973
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
974
+ const int nb12, const int nb13, queue_ptr stream) {
975
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
976
+ stream->parallel_for(
977
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
978
+ cpy_q_q<block_iq2_xs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
979
+ });
980
+ }
981
+
982
+ static void ggml_cpy_iq2_s_iq2_s(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
983
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
984
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
985
+ const int nb12, const int nb13, queue_ptr stream) {
986
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
987
+ stream->parallel_for(
988
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
989
+ cpy_q_q<block_iq2_s, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
990
+ });
991
+ }
992
+
993
+ static void ggml_cpy_iq3_xxs_iq3_xxs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
994
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
995
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
996
+ const int nb12, const int nb13, queue_ptr stream) {
997
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
998
+ stream->parallel_for(
999
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
1000
+ cpy_q_q<block_iq3_xxs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1001
+ });
1002
+ }
1003
+
1004
+ static void ggml_cpy_iq1_s_iq1_s(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1005
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1006
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1007
+ const int nb12, const int nb13, queue_ptr stream) {
1008
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
1009
+ stream->parallel_for(
1010
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
1011
+ cpy_q_q<block_iq1_s, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1012
+ });
1013
+ }
1014
+
1015
+ static void ggml_cpy_iq1_m_iq1_m(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1016
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1017
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1018
+ const int nb12, const int nb13, queue_ptr stream) {
1019
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
1020
+ stream->parallel_for(
1021
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
1022
+ cpy_q_q<block_iq1_m, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1023
+ });
1024
+ }
1025
+
1026
+ static void ggml_cpy_iq4_nl_iq4_nl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1027
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1028
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1029
+ const int nb12, const int nb13, queue_ptr stream) {
1030
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
1031
+ stream->parallel_for(
1032
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
1033
+ cpy_q_q<block_iq4_nl, QK4_NL>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1034
+ });
1035
+ }
1036
+
1037
+ static void ggml_cpy_iq3_s_iq3_s(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1038
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1039
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1040
+ const int nb12, const int nb13, queue_ptr stream) {
1041
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
1042
+ stream->parallel_for(
1043
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
1044
+ cpy_q_q<block_iq3_s, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1045
+ });
1046
+ }
1047
+
1048
+ static void ggml_cpy_iq4_xs_iq4_xs(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1049
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1050
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1051
+ const int nb12, const int nb13, queue_ptr stream) {
1052
+ const int num_blocks = ceil_div(ne, SYCL_CPY_BLOCK_SIZE);
1053
+ stream->parallel_for(
1054
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE), sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)), [=](sycl::nd_item<3> item_ct1) {
1055
+ cpy_q_q<block_iq4_xs, QK_K>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, item_ct1);
1056
+ });
1057
+ }
1058
+
1059
+ #ifdef GGML_SYCL_HAS_BF16
1060
+ static void ggml_cpy_f32_bf16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1061
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1062
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1063
+ const int nb12, const int nb13, queue_ptr stream) {
1064
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1065
+ stream->parallel_for(
1066
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1067
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1068
+ [=](sycl::nd_item<3> item_ct1) {
1069
+ cpy_f32_f16<cpy_1_f32_bf16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1070
+ nb10, nb11, nb12, nb13, item_ct1);
1071
+ });
1072
+ }
1073
+
1074
+ static void ggml_cpy_bf16_f32_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1075
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1076
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1077
+ const int nb12, const int nb13, queue_ptr stream) {
1078
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1079
+ stream->parallel_for(
1080
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1081
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1082
+ [=](sycl::nd_item<3> item_ct1) {
1083
+ cpy_f32_f16<cpy_1_bf16_f32>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1084
+ nb10, nb11, nb12, nb13, item_ct1);
1085
+ });
1086
+ }
1087
+
1088
+ static void ggml_cpy_bf16_bf16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1089
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1090
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1091
+ const int nb12, const int nb13, queue_ptr stream) {
1092
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1093
+ stream->parallel_for(
1094
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1095
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1096
+ [=](sycl::nd_item<3> item_ct1) {
1097
+ cpy_f32_f16<cpy_1_bf16_bf16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1098
+ nb10, nb11, nb12, nb13, item_ct1);
1099
+ });
1100
+ }
1101
+
1102
+ static void ggml_cpy_f16_bf16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1103
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1104
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1105
+ const int nb12, const int nb13, queue_ptr stream) {
1106
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1107
+ stream->parallel_for(
1108
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1109
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1110
+ [=](sycl::nd_item<3> item_ct1) {
1111
+ cpy_f32_f16<cpy_1_f16_bf16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1112
+ nb10, nb11, nb12, nb13, item_ct1);
1113
+ });
1114
+ }
1115
+
1116
+ static void ggml_cpy_bf16_f16_sycl(const char * cx, char * cdst, const int ne, const int ne00, const int ne01,
1117
+ const int ne02, const int nb00, const int nb01, const int nb02, const int nb03,
1118
+ const int ne10, const int ne11, const int ne12, const int nb10, const int nb11,
1119
+ const int nb12, const int nb13, queue_ptr stream) {
1120
+ const int num_blocks = (ne + SYCL_CPY_BLOCK_SIZE - 1) / SYCL_CPY_BLOCK_SIZE;
1121
+ stream->parallel_for(
1122
+ sycl::nd_range<3>(sycl::range<3>(1, 1, num_blocks) * sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE),
1123
+ sycl::range<3>(1, 1, SYCL_CPY_BLOCK_SIZE)),
1124
+ [=](sycl::nd_item<3> item_ct1) {
1125
+ cpy_f32_f16<cpy_1_bf16_f16>(cx, cdst, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1126
+ nb10, nb11, nb12, nb13, item_ct1);
1127
+ });
1128
+ }
1129
+ #endif
1130
+
512
1131
  void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, const ggml_tensor * src1) try {
513
1132
  // Unlike other operators ggml_sycl_cpy takes 2 distinct tensors instead of a dst ggml_tensor and rely on its src field
1133
+ GGML_SYCL_DEBUG("ggml_sycl_cpy: src0->type=%s, src1->type=%s\n",
1134
+ ggml_type_name(src0->type), ggml_type_name(src1->type));
514
1135
  scope_op_debug_print scope_dbg_print(__func__, src1, /*num_src=*/0, debug_get_tensor_str("\tsrc0", src0));
515
1136
  const int64_t ne = ggml_nelements(src0);
516
1137
  GGML_ASSERT(ne == ggml_nelements(src1));
@@ -525,12 +1146,31 @@ void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, co
525
1146
  if ((src0->type == src1->type) && (ggml_is_contiguous(src0) && ggml_is_contiguous(src1))) {
526
1147
  GGML_SYCL_DEBUG("%s: memcpy path\n", __func__);
527
1148
  main_stream->memcpy(src1_ddc, src0_ddc, ggml_nbytes(src0));
1149
+ } else if (src0->type == GGML_TYPE_F32 && ggml_sycl_is_quantized_type(src1->type)) {
1150
+ GGML_ASSERT(ggml_sycl_can_quantize_rows_sycl(src1->type));
1151
+ ggml_sycl_quantize_rows_sycl<float>(src0_ddc, src1_ddc, src0, src1, ne, ne00, ne01, ne02, nb00, nb01,
1152
+ nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1153
+ } else if (src0->type == GGML_TYPE_F16 && ggml_sycl_is_quantized_type(src1->type)) {
1154
+ GGML_ASSERT(ggml_sycl_can_quantize_rows_sycl(src1->type));
1155
+ ggml_sycl_quantize_rows_sycl<sycl::half>(src0_ddc, src1_ddc, src0, src1, ne, ne00, ne01, ne02, nb00,
1156
+ nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13,
1157
+ main_stream);
1158
+ #ifdef GGML_SYCL_HAS_BF16
1159
+ } else if (src0->type == GGML_TYPE_BF16 && ggml_sycl_is_quantized_type(src1->type)) {
1160
+ GGML_ASSERT(ggml_sycl_can_quantize_rows_sycl(src1->type));
1161
+ ggml_sycl_quantize_rows_sycl<ggml_bf16_t>(src0_ddc, src1_ddc, src0, src1, ne, ne00, ne01, ne02,
1162
+ nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11,
1163
+ nb12, nb13, main_stream);
1164
+ #endif
528
1165
  } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F32) {
529
1166
  ggml_cpy_f32_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
530
1167
  nb11, nb12, nb13, main_stream);
531
1168
  } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F16) {
532
1169
  ggml_cpy_f32_f16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
533
1170
  nb11, nb12, nb13, main_stream);
1171
+ } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_I32) {
1172
+ ggml_cpy_f32_i32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1173
+ nb11, nb12, nb13, main_stream);
534
1174
  } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_Q8_0) {
535
1175
  ggml_cpy_f32_q8_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
536
1176
  nb11, nb12, nb13, main_stream);
@@ -546,12 +1186,24 @@ void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, co
546
1186
  } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F16) {
547
1187
  ggml_cpy_f16_f16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
548
1188
  nb11, nb12, nb13, main_stream);
1189
+ } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_Q4_0) {
1190
+ ggml_cpy_f16_q4_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02,
1191
+ nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1192
+ } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_Q4_1) {
1193
+ ggml_cpy_f16_q4_1_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02,
1194
+ nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1195
+ } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_Q5_0) {
1196
+ ggml_cpy_f16_q5_0_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02,
1197
+ nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
549
1198
  } else if (src0->type == GGML_TYPE_I16 && src1->type == GGML_TYPE_I16) {
550
1199
  ggml_cpy_i16_i16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
551
1200
  nb11, nb12, nb13, main_stream);
552
1201
  } else if (src0->type == GGML_TYPE_I32 && src1->type == GGML_TYPE_I32) {
553
1202
  ggml_cpy_i32_i32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
554
1203
  nb11, nb12, nb13, main_stream);
1204
+ } else if (src0->type == GGML_TYPE_I32 && src1->type == GGML_TYPE_F32) {
1205
+ ggml_cpy_i32_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1206
+ nb11, nb12, nb13, main_stream);
555
1207
  } else if (src0->type == GGML_TYPE_Q4_0 && src1->type == GGML_TYPE_F32) {
556
1208
  ggml_cpy_q4_0_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
557
1209
  nb11, nb12, nb13, main_stream);
@@ -573,6 +1225,9 @@ void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, co
573
1225
  } else if (src0->type == GGML_TYPE_Q5_1 && src1->type == GGML_TYPE_F32) {
574
1226
  ggml_cpy_q5_1_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
575
1227
  nb11, nb12, nb13, main_stream);
1228
+ } else if (src0->type == GGML_TYPE_MXFP4 && src1->type == GGML_TYPE_F32) {
1229
+ ggml_cpy_mxfp4_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
1230
+ nb10, nb11, nb12, nb13, main_stream);
576
1231
  } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_IQ4_NL) {
577
1232
  ggml_cpy_f32_iq4_nl_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12,
578
1233
  nb10, nb11, nb12, nb13, main_stream);
@@ -586,6 +1241,57 @@ void ggml_sycl_cpy(ggml_backend_sycl_context & ctx, const ggml_tensor * src0, co
586
1241
  ggml_cpy_q4_0_q4_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
587
1242
  } else if (src0->type == GGML_TYPE_Q4_1 && src1->type == GGML_TYPE_Q4_1) {
588
1243
  ggml_cpy_q4_1_q4_1(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1244
+ } else if (src0->type == GGML_TYPE_Q1_0 && src1->type == GGML_TYPE_Q1_0) {
1245
+ ggml_cpy_q1_0_q1_0(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1246
+ } else if (src0->type == GGML_TYPE_MXFP4 && src1->type == GGML_TYPE_MXFP4) {
1247
+ ggml_cpy_mxfp4_mxfp4(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1248
+ } else if (src0->type == GGML_TYPE_NVFP4 && src1->type == GGML_TYPE_NVFP4) {
1249
+ ggml_cpy_nvfp4_nvfp4(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1250
+ } else if (src0->type == GGML_TYPE_Q2_K && src1->type == GGML_TYPE_Q2_K) {
1251
+ ggml_cpy_q2_K_q2_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1252
+ } else if (src0->type == GGML_TYPE_Q3_K && src1->type == GGML_TYPE_Q3_K) {
1253
+ ggml_cpy_q3_K_q3_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1254
+ } else if (src0->type == GGML_TYPE_Q4_K && src1->type == GGML_TYPE_Q4_K) {
1255
+ ggml_cpy_q4_K_q4_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1256
+ } else if (src0->type == GGML_TYPE_Q5_K && src1->type == GGML_TYPE_Q5_K) {
1257
+ ggml_cpy_q5_K_q5_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1258
+ } else if (src0->type == GGML_TYPE_Q6_K && src1->type == GGML_TYPE_Q6_K) {
1259
+ ggml_cpy_q6_K_q6_K(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1260
+ } else if (src0->type == GGML_TYPE_IQ2_XXS && src1->type == GGML_TYPE_IQ2_XXS) {
1261
+ ggml_cpy_iq2_xxs_iq2_xxs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1262
+ } else if (src0->type == GGML_TYPE_IQ2_XS && src1->type == GGML_TYPE_IQ2_XS) {
1263
+ ggml_cpy_iq2_xs_iq2_xs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1264
+ } else if (src0->type == GGML_TYPE_IQ2_S && src1->type == GGML_TYPE_IQ2_S) {
1265
+ ggml_cpy_iq2_s_iq2_s(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1266
+ } else if (src0->type == GGML_TYPE_IQ3_XXS && src1->type == GGML_TYPE_IQ3_XXS) {
1267
+ ggml_cpy_iq3_xxs_iq3_xxs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1268
+ } else if (src0->type == GGML_TYPE_IQ1_S && src1->type == GGML_TYPE_IQ1_S) {
1269
+ ggml_cpy_iq1_s_iq1_s(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1270
+ } else if (src0->type == GGML_TYPE_IQ1_M && src1->type == GGML_TYPE_IQ1_M) {
1271
+ ggml_cpy_iq1_m_iq1_m(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1272
+ } else if (src0->type == GGML_TYPE_IQ4_NL && src1->type == GGML_TYPE_IQ4_NL) {
1273
+ ggml_cpy_iq4_nl_iq4_nl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1274
+ } else if (src0->type == GGML_TYPE_IQ3_S && src1->type == GGML_TYPE_IQ3_S) {
1275
+ ggml_cpy_iq3_s_iq3_s(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1276
+ } else if (src0->type == GGML_TYPE_IQ4_XS && src1->type == GGML_TYPE_IQ4_XS) {
1277
+ ggml_cpy_iq4_xs_iq4_xs(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10, nb11, nb12, nb13, main_stream);
1278
+ #ifdef GGML_SYCL_HAS_BF16
1279
+ } else if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_BF16) {
1280
+ ggml_cpy_f32_bf16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1281
+ nb11, nb12, nb13, main_stream);
1282
+ } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_F32) {
1283
+ ggml_cpy_bf16_f32_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1284
+ nb11, nb12, nb13, main_stream);
1285
+ } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_BF16) {
1286
+ ggml_cpy_bf16_bf16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1287
+ nb11, nb12, nb13, main_stream);
1288
+ } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_BF16) {
1289
+ ggml_cpy_f16_bf16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1290
+ nb11, nb12, nb13, main_stream);
1291
+ } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_F16) {
1292
+ ggml_cpy_bf16_f16_sycl(src0_ddc, src1_ddc, ne, ne00, ne01, ne02, nb00, nb01, nb02, nb03, ne10, ne11, ne12, nb10,
1293
+ nb11, nb12, nb13, main_stream);
1294
+ #endif
589
1295
  } else {
590
1296
  GGML_LOG_ERROR("%s: unsupported type combination (%s to %s)\n", __func__, ggml_type_name(src0->type),
591
1297
  ggml_type_name(src1->type));