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
@@ -2,8 +2,10 @@
2
2
  #include "ggml-sycl/common.hpp"
3
3
  #include "ggml-sycl/presets.hpp"
4
4
 
5
- static void norm_f32(const float* x, float* dst, const int ncols, const int64_t stride_row, const int64_t stride_channel,
6
- const int64_t stride_sample, const float eps, const sycl::nd_item<3>& item_ct1, sycl::float2* s_sum, int block_size) {
5
+ static void norm_f32(const float* x, float* dst, const int ncols,
6
+ const int64_t src_stride_col, const int64_t src_stride_row, const int64_t src_stride_channel, const int64_t src_stride_sample,
7
+ const int64_t dst_stride_col, const int64_t dst_stride_row, const int64_t dst_stride_channel, const int64_t dst_stride_sample,
8
+ const float eps, const sycl::nd_item<3>& item_ct1, sycl::float2* s_sum, int block_size) {
7
9
 
8
10
  const int nrows = item_ct1.get_group_range(2);
9
11
  const int nchannels = item_ct1.get_group_range(1);
@@ -16,16 +18,16 @@ static void norm_f32(const float* x, float* dst, const int ncols, const int64_t
16
18
  const int tid = item_ct1.get_local_id(2);
17
19
  const int nwarps = nthreads / WARP_SIZE;
18
20
 
19
- const auto strided_offset = calculate_offset<3>({stride_sample, stride_channel, stride_row}, {sample, channel, row});
20
- const auto packed_offset = calculate_offset<3>({nchannels * nrows * ncols, nrows * ncols, ncols}, {sample, channel, row});
21
+ const auto src_offset = calculate_offset<3>({src_stride_sample, src_stride_channel, src_stride_row}, {sample, channel, row});
22
+ const auto dst_offset = calculate_offset<3>({dst_stride_sample, dst_stride_channel, dst_stride_row}, {sample, channel, row});
21
23
 
22
- x += strided_offset;
23
- dst += packed_offset;
24
+ x += src_offset;
25
+ dst += dst_offset;
24
26
 
25
27
  sycl::float2 mean_var = sycl::float2(0.f, 0.f);
26
28
 
27
29
  for (int col = tid; col < ncols; col += block_size) {
28
- const float xi = x[col];
30
+ const float xi = x[col * src_stride_col];
29
31
  mean_var.x() += xi;
30
32
  mean_var.y() += xi * xi;
31
33
  }
@@ -54,7 +56,7 @@ static void norm_f32(const float* x, float* dst, const int ncols, const int64_t
54
56
  const float inv_std = sycl::rsqrt(var + eps);
55
57
 
56
58
  for (int col = tid; col < ncols; col += block_size) {
57
- dst[col] = (x[col] - mean) * inv_std;
59
+ dst[col * dst_stride_col] = (x[col * src_stride_col] - mean) * inv_std;
58
60
  }
59
61
  }
60
62
 
@@ -145,8 +147,10 @@ static void group_norm_f32(const float* x, float* dst, const int group_size, con
145
147
  }
146
148
  }
147
149
 
148
- static void rms_norm_f32(const float* x, float* dst, const int ncols, const int64_t stride_row, const int64_t stride_channel,
149
- const int64_t stride_sample, const float eps, const sycl::nd_item<3>& item_ct1, float* s_sum, int block_size) {
150
+ static void rms_norm_f32(const float* x, float* dst, const int ncols,
151
+ const int64_t src_stride_col, const int64_t src_stride_row, const int64_t src_stride_channel, const int64_t src_stride_sample,
152
+ const int64_t dst_stride_col, const int64_t dst_stride_row, const int64_t dst_stride_channel, const int64_t dst_stride_sample,
153
+ const float eps, const sycl::nd_item<3>& item_ct1, float* s_sum, int block_size) {
150
154
 
151
155
  const int nrows = item_ct1.get_group_range(2);
152
156
  const int nchannels = item_ct1.get_group_range(1);
@@ -160,17 +164,17 @@ static void rms_norm_f32(const float* x, float* dst, const int ncols, const int6
160
164
  const int tid = item_ct1.get_local_id(2);
161
165
  const int nwarps = nthreads / WARP_SIZE;
162
166
 
163
- const auto strided_offset = calculate_offset<3>({stride_sample, stride_channel, stride_row}, {sample, channel, row});
164
- const auto packed_offset = calculate_offset<3>({nchannels * nrows * ncols, nrows * ncols, ncols}, {sample, channel, row});
167
+ const auto src_offset = calculate_offset<3>({src_stride_sample, src_stride_channel, src_stride_row}, {sample, channel, row});
168
+ const auto dst_offset = calculate_offset<3>({dst_stride_sample, dst_stride_channel, dst_stride_row}, {sample, channel, row});
165
169
 
166
- x += strided_offset;
167
- dst += packed_offset;
170
+ x += src_offset;
171
+ dst += dst_offset;
168
172
 
169
173
 
170
174
  float tmp = 0.0f; // partial sum for thread in warp
171
175
 
172
176
  for (int col = tid; col < ncols; col += block_size) {
173
- const float xi = x[col];
177
+ const float xi = x[col * src_stride_col];
174
178
  tmp += xi * xi;
175
179
  }
176
180
 
@@ -198,14 +202,15 @@ static void rms_norm_f32(const float* x, float* dst, const int ncols, const int6
198
202
  const float scale = sycl::rsqrt(mean + eps);
199
203
 
200
204
  for (int col = tid; col < ncols; col += block_size) {
201
- dst[col] = scale * x[col];
205
+ dst[col * dst_stride_col] = scale * x[col * src_stride_col];
202
206
  }
203
207
  }
204
208
 
205
209
  template<int warp_size>
206
210
  static void l2_norm_f32(const float * x, float * dst, const int ncols,
207
- const int64_t stride_row, const int64_t stride_channel,
208
- const int64_t stride_sample, const float eps,
211
+ const int64_t src_stride_col, const int64_t src_stride_row, const int64_t src_stride_channel,
212
+ const int64_t src_stride_sample, const int64_t dst_stride_col, const int64_t dst_stride_row,
213
+ const int64_t dst_stride_channel, const int64_t dst_stride_sample, const float eps,
209
214
  const sycl::nd_item<3>& item_ct1, float* s_sum, const int block_size) {
210
215
  const int nrows = item_ct1.get_group_range(2);
211
216
  const int nchannels = item_ct1.get_group_range(1);
@@ -215,13 +220,13 @@ static void l2_norm_f32(const float * x, float * dst, const int ncols,
215
220
  const int sample = item_ct1.get_group(0);
216
221
  const int tid = item_ct1.get_local_id(2);
217
222
 
218
- x += sample*stride_sample + channel*stride_channel + row*stride_row;
219
- dst += ((sample*nchannels + channel)*nrows + row)*ncols;
223
+ x += sample*src_stride_sample + channel*src_stride_channel + row*src_stride_row;
224
+ dst += sample*dst_stride_sample + channel*dst_stride_channel + row*dst_stride_row;
220
225
 
221
226
  float tmp = 0.0f; // partial sum for thread in warp
222
227
 
223
228
  for (int col = tid; col < ncols; col += block_size) {
224
- const float xi = x[col];
229
+ const float xi = x[col * src_stride_col];
225
230
  tmp += xi * xi;
226
231
  }
227
232
 
@@ -229,12 +234,13 @@ static void l2_norm_f32(const float * x, float * dst, const int ncols,
229
234
  const float scale = sycl::rsqrt(sycl::fmax(tmp, eps * eps));
230
235
 
231
236
  for (int col = tid; col < ncols; col += block_size) {
232
- dst[col] = scale * x[col];
237
+ dst[col * dst_stride_col] = scale * x[col * src_stride_col];
233
238
  }
234
239
  }
235
240
 
236
241
  static void norm_f32_sycl(const float * x, float * dst, const int ncols, const int nrows, const int nchannels, const int nsamples,
237
- const int64_t stride_row, const int64_t stride_channel, const int64_t stride_sample,
242
+ const int64_t src_stride_col, const int64_t src_stride_row, const int64_t src_stride_channel, const int64_t src_stride_sample,
243
+ const int64_t dst_stride_col, const int64_t dst_stride_row, const int64_t dst_stride_channel, const int64_t dst_stride_sample,
238
244
  const float eps, queue_ptr stream, int device) {
239
245
 
240
246
  const sycl::range<3> global_dims(nsamples, nchannels, nrows);
@@ -245,7 +251,10 @@ static void norm_f32_sycl(const float * x, float * dst, const int ncols, const i
245
251
  sycl::nd_range<3>(global_dims * block_dims, block_dims),
246
252
  [=](sycl::nd_item<3> item_ct1)
247
253
  [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
248
- norm_f32(x, dst, ncols, stride_row, stride_channel, stride_sample, eps, item_ct1, nullptr, WARP_SIZE);
254
+ norm_f32(x, dst, ncols,
255
+ src_stride_col, src_stride_row, src_stride_channel, src_stride_sample,
256
+ dst_stride_col, dst_stride_row, dst_stride_channel, dst_stride_sample,
257
+ eps, item_ct1, nullptr, WARP_SIZE);
249
258
  });
250
259
  });
251
260
  }
@@ -265,7 +274,10 @@ static void norm_f32_sycl(const float * x, float * dst, const int ncols, const i
265
274
  sycl::nd_range<3>(global_dims * block_dims, block_dims),
266
275
  [=](sycl::nd_item<3> item_ct1)
267
276
  [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
268
- norm_f32(x, dst, ncols, stride_row, stride_channel, stride_sample, eps, item_ct1, get_pointer(s_sum_acc_ct1), work_group_size);
277
+ norm_f32(x, dst, ncols,
278
+ src_stride_col, src_stride_row, src_stride_channel, src_stride_sample,
279
+ dst_stride_col, dst_stride_row, dst_stride_channel, dst_stride_sample,
280
+ eps, item_ct1, get_pointer(s_sum_acc_ct1), work_group_size);
269
281
  });
270
282
  });
271
283
  }
@@ -319,7 +331,9 @@ static void group_norm_f32_sycl(const float* x, float* dst,
319
331
  }
320
332
 
321
333
  static void rms_norm_f32_sycl(const float* x, float* dst, const int ncols, const int nrows, const int nchannels, const int nsamples,
322
- const int64_t stride_row, const int64_t stride_channel, const int64_t stride_sample, const float eps, queue_ptr stream, int device) {
334
+ const int64_t src_stride_col, const int64_t src_stride_row, const int64_t src_stride_channel, const int64_t src_stride_sample,
335
+ const int64_t dst_stride_col, const int64_t dst_stride_row, const int64_t dst_stride_channel, const int64_t dst_stride_sample,
336
+ const float eps, queue_ptr stream, int device) {
323
337
  // printf("%s ncols=%d, nrows=%d, WARP_SIZE=%d\n", __func__, ncols, nrows, WARP_SIZE);
324
338
 
325
339
  const sycl::range<3> global_dims(nsamples, nchannels, nrows);
@@ -330,7 +344,10 @@ static void rms_norm_f32_sycl(const float* x, float* dst, const int ncols, const
330
344
  sycl::nd_range<3>(global_dims * block_dims, block_dims),
331
345
  [=](sycl::nd_item<3> item_ct1)
332
346
  [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
333
- rms_norm_f32(x, dst, ncols, stride_row, stride_channel, stride_sample, eps, item_ct1, nullptr, WARP_SIZE);
347
+ rms_norm_f32(x, dst, ncols,
348
+ src_stride_col, src_stride_row, src_stride_channel, src_stride_sample,
349
+ dst_stride_col, dst_stride_row, dst_stride_channel, dst_stride_sample,
350
+ eps, item_ct1, nullptr, WARP_SIZE);
334
351
  });
335
352
  });
336
353
  }
@@ -350,7 +367,10 @@ static void rms_norm_f32_sycl(const float* x, float* dst, const int ncols, const
350
367
  sycl::nd_range<3>(global_dims * block_dims, block_dims),
351
368
  [=](sycl::nd_item<3> item_ct1)
352
369
  [[sycl::reqd_sub_group_size(WARP_SIZE)]] {
353
- rms_norm_f32(x, dst, ncols, stride_row, stride_channel, stride_sample, eps, item_ct1, get_pointer(s_sum_acc_ct1), work_group_size);
370
+ rms_norm_f32(x, dst, ncols,
371
+ src_stride_col, src_stride_row, src_stride_channel, src_stride_sample,
372
+ dst_stride_col, dst_stride_row, dst_stride_channel, dst_stride_sample,
373
+ eps, item_ct1, get_pointer(s_sum_acc_ct1), work_group_size);
354
374
  });
355
375
  });
356
376
  }
@@ -363,9 +383,14 @@ static void l2_norm_f32_sycl(const float * x,
363
383
  const int nrows,
364
384
  const int nchannels,
365
385
  const int nsamples,
366
- const int64_t stride_row,
367
- const int64_t stride_channel,
368
- const int64_t stride_sample,
386
+ const int64_t src_stride_col,
387
+ const int64_t src_stride_row,
388
+ const int64_t src_stride_channel,
389
+ const int64_t src_stride_sample,
390
+ const int64_t dst_stride_col,
391
+ const int64_t dst_stride_row,
392
+ const int64_t dst_stride_channel,
393
+ const int64_t dst_stride_sample,
369
394
  const float eps,
370
395
  queue_ptr stream,
371
396
  int device) {
@@ -379,7 +404,10 @@ static void l2_norm_f32_sycl(const float * x,
379
404
  block_dims),
380
405
  [=](sycl::nd_item<3> item_ct1)
381
406
  [[sycl::reqd_sub_group_size(warp_size)]] {
382
- l2_norm_f32<warp_size>(x, dst, ncols, stride_row, stride_channel, stride_sample, eps, item_ct1,
407
+ l2_norm_f32<warp_size>(x, dst, ncols,
408
+ src_stride_col, src_stride_row, src_stride_channel, src_stride_sample,
409
+ dst_stride_col, dst_stride_row, dst_stride_channel, dst_stride_sample,
410
+ eps, item_ct1,
383
411
  nullptr, warp_size);
384
412
  });
385
413
  });
@@ -398,7 +426,9 @@ static void l2_norm_f32_sycl(const float * x,
398
426
  block_dims),
399
427
  [=](sycl::nd_item<3> item_ct1)
400
428
  [[sycl::reqd_sub_group_size(warp_size)]] {
401
- l2_norm_f32<warp_size>(x, dst, ncols, stride_row, stride_channel, stride_sample,
429
+ l2_norm_f32<warp_size>(x, dst, ncols,
430
+ src_stride_col, src_stride_row, src_stride_channel, src_stride_sample,
431
+ dst_stride_col, dst_stride_row, dst_stride_channel, dst_stride_sample,
402
432
  eps, item_ct1, get_pointer(s_sum_acc_ct1), work_group_size);
403
433
  });
404
434
  });
@@ -421,12 +451,20 @@ void ggml_sycl_op_norm(ggml_backend_sycl_context& ctx, ggml_tensor* dst) {
421
451
  memcpy(&eps, dst->op_params, sizeof(float));
422
452
  GGML_ASSERT(eps >= 0.0f);
423
453
  const size_t ts0 = ggml_type_size(src0->type);
424
- GGML_ASSERT(nb00 == ts0);
425
- const int64_t s01 = nb01 / ts0;
426
- const int64_t s02 = nb02 / ts0;
427
- const int64_t s03 = nb03 / ts0;
428
-
429
- norm_f32_sycl(src0_dd, dst_dd, ne00, ne01, ne02, ne03, s01, s02, s03, eps, main_stream, ctx.device);
454
+ const size_t tdst = ggml_type_size(dst->type);
455
+ GGML_ASSERT(nb00 % ts0 == 0 && nb01 % ts0 == 0 && nb02 % ts0 == 0 && nb03 % ts0 == 0);
456
+ GGML_ASSERT(nb0 % tdst == 0 && nb1 % tdst == 0 && nb2 % tdst == 0 && nb3 % tdst == 0);
457
+ const int64_t ss0 = nb00 / ts0;
458
+ const int64_t ss1 = nb01 / ts0;
459
+ const int64_t ss2 = nb02 / ts0;
460
+ const int64_t ss3 = nb03 / ts0;
461
+ const int64_t ds0 = nb0 / tdst;
462
+ const int64_t ds1 = nb1 / tdst;
463
+ const int64_t ds2 = nb2 / tdst;
464
+ const int64_t ds3 = nb3 / tdst;
465
+
466
+ norm_f32_sycl(src0_dd, dst_dd, ne00, ne01, ne02, ne03,
467
+ ss0, ss1, ss2, ss3, ds0, ds1, ds2, ds3, eps, main_stream, ctx.device);
430
468
  }
431
469
 
432
470
  void ggml_sycl_op_group_norm(ggml_backend_sycl_context& ctx, ggml_tensor* dst) {
@@ -465,11 +503,19 @@ void ggml_sycl_op_rms_norm(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
465
503
 
466
504
  GGML_TENSOR_UNARY_OP_LOCALS
467
505
  const size_t ts0 = ggml_type_size(src0->type);
468
- GGML_ASSERT(nb00 == ts0);
469
- const int64_t s01 = nb01 / ts0;
470
- const int64_t s02 = nb02 / ts0;
471
- const int64_t s03 = nb03 / ts0;
472
- rms_norm_f32_sycl(src0_dd, dst_dd, ne00, ne01, ne02, ne03, s01, s02, s03, eps, main_stream, ctx.device);
506
+ const size_t tdst = ggml_type_size(dst->type);
507
+ GGML_ASSERT(nb00 % ts0 == 0 && nb01 % ts0 == 0 && nb02 % ts0 == 0 && nb03 % ts0 == 0);
508
+ GGML_ASSERT(nb0 % tdst == 0 && nb1 % tdst == 0 && nb2 % tdst == 0 && nb3 % tdst == 0);
509
+ const int64_t ss0 = nb00 / ts0;
510
+ const int64_t ss1 = nb01 / ts0;
511
+ const int64_t ss2 = nb02 / ts0;
512
+ const int64_t ss3 = nb03 / ts0;
513
+ const int64_t ds0 = nb0 / tdst;
514
+ const int64_t ds1 = nb1 / tdst;
515
+ const int64_t ds2 = nb2 / tdst;
516
+ const int64_t ds3 = nb3 / tdst;
517
+ rms_norm_f32_sycl(src0_dd, dst_dd, ne00, ne01, ne02, ne03,
518
+ ss0, ss1, ss2, ss3, ds0, ds1, ds2, ds3, eps, main_stream, ctx.device);
473
519
  }
474
520
 
475
521
  void ggml_sycl_op_rms_norm_back(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
@@ -644,13 +690,21 @@ void ggml_sycl_op_l2_norm(ggml_backend_sycl_context& ctx, ggml_tensor* dst) {
644
690
  GGML_ASSERT(eps >= 0.0f);
645
691
 
646
692
  const size_t ts0 = ggml_type_size(src0->type);
647
- GGML_ASSERT(nb00 == ts0);
648
- const int64_t s01 = nb01 / ts0;
649
- const int64_t s02 = nb02 / ts0;
650
- const int64_t s03 = nb03 / ts0;
693
+ const size_t tdst = ggml_type_size(dst->type);
694
+ GGML_ASSERT(nb00 % ts0 == 0 && nb01 % ts0 == 0 && nb02 % ts0 == 0 && nb03 % ts0 == 0);
695
+ GGML_ASSERT(nb0 % tdst == 0 && nb1 % tdst == 0 && nb2 % tdst == 0 && nb3 % tdst == 0);
696
+ const int64_t ss0 = nb00 / ts0;
697
+ const int64_t ss1 = nb01 / ts0;
698
+ const int64_t ss2 = nb02 / ts0;
699
+ const int64_t ss3 = nb03 / ts0;
700
+ const int64_t ds0 = nb0 / tdst;
701
+ const int64_t ds1 = nb1 / tdst;
702
+ const int64_t ds2 = nb2 / tdst;
703
+ const int64_t ds3 = nb3 / tdst;
651
704
 
652
705
  /*support both WARP_SIZE or WARP_32_SIZE in code
653
706
  choose by hardware for better performance
654
707
  */
655
- l2_norm_f32_sycl<WARP_SIZE>(src0_d, dst_d, ne00, ne01, ne02, ne03, s01, s02, s03, eps, stream, ctx.device);
708
+ l2_norm_f32_sycl<WARP_SIZE>(src0_d, dst_d, ne00, ne01, ne02, ne03,
709
+ ss0, ss1, ss2, ss3, ds0, ds1, ds2, ds3, eps, stream, ctx.device);
656
710
  }
@@ -1,11 +1,12 @@
1
1
  #include "outprod.hpp"
2
+ #include "convert.hpp"
2
3
 
3
4
  void ggml_sycl_op_out_prod(ggml_backend_sycl_context& ctx, ggml_tensor* dst) {
4
5
  scope_op_debug_print scope_dbg_print(__func__, dst, /*num_src=*/2);
5
6
  const ggml_tensor *src0 = dst->src[0];
6
7
  const ggml_tensor *src1 = dst->src[1];
7
8
 
8
- GGML_ASSERT(src0->type == GGML_TYPE_F32);
9
+ GGML_ASSERT(src0->type == GGML_TYPE_F32 || src0->type == GGML_TYPE_Q1_0);
9
10
  GGML_ASSERT(src1->type == GGML_TYPE_F32);
10
11
  GGML_ASSERT(dst->type == GGML_TYPE_F32);
11
12
  GGML_ASSERT(ggml_is_contiguous(src0));
@@ -20,11 +21,31 @@ void ggml_sycl_op_out_prod(ggml_backend_sycl_context& ctx, ggml_tensor* dst) {
20
21
  GGML_ASSERT(ne01 == ne11); // Inner dimensions must match
21
22
  GGML_ASSERT(ne0 == ne00); // Output rows match src0 rows
22
23
  GGML_ASSERT(ne1 == ne10); // Output cols match src1 cols
24
+ GGML_ASSERT(ne2 == ne12);
25
+ GGML_ASSERT(ne3 == ne13);
26
+ GGML_ASSERT(ne2 % ne02 == 0);
27
+ GGML_ASSERT(ne3 % ne03 == 0);
23
28
 
24
29
  // Get data pointers
25
- const float* src0_d = (const float*)src0->data;
26
- const float* src1_d = (const float*)src1->data;
27
- float* dst_d = (float*)dst->data;
30
+ const float * src0_d = (const float *) src0->data;
31
+ const float * src1_d = (const float *) src1->data;
32
+ float * dst_d = (float *) dst->data;
33
+
34
+ ggml_sycl_pool_alloc<float> src0_as_f32(ctx.pool());
35
+ int64_t src0_nb02 = nb02;
36
+ int64_t src0_nb03 = nb03;
37
+ if (src0->type == GGML_TYPE_Q1_0) {
38
+ scope_op_debug_print scope_dbg_print(__func__, "/to_fp32_sycl", dst, /*num_src=*/2,
39
+ " : converting src0 Q1_0 to fp32");
40
+ src0_d = src0_as_f32.alloc(ne00 * ne01 * ne02 * ne03);
41
+ const to_fp32_sycl_t to_fp32_sycl = ggml_get_to_fp32_sycl(src0->type, dst);
42
+ GGML_ASSERT(to_fp32_sycl != nullptr);
43
+ to_fp32_sycl(src0->data, const_cast<float *>(src0_d), ne00 * ne01 * ne02 * ne03, stream);
44
+
45
+ // Dequantized src0 buffer is contiguous fp32 [ne00, ne01, ne02, ne03].
46
+ src0_nb02 = ne00 * ne01 * (int64_t) sizeof(float);
47
+ src0_nb03 = ne00 * ne01 * ne02 * (int64_t) sizeof(float);
48
+ }
28
49
 
29
50
  // GEMM parameters
30
51
  const float alpha = 1.0f;
@@ -35,12 +56,27 @@ void ggml_sycl_op_out_prod(ggml_backend_sycl_context& ctx, ggml_tensor* dst) {
35
56
  const oneapi::mkl::transpose src1_op = src1_T ? oneapi::mkl::transpose::nontrans : oneapi::mkl::transpose::trans;
36
57
  const int64_t ldb = (src1_T ? nb10 : nb11) / sizeof(float);
37
58
 
59
+ const int64_t r2 = ne2 / ne02;
60
+ const int64_t r3 = ne3 / ne03;
61
+
38
62
  try {
39
- // Perform matrix multiplication using oneMKL GEMM
40
- oneapi::mkl::blas::column_major::gemm(*stream, oneapi::mkl::transpose::nontrans, src1_op,
41
- ne0, ne1, ne01, alpha, src0_d, ne00, src1_d, ldb, beta, dst_d, ne0);
42
- }
43
- catch (sycl::exception const& exc) {
63
+ // OUT_PROD applies independently to each (i2, i3) destination plane.
64
+ for (int64_t i3 = 0; i3 < ne3; ++i3) {
65
+ for (int64_t i2 = 0; i2 < ne2; ++i2) {
66
+ const int64_t i03 = i3 / r3;
67
+ const int64_t i02 = i2 / r2;
68
+
69
+ const float * src0_plane = (const float *) ((const char *) src0_d + i02 * src0_nb02 + i03 * src0_nb03);
70
+ const float * src1_plane = (const float *) ((const char *) src1_d + i2 * nb12 + i3 * nb13);
71
+ float * dst_plane = (float *) ((char *) dst_d + i2 * nb2 + i3 * nb3);
72
+
73
+ // Perform matrix multiplication using oneMKL GEMM
74
+ oneapi::mkl::blas::column_major::gemm(*stream, oneapi::mkl::transpose::nontrans, src1_op,
75
+ ne0, ne1, ne01, alpha, src0_plane, ne00,
76
+ src1_plane, ldb, beta, dst_plane, ne0);
77
+ }
78
+ }
79
+ } catch (sycl::exception const& exc) {
44
80
  std::cerr << exc.what() << std::endl;
45
81
  GGML_ASSERT(false);
46
82
  }
@@ -0,0 +1,185 @@
1
+ //
2
+ // MIT license
3
+ // Copyright (C) 2026 Intel Corporation
4
+ // SPDX-License-Identifier: MIT
5
+ //
6
+
7
+ //
8
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9
+ // See https://llvm.org/LICENSE.txt for license information.
10
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11
+ //
12
+
13
+ #include "pool.hpp"
14
+ #include <float.h>
15
+
16
+ template <typename Ti, typename To>
17
+ static void pool2d_nchw_kernel(
18
+ const int ih, const int iw, const int oh, const int ow,
19
+ const int kh, const int kw, const int sh, const int sw,
20
+ const int ph, const int pw, const int parallel_elements,
21
+ const Ti* src, To* dst, const enum ggml_op_pool op,
22
+ const sycl::nd_item<3> &item_ct1) {
23
+ int idx = item_ct1.get_local_id(2) +
24
+ item_ct1.get_group(2) * item_ct1.get_local_range(2);
25
+ if (idx >= parallel_elements) {
26
+ return;
27
+ }
28
+
29
+ const int I_HW = ih * iw;
30
+ const int O_HW = oh * ow;
31
+ const int nc = idx / O_HW;
32
+ const int cur_oh = idx % O_HW / ow;
33
+ const int cur_ow = idx % O_HW % ow;
34
+ const Ti* i_ptr = src + nc * I_HW;
35
+ To* o_ptr = dst + nc * O_HW;
36
+ const int start_h = cur_oh * sh - ph;
37
+ const int bh = sycl::max(0, start_h);
38
+ const int eh = sycl::min(ih, start_h + kh);
39
+ const int start_w = cur_ow * sw - pw;
40
+ const int bw = sycl::max(0, start_w);
41
+ const int ew = sycl::min(iw, start_w + kw);
42
+
43
+ To res = 0;
44
+
45
+ switch (op) {
46
+ case GGML_OP_POOL_AVG: res = 0; break;
47
+ case GGML_OP_POOL_MAX: res = -FLT_MAX; break;
48
+ default:
49
+ res = (To) sycl::nan(uint32_t(0));
50
+ break;
51
+ }
52
+
53
+ for (int i = bh; i < eh; i += 1) {
54
+ for (int j = bw; j < ew; j += 1) {
55
+ Ti cur = i_ptr[i * iw + j];
56
+ switch (op) {
57
+ case GGML_OP_POOL_AVG: res += (cur / (kh * kw)); break;
58
+ case GGML_OP_POOL_MAX: res = sycl::max(res, (To)cur); break;
59
+ default:
60
+ res = (To) sycl::nan(uint32_t(0));
61
+ break;
62
+ }
63
+ }
64
+ }
65
+ o_ptr[cur_oh * ow + cur_ow] = res;
66
+ }
67
+
68
+ template <typename Ti, typename To>
69
+ static void pool1d_ncw_kernel(
70
+ const int iw, const int ow,
71
+ const int k, const int s,
72
+ const int p, const int parallel_elements,
73
+ const Ti * src, To * dst, const enum ggml_op_pool op,
74
+ const sycl::nd_item<3> & item_ct1) {
75
+ int idx = item_ct1.get_local_id(2) +
76
+ item_ct1.get_group(2) * item_ct1.get_local_range(2);
77
+ if (idx >= parallel_elements) {
78
+ return;
79
+ }
80
+
81
+ const int nc = idx / ow;
82
+ const int cur_ow = idx % ow;
83
+ const Ti * i_ptr = src + nc * iw;
84
+ To * o_ptr = dst + nc * ow;
85
+ const int start = cur_ow * s - p;
86
+ const int b = sycl::max(0, start);
87
+ const int e = sycl::min(iw, start + k);
88
+
89
+ To res = 0;
90
+ switch (op) {
91
+ case GGML_OP_POOL_AVG: res = 0; break;
92
+ case GGML_OP_POOL_MAX: res = -FLT_MAX; break;
93
+ default:
94
+ res = (To) sycl::nan(uint32_t(0));
95
+ break;
96
+ }
97
+
98
+ for (int j = b; j < e; j += 1) {
99
+ Ti cur = i_ptr[j];
100
+ switch (op) {
101
+ case GGML_OP_POOL_AVG: res += cur; break;
102
+ case GGML_OP_POOL_MAX: res = sycl::max(res, (To) cur); break;
103
+ default:
104
+ res = (To) sycl::nan(uint32_t(0));
105
+ break;
106
+ }
107
+ }
108
+
109
+ const int count = e - b;
110
+ if (op == GGML_OP_POOL_AVG) {
111
+ res = (count > 0) ? (res / count) : (To) 0;
112
+ }
113
+ o_ptr[cur_ow] = res;
114
+ }
115
+
116
+ void ggml_sycl_op_pool2d(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
117
+ GGML_ASSERT(dst->src[0]->type == GGML_TYPE_F32);
118
+ GGML_ASSERT( dst->type == GGML_TYPE_F32);
119
+ dpct::queue_ptr main_stream = ctx.stream();
120
+ SYCL_CHECK(ggml_sycl_set_device(ctx.device));
121
+ const float * src0_dd = static_cast<const float *>(dst->src[0]->data);
122
+ float * dst_dd = static_cast<float *>(dst->data);
123
+
124
+ const int32_t * opts = (const int32_t *)dst->op_params;
125
+ enum ggml_op_pool op = static_cast<ggml_op_pool>(opts[0]);
126
+ const int k0 = opts[1];
127
+ const int k1 = opts[2];
128
+ const int s0 = opts[3];
129
+ const int s1 = opts[4];
130
+ const int p0 = opts[5];
131
+ const int p1 = opts[6];
132
+
133
+ const int64_t IH = dst->src[0]->ne[1];
134
+ const int64_t IW = dst->src[0]->ne[0];
135
+
136
+ const int64_t N = dst->ne[3];
137
+ const int64_t OC = dst->ne[2];
138
+ const int64_t OH = dst->ne[1];
139
+ const int64_t OW = dst->ne[0];
140
+
141
+ const int parallel_elements = N * OC * OH * OW;
142
+ const int num_blocks = (parallel_elements + SYCL_POOL2D_BLOCK_SIZE - 1) / SYCL_POOL2D_BLOCK_SIZE;
143
+ sycl::range<3> block_nums(1, 1, num_blocks);
144
+ main_stream->parallel_for(
145
+ sycl::nd_range<3>(block_nums *
146
+ sycl::range<3>(1, 1, SYCL_IM2COL_BLOCK_SIZE),
147
+ sycl::range<3>(1, 1, SYCL_IM2COL_BLOCK_SIZE)),
148
+ [=](sycl::nd_item<3> item_ct1) {
149
+ pool2d_nchw_kernel(IH, IW, OH, OW, k1, k0, s1, s0, p1, p0,
150
+ parallel_elements, src0_dd, dst_dd, op,
151
+ item_ct1);
152
+ });
153
+ }
154
+
155
+ void ggml_sycl_op_pool1d(ggml_backend_sycl_context & ctx, ggml_tensor * dst) {
156
+ GGML_ASSERT(dst->src[0]->type == GGML_TYPE_F32);
157
+ GGML_ASSERT( dst->type == GGML_TYPE_F32);
158
+ dpct::queue_ptr main_stream = ctx.stream();
159
+ SYCL_CHECK(ggml_sycl_set_device(ctx.device));
160
+ const float * src0_dd = static_cast<const float *>(dst->src[0]->data);
161
+ float * dst_dd = static_cast<float *>(dst->data);
162
+
163
+ const int32_t * opts = (const int32_t *)dst->op_params;
164
+ enum ggml_op_pool op = static_cast<ggml_op_pool>(opts[0]);
165
+ const int k0 = opts[1];
166
+ const int s0 = opts[2];
167
+ const int p0 = opts[3];
168
+
169
+ const int64_t IW = dst->src[0]->ne[0];
170
+ const int64_t OW = dst->ne[0];
171
+ const int64_t NC = dst->ne[3] * dst->ne[2] * dst->ne[1];
172
+
173
+ const int parallel_elements = NC * OW;
174
+ const int num_blocks = (parallel_elements + SYCL_POOL1D_BLOCK_SIZE - 1) / SYCL_POOL1D_BLOCK_SIZE;
175
+ sycl::range<3> block_nums(1, 1, num_blocks);
176
+ main_stream->parallel_for(
177
+ sycl::nd_range<3>(block_nums *
178
+ sycl::range<3>(1, 1, SYCL_POOL1D_BLOCK_SIZE),
179
+ sycl::range<3>(1, 1, SYCL_POOL1D_BLOCK_SIZE)),
180
+ [=](sycl::nd_item<3> item_ct1) {
181
+ pool1d_ncw_kernel(IW, OW, k0, s0, p0,
182
+ parallel_elements, src0_dd, dst_dd, op,
183
+ item_ct1);
184
+ });
185
+ }
@@ -0,0 +1,22 @@
1
+ //
2
+ // MIT license
3
+ // Copyright (C) 2026 Intel Corporation
4
+ // SPDX-License-Identifier: MIT
5
+ //
6
+
7
+ //
8
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9
+ // See https://llvm.org/LICENSE.txt for license information.
10
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11
+ //
12
+
13
+ #ifndef GGML_SYCL_POOL_HPP
14
+ #define GGML_SYCL_POOL_HPP
15
+
16
+ #include "common.hpp"
17
+ #include "presets.hpp"
18
+
19
+ void ggml_sycl_op_pool2d(ggml_backend_sycl_context & ctx, ggml_tensor * dst);
20
+ void ggml_sycl_op_pool1d(ggml_backend_sycl_context & ctx, ggml_tensor * dst);
21
+
22
+ #endif // GGML_SYCL_POOL_HPP
@@ -19,6 +19,7 @@
19
19
  #define WARP_SIZE GGML_SYCL_WARP_SIZE
20
20
  #define MATRIX_ROW_PADDING 512 // last row of quant. matrices is a multiple of this to avoid out-of-bounds memory accesses
21
21
 
22
+ #define SYCL_COL2IM_1D_BLOCK_SIZE 256
22
23
  #define SYCL_GELU_BLOCK_SIZE 256
23
24
  #define SYCL_SILU_BLOCK_SIZE 256
24
25
  #define SYCL_TANH_BLOCK_SIZE 256
@@ -46,6 +47,7 @@
46
47
  #define SYCL_PAD_BLOCK_SIZE 256
47
48
  #define SYCL_ACC_BLOCK_SIZE 256
48
49
  #define SYCL_IM2COL_BLOCK_SIZE 256
50
+ #define SYCL_POOL1D_BLOCK_SIZE 256
49
51
  #define SYCL_POOL2D_BLOCK_SIZE 256
50
52
  #define SYCL_ARGMAX_BLOCK_SIZE 256
51
53
  #define SYCL_CONV_TRANPOSE_1D_BLOCK_SIZE 256
@@ -61,7 +63,7 @@
61
63
  #endif
62
64
 
63
65
  #ifndef K_QUANTS_PER_ITERATION
64
- #define K_QUANTS_PER_ITERATION 2
66
+ #define K_QUANTS_PER_ITERATION 1
65
67
  #else
66
68
  static_assert(K_QUANTS_PER_ITERATION == 1 || K_QUANTS_PER_ITERATION == 2, "K_QUANTS_PER_ITERATION must be 1 or 2");
67
69
  #endif
@@ -135,7 +135,7 @@ static void set_rows_sycl(
135
135
 
136
136
  stream->parallel_for(
137
137
  sycl::nd_range<1>(grid_size * block_size, block_size),
138
- [=](sycl::nd_item<1> item_ct1) {
138
+ [=](sycl::nd_item<1> item_ct1) [[intel::reqd_sub_group_size(WARP_SIZE)]] {
139
139
  k_set_rows<TIn, TIdx, TOut>(
140
140
  src0_d, src1_d, dst_d,
141
141
  ne00, ne01, ne02,
@@ -202,6 +202,9 @@ static void set_rows_sycl(ggml_backend_sycl_context & ctx, const ggml_tensor * s
202
202
  case GGML_TYPE_Q8_0:
203
203
  set_rows_sycl_q<TIdx, block_q8_0, QK8_0, cpy_blck_f32_q8_0>(src0_d, src1_d, (block_q8_0 *)dst->data, ne00, ne01, ne02, ne03, ne10, ne11, ne12, ne13, nb00, nb01, nb02, nb03, nb10, nb11, nb12, nb13, nb1, nb2, nb3, stream);
204
204
  break;
205
+ case GGML_TYPE_Q1_0:
206
+ set_rows_sycl_q<TIdx, block_q1_0, QK1_0, cpy_blck_f32_q1_0>(src0_d, src1_d, (block_q1_0 *)dst->data, ne00, ne01, ne02, ne03, ne10, ne11, ne12, ne13, nb00, nb01, nb02, nb03, nb10, nb11, nb12, nb13, nb1, nb2, nb3, stream);
207
+ break;
205
208
  case GGML_TYPE_Q5_1:
206
209
  set_rows_sycl_q<TIdx, block_q5_1, QK5_1, cpy_blck_f32_q5_1>(src0_d, src1_d, (block_q5_1 *)dst->data, ne00, ne01, ne02, ne03, ne10, ne11, ne12, ne13, nb00, nb01, nb02, nb03, nb10, nb11, nb12, nb13, nb1, nb2, nb3, stream);
207
210
  break;
@@ -217,7 +220,12 @@ static void set_rows_sycl(ggml_backend_sycl_context & ctx, const ggml_tensor * s
217
220
  case GGML_TYPE_IQ4_NL:
218
221
  set_rows_sycl_q<TIdx, block_iq4_nl, QK4_NL, cpy_blck_f32_iq4_nl>(src0_d, src1_d, (block_iq4_nl *)dst->data, ne00, ne01, ne02, ne03, ne10, ne11, ne12, ne13, nb00, nb01, nb02, nb03, nb10, nb11, nb12, nb13, nb1, nb2, nb3, stream);
219
222
  break;
220
-
223
+ case GGML_TYPE_MXFP4:
224
+ set_rows_sycl_q<TIdx, block_mxfp4, QK_MXFP4, cpy_blck_f32_mxfp4>(src0_d, src1_d, (block_mxfp4 *)dst->data, ne00, ne01, ne02, ne03, ne10, ne11, ne12, ne13, nb00, nb01, nb02, nb03, nb10, nb11, nb12, nb13, nb1, nb2, nb3, stream);
225
+ break;
226
+ case GGML_TYPE_NVFP4:
227
+ set_rows_sycl_q<TIdx, block_nvfp4, QK_NVFP4, cpy_blck_f32_nvfp4>(src0_d, src1_d, (block_nvfp4 *)dst->data, ne00, ne01, ne02, ne03, ne10, ne11, ne12, ne13, nb00, nb01, nb02, nb03, nb10, nb11, nb12, nb13, nb1, nb2, nb3, stream);
228
+ break;
221
229
  default:
222
230
  GGML_ABORT("Unsupported tensor type!");
223
231
  break;