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.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/ext/options.rb +1 -1
- data/ext/ruby_whisper.c +0 -1
- data/ext/ruby_whisper.h +7 -1
- data/ext/ruby_whisper_context.c +50 -1
- data/ext/ruby_whisper_log_settable.h +1 -2
- data/ext/ruby_whisper_params.c +9 -8
- data/ext/ruby_whisper_transcribe.cpp +0 -19
- data/ext/ruby_whisper_vad_context.c +30 -10
- data/ext/ruby_whisper_vad_context_detect.cpp +8 -9
- data/ext/ruby_whisper_vad_params.c +4 -4
- data/ext/ruby_whisper_vad_segment.c +2 -2
- data/ext/sources/CMakeLists.txt +2 -1
- data/ext/sources/cmake/parakeet.pc.in +2 -2
- data/ext/sources/cmake/whisper.pc.in +2 -2
- data/ext/sources/examples/cli/cli.cpp +9 -1
- data/ext/sources/examples/common-ggml.cpp +2 -0
- data/ext/sources/examples/vad-speech-segments/speech.cpp +3 -2
- data/ext/sources/ggml/CMakeLists.txt +3 -4
- data/ext/sources/ggml/include/ggml-cuda.h +0 -3
- data/ext/sources/ggml/include/ggml-sycl.h +8 -0
- data/ext/sources/ggml/include/ggml.h +3 -1
- data/ext/sources/ggml/src/CMakeLists.txt +8 -1
- data/ext/sources/ggml/src/ggml-backend-meta.cpp +7 -4
- data/ext/sources/ggml/src/ggml-common.h +13 -2
- data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +1 -1
- data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +5 -6
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +78 -4
- data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +142 -4
- data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +7 -2
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +14 -0
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +26 -19
- data/ext/sources/ggml/src/ggml-cpu/ops.cpp +129 -46
- data/ext/sources/ggml/src/ggml-cpu/quants.c +51 -0
- data/ext/sources/ggml/src/ggml-cpu/quants.h +3 -0
- data/ext/sources/ggml/src/ggml-cpu/simd-gemm.h +1 -1
- data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +11 -0
- data/ext/sources/ggml/src/ggml-cpu/vec.cpp +2 -2
- data/ext/sources/ggml/src/ggml-cuda/binbcast.cu +90 -46
- data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
- data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/common.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/concat.cu +33 -21
- data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cu +14 -12
- data/ext/sources/ggml/src/ggml-cuda/convert.cu +86 -34
- data/ext/sources/ggml/src/ggml-cuda/cpy.cu +80 -29
- data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +9 -5
- data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile.cuh +9 -5
- data/ext/sources/ggml/src/ggml-cuda/fattn.cu +27 -21
- data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cu +40 -25
- data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cuh +10 -0
- data/ext/sources/ggml/src/ggml-cuda/getrows.cu +15 -12
- data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +718 -1248
- data/ext/sources/ggml/src/ggml-cuda/mmq.cu +7 -0
- data/ext/sources/ggml/src/ggml-cuda/mmvq.cu +77 -40
- data/ext/sources/ggml/src/ggml-cuda/out-prod.cu +55 -12
- data/ext/sources/ggml/src/ggml-cuda/set-rows.cu +64 -4
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/topk-moe.cu +7 -1
- data/ext/sources/ggml/src/ggml-cuda/vendors/hip.h +1 -0
- data/ext/sources/ggml/src/ggml-cuda/vendors/musa.h +1 -0
- data/ext/sources/ggml/src/ggml-hexagon/CMakeLists.txt +0 -5
- data/ext/sources/ggml/src/ggml-hexagon/ggml-hexagon.cpp +1634 -1293
- data/ext/sources/ggml/src/ggml-hexagon/htp/CMakeLists.txt +11 -40
- data/ext/sources/ggml/src/ggml-hexagon/htp/cmake-toolchain.cmake +13 -15
- data/ext/sources/ggml/src/ggml-hexagon/htp/concat-ops.c +1 -1
- data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.c +1749 -399
- data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.h +303 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-common.h +80 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-dma.h +26 -23
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-profile.h +64 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-utils.h +1 -83
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-fa-kernels.h +555 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-mm-kernels-tiled.h +1303 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.c +9 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.h +27 -4
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-utils.h +59 -37
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ctx.h +11 -3
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ops.h +52 -12
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-vtcm.h +19 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp_iface.idl +2 -1
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-base.h +14 -30
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-exp.h +39 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-fa-kernels.h +232 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-flat.h +1511 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-tiled.h +1200 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-sigmoid.h +39 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/main.c +127 -32
- data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.c +3023 -4425
- data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.h +650 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/rope-ops.c +48 -13
- data/ext/sources/ggml/src/ggml-hexagon/htp/ssm-conv.c +10 -9
- data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.c +15 -3
- data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.h +8 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp-opnode.h +168 -50
- data/ext/sources/ggml/src/ggml-hexagon/libggml-htp.inf +0 -4
- data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +5 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.cpp +69 -5
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.h +4 -1
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.m +27 -6
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +38 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.cpp +132 -2
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.h +2 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +345 -87
- data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +13 -0
- data/ext/sources/ggml/src/ggml-opencl/fa_tune.h +92 -0
- data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +4060 -357
- data/ext/sources/ggml/src/ggml-opencl/kernels/cvt.cl +198 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +81 -41
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +88 -39
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +1995 -96
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q4_0.cl +1615 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q8_0.cl +1486 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_pre_f16.cl +156 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl +71 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q1_0_f32.cl +94 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q1_0_f32.cl +121 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q8_0_f32.cl +1 -1
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mm_q1_0_f32_l4_lm.cl +156 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +1149 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32.cl +141 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32_flat.cl +190 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/norm.cl +5 -2
- data/ext/sources/ggml/src/ggml-opencl/kernels/set_rows.cl +500 -0
- data/ext/sources/ggml/src/ggml-opencl/libdl.h +79 -0
- data/ext/sources/ggml/src/ggml-openvino/.clang-format +0 -5
- data/ext/sources/ggml/src/ggml-openvino/CMakeLists.txt +2 -4
- data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.cpp +733 -130
- data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.h +76 -23
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.cpp +57 -3
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.h +29 -8
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino.cpp +307 -59
- data/ext/sources/ggml/src/ggml-openvino/ggml-quants.cpp +66 -0
- data/ext/sources/ggml/src/ggml-openvino/ggml-quants.h +10 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/decoder.h +56 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/frontend.h +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/input_model.h +4 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/node_context.h +94 -37
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/add_id.cpp +76 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/argsort.cpp +47 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/clamp.cpp +33 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/concat.cpp +48 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/cont.cpp +8 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/cpy.cpp +14 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/div.cpp +146 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/flash_attn_ext.cpp +108 -21
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.cpp +282 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.hpp +65 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/get_rows.cpp +2 -9
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_geglu.cpp +21 -7
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_swiglu.cpp +41 -8
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/im2col.cpp +120 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/l2_norm.cpp +44 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/mul_mat_id.cpp +226 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/mulmat.cpp +19 -9
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/norm.cpp +58 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/pad.cpp +95 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/permute.cpp +58 -13
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/repeat.cpp +74 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/reshape.cpp +13 -6
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/rms_norm.cpp +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/rope.cpp +134 -38
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/set_rows.cpp +3 -3
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/softmax.cpp +126 -49
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/ssm_conv.cpp +59 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/sum_rows.cpp +27 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/transpose.cpp +32 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_silu.cpp +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_softplus.cpp +38 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/view.cpp +90 -25
- data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.cpp +41 -23
- data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.h +18 -5
- data/ext/sources/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.cpp +43 -40
- data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.h +5 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/utils.cpp +548 -3
- data/ext/sources/ggml/src/ggml-openvino/openvino/utils.h +28 -26
- data/ext/sources/ggml/src/ggml-openvino/utils.cpp +383 -94
- data/ext/sources/ggml/src/ggml-openvino/utils.h +11 -8
- data/ext/sources/ggml/src/ggml-quants.c +76 -0
- data/ext/sources/ggml/src/ggml-quants.h +3 -0
- data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +5 -5
- data/ext/sources/ggml/src/ggml-sycl/backend.hpp +2 -0
- data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +12 -0
- data/ext/sources/ggml/src/ggml-sycl/col2im-1d.cpp +102 -0
- data/ext/sources/ggml/src/ggml-sycl/col2im-1d.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/common.cpp +6 -8
- data/ext/sources/ggml/src/ggml-sycl/common.hpp +19 -2
- data/ext/sources/ggml/src/ggml-sycl/concat.cpp +21 -1
- data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.cpp +158 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.cpp +125 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d.cpp +150 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv3d.cpp +224 -0
- data/ext/sources/ggml/src/ggml-sycl/conv3d.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/convert.cpp +6 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +706 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.hpp +281 -0
- data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.cpp +255 -0
- data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.hpp +7 -0
- data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +15 -0
- data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +492 -319
- data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +15 -7
- data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +215 -115
- data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +2 -0
- data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +1006 -336
- data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +252 -67
- data/ext/sources/ggml/src/ggml-sycl/mmvq.hpp +17 -0
- data/ext/sources/ggml/src/ggml-sycl/norm.cpp +103 -49
- data/ext/sources/ggml/src/ggml-sycl/outprod.cpp +45 -9
- data/ext/sources/ggml/src/ggml-sycl/pool.cpp +185 -0
- data/ext/sources/ggml/src/ggml-sycl/pool.hpp +22 -0
- data/ext/sources/ggml/src/ggml-sycl/presets.hpp +3 -1
- data/ext/sources/ggml/src/ggml-sycl/set_rows.cpp +10 -2
- data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +9 -10
- data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +35 -0
- data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +5 -0
- data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +833 -215
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/col2im_1d.comp +61 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +1 -1
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv3d_mm.comp +431 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/diag.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +1 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +1 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl +21 -19
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_back.comp +25 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl +23 -4
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl +14 -18
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +4 -7
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq.comp +21 -24
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +31 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +6 -5
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_funcs.glsl +84 -67
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +10 -10
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tri.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/unary.comp +168 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +121 -74
- data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp +26 -19
- data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu.cpp +31 -36
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/common_decls.tmpl +16 -2
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl +7 -7
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/get_rows.wgsl +21 -0
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_decls.tmpl +439 -320
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_vec.wgsl +2 -2
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec.wgsl +45 -39
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_acc.tmpl +586 -465
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_q_acc.tmpl +63 -69
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/quantize_q8.wgsl +14 -9
- data/ext/sources/ggml/src/ggml.c +36 -14
- data/ext/sources/include/whisper.h +21 -0
- data/ext/sources/src/whisper.cpp +164 -14
- data/lib/whisper/log_settable.rb +5 -8
- data/lib/whisper/model/uri.rb +0 -7
- data/sig/whisper.rbs +6 -0
- data/test/test_vad.rb +9 -0
- data/test/test_vad_context.rb +2 -2
- data/whispercpp.gemspec +1 -1
- metadata +62 -37
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c +0 -1878
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-matmul-ops.c +0 -2066
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.c +0 -6
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.h +0 -88
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-profile.h +0 -34
- data/ext/sources/ggml/src/ggml-hexagon/htp/vtcm-utils.h +0 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_gelu.cpp +0 -25
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/abs.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/ceil.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/elu.comp +0 -27
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/exp.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/floor.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +0 -25
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp +0 -39
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +0 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardsigmoid.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardswish.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/neg.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/round.comp +0 -29
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sgn.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/softplus.comp +0 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sqrt.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/step.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/trunc.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/xielu.comp +0 -35
|
@@ -42,6 +42,8 @@ typedef matrix<bfloat, 4, 4> bfloat4x4;
|
|
|
42
42
|
typedef matrix<bfloat, 2, 4> bfloat2x4;
|
|
43
43
|
#endif
|
|
44
44
|
|
|
45
|
+
#define QK_NL 16
|
|
46
|
+
|
|
45
47
|
constexpr constant static float kvalues_iq4nl_f[16] = {
|
|
46
48
|
-127.f, -104.f, -83.f, -65.f, -49.f, -35.f, -22.f, -10.f, 1.f, 13.f, 25.f, 38.f, 53.f, 69.f, 89.f, 113.f
|
|
47
49
|
};
|
|
@@ -1418,6 +1420,9 @@ typedef decltype(kernel_repeat<float>) kernel_repeat_t;
|
|
|
1418
1420
|
|
|
1419
1421
|
template [[host_name("kernel_repeat_f32")]] kernel kernel_repeat_t kernel_repeat<float>;
|
|
1420
1422
|
template [[host_name("kernel_repeat_f16")]] kernel kernel_repeat_t kernel_repeat<half>;
|
|
1423
|
+
#if defined(GGML_METAL_HAS_BF16)
|
|
1424
|
+
template [[host_name("kernel_repeat_bf16")]] kernel kernel_repeat_t kernel_repeat<bfloat>;
|
|
1425
|
+
#endif
|
|
1421
1426
|
template [[host_name("kernel_repeat_i32")]] kernel kernel_repeat_t kernel_repeat<int>;
|
|
1422
1427
|
template [[host_name("kernel_repeat_i16")]] kernel kernel_repeat_t kernel_repeat<short>;
|
|
1423
1428
|
|
|
@@ -4355,6 +4360,7 @@ template [[host_name("kernel_mul_mv_bf16_bf16_short")]] kernel mul_mv_t_t_short_
|
|
|
4355
4360
|
#endif
|
|
4356
4361
|
|
|
4357
4362
|
constant bool FC_rope_is_imrope [[function_constant(FC_ROPE + 0)]];
|
|
4363
|
+
constant bool FC_rope_is_back [[function_constant(FC_ROPE + 1)]];
|
|
4358
4364
|
|
|
4359
4365
|
static float rope_yarn_ramp(const float low, const float high, const int i0) {
|
|
4360
4366
|
const float y = (i0 / 2 - low) / max(0.001f, high - low);
|
|
@@ -4378,6 +4384,9 @@ static void rope_yarn(
|
|
|
4378
4384
|
}
|
|
4379
4385
|
*cos_theta = cos(theta) * mscale;
|
|
4380
4386
|
*sin_theta = sin(theta) * mscale;
|
|
4387
|
+
if (FC_rope_is_back) {
|
|
4388
|
+
*sin_theta *= -1.0f;
|
|
4389
|
+
}
|
|
4381
4390
|
}
|
|
4382
4391
|
|
|
4383
4392
|
// Apparently solving `n_rot = 2pi * x * base^((2 * max_pos_emb) / n_dims)` for x, we get
|
|
@@ -4899,6 +4908,202 @@ kernel void kernel_conv_2d<half>(
|
|
|
4899
4908
|
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
4900
4909
|
uint3 ntg[[threads_per_threadgroup]]);
|
|
4901
4910
|
|
|
4911
|
+
// grid: x = C tile, y = OH, z = OW * N (for channel-contiguous layouts)
|
|
4912
|
+
template <typename TK>
|
|
4913
|
+
kernel void kernel_conv_2d_dw_tiled(
|
|
4914
|
+
constant ggml_metal_kargs_conv_2d_dw & args,
|
|
4915
|
+
device const char * weights,
|
|
4916
|
+
device const char * src,
|
|
4917
|
+
device char * dst,
|
|
4918
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
4919
|
+
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
4920
|
+
uint3 ntg[[threads_per_threadgroup]]) {
|
|
4921
|
+
|
|
4922
|
+
const int32_t c = (int32_t)(tgpig.x * ntg.x + tpitg.x);
|
|
4923
|
+
if (c >= args.C) {
|
|
4924
|
+
return;
|
|
4925
|
+
}
|
|
4926
|
+
|
|
4927
|
+
const int32_t oh = tgpig.y;
|
|
4928
|
+
const int32_t own = tgpig.z;
|
|
4929
|
+
const int32_t ow = own % args.OW;
|
|
4930
|
+
const int32_t n = own / args.OW;
|
|
4931
|
+
|
|
4932
|
+
const int32_t base_y = oh*args.s1 - args.p1;
|
|
4933
|
+
|
|
4934
|
+
int32_t ky_start = 0;
|
|
4935
|
+
if (base_y < 0) {
|
|
4936
|
+
ky_start = (-base_y + args.d1 - 1)/args.d1;
|
|
4937
|
+
}
|
|
4938
|
+
int32_t ky_end = args.KH;
|
|
4939
|
+
const int32_t y_max = args.IH - 1 - base_y;
|
|
4940
|
+
if (y_max < 0) {
|
|
4941
|
+
ky_end = ky_start;
|
|
4942
|
+
} else if (base_y + (args.KH - 1)*args.d1 >= args.IH) {
|
|
4943
|
+
ky_end = min(ky_end, y_max/args.d1 + 1);
|
|
4944
|
+
}
|
|
4945
|
+
|
|
4946
|
+
const int32_t base_x = ow*args.s0 - args.p0;
|
|
4947
|
+
|
|
4948
|
+
int32_t kx_start = 0;
|
|
4949
|
+
if (base_x < 0) {
|
|
4950
|
+
kx_start = (-base_x + args.d0 - 1)/args.d0;
|
|
4951
|
+
}
|
|
4952
|
+
int32_t kx_end = args.KW;
|
|
4953
|
+
const int32_t x_max = args.IW - 1 - base_x;
|
|
4954
|
+
if (x_max < 0) {
|
|
4955
|
+
kx_end = kx_start;
|
|
4956
|
+
} else if (base_x + (args.KW - 1)*args.d0 >= args.IW) {
|
|
4957
|
+
kx_end = min(kx_end, x_max/args.d0 + 1);
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4960
|
+
float acc = 0.0f;
|
|
4961
|
+
|
|
4962
|
+
if (ky_start < ky_end && kx_start < kx_end) {
|
|
4963
|
+
const uint64_t w_base = (uint64_t) c * args.nb02;
|
|
4964
|
+
const uint64_t src_base = (uint64_t) n * args.nb13 + (uint64_t) c * args.nb12;
|
|
4965
|
+
|
|
4966
|
+
for (int32_t ky = ky_start; ky < ky_end; ++ky) {
|
|
4967
|
+
const int32_t iy = base_y + ky*args.d1;
|
|
4968
|
+
const uint64_t src_row = src_base + (uint64_t) iy * args.nb11;
|
|
4969
|
+
const uint64_t w_row = w_base + (uint64_t) ky * args.nb01;
|
|
4970
|
+
|
|
4971
|
+
for (int32_t kx = kx_start; kx < kx_end; ++kx) {
|
|
4972
|
+
const int32_t ix = base_x + kx*args.d0;
|
|
4973
|
+
const float x = *(device const float *)(src + src_row + (uint64_t) ix * args.nb10);
|
|
4974
|
+
const float w = (float)(*(device const TK *)(weights + w_row + (uint64_t) kx * args.nb00));
|
|
4975
|
+
acc += x * w;
|
|
4976
|
+
}
|
|
4977
|
+
}
|
|
4978
|
+
}
|
|
4979
|
+
|
|
4980
|
+
const uint64_t dst_offs =
|
|
4981
|
+
(uint64_t) n * args.nb3 +
|
|
4982
|
+
(uint64_t) c * args.nb2 +
|
|
4983
|
+
(uint64_t) oh * args.nb1 +
|
|
4984
|
+
(uint64_t) ow * args.nb0;
|
|
4985
|
+
|
|
4986
|
+
*(device float *)(dst + dst_offs) = acc;
|
|
4987
|
+
}
|
|
4988
|
+
|
|
4989
|
+
// grid: x = OW tile, y = OH, z = C * N (for spatially-contiguous layouts)
|
|
4990
|
+
template <typename TK>
|
|
4991
|
+
kernel void kernel_conv_2d_dw(
|
|
4992
|
+
constant ggml_metal_kargs_conv_2d_dw & args,
|
|
4993
|
+
device const char * weights,
|
|
4994
|
+
device const char * src,
|
|
4995
|
+
device char * dst,
|
|
4996
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
4997
|
+
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
4998
|
+
uint3 ntg[[threads_per_threadgroup]]) {
|
|
4999
|
+
|
|
5000
|
+
const int32_t oh = tgpig.y;
|
|
5001
|
+
const int32_t cn = tgpig.z;
|
|
5002
|
+
const int32_t c = cn % args.C;
|
|
5003
|
+
const int32_t n = cn / args.C;
|
|
5004
|
+
|
|
5005
|
+
const int32_t base_y = oh*args.s1 - args.p1;
|
|
5006
|
+
|
|
5007
|
+
int32_t ky_start = 0;
|
|
5008
|
+
if (base_y < 0) {
|
|
5009
|
+
ky_start = (-base_y + args.d1 - 1)/args.d1;
|
|
5010
|
+
}
|
|
5011
|
+
int32_t ky_end = args.KH;
|
|
5012
|
+
const int32_t y_max = args.IH - 1 - base_y;
|
|
5013
|
+
if (y_max < 0) {
|
|
5014
|
+
ky_end = ky_start;
|
|
5015
|
+
} else if (base_y + (args.KH - 1)*args.d1 >= args.IH) {
|
|
5016
|
+
ky_end = min(ky_end, y_max/args.d1 + 1);
|
|
5017
|
+
}
|
|
5018
|
+
|
|
5019
|
+
const uint64_t w_base = (uint64_t) c * args.nb02;
|
|
5020
|
+
const uint64_t src_base = (uint64_t) n * args.nb13 + (uint64_t) c * args.nb12;
|
|
5021
|
+
|
|
5022
|
+
const int32_t ow = (int32_t)(tgpig.x * ntg.x + tpitg.x);
|
|
5023
|
+
if (ow >= args.OW) {
|
|
5024
|
+
return;
|
|
5025
|
+
}
|
|
5026
|
+
|
|
5027
|
+
float acc = 0.0f;
|
|
5028
|
+
|
|
5029
|
+
const int32_t base_x = ow*args.s0 - args.p0;
|
|
5030
|
+
|
|
5031
|
+
int32_t kx_start = 0;
|
|
5032
|
+
if (base_x < 0) {
|
|
5033
|
+
kx_start = (-base_x + args.d0 - 1)/args.d0;
|
|
5034
|
+
}
|
|
5035
|
+
int32_t kx_end = args.KW;
|
|
5036
|
+
const int32_t x_max = args.IW - 1 - base_x;
|
|
5037
|
+
if (x_max < 0) {
|
|
5038
|
+
kx_end = kx_start;
|
|
5039
|
+
} else if (base_x + (args.KW - 1)*args.d0 >= args.IW) {
|
|
5040
|
+
kx_end = min(kx_end, x_max/args.d0 + 1);
|
|
5041
|
+
}
|
|
5042
|
+
|
|
5043
|
+
if (ky_start < ky_end && kx_start < kx_end) {
|
|
5044
|
+
for (int32_t ky = ky_start; ky < ky_end; ++ky) {
|
|
5045
|
+
const int32_t iy = base_y + ky*args.d1;
|
|
5046
|
+
const uint64_t src_row = src_base + (uint64_t) iy * args.nb11;
|
|
5047
|
+
const uint64_t w_row = w_base + (uint64_t) ky * args.nb01;
|
|
5048
|
+
|
|
5049
|
+
for (int32_t kx = kx_start; kx < kx_end; ++kx) {
|
|
5050
|
+
const int32_t ix = base_x + kx*args.d0;
|
|
5051
|
+
const float x = *(device const float *)(src + src_row + (uint64_t) ix * args.nb10);
|
|
5052
|
+
const float w = (float)(*(device const TK *)(weights + w_row + (uint64_t) kx * args.nb00));
|
|
5053
|
+
acc += x * w;
|
|
5054
|
+
}
|
|
5055
|
+
}
|
|
5056
|
+
}
|
|
5057
|
+
|
|
5058
|
+
const uint64_t dst_offs =
|
|
5059
|
+
(uint64_t) n * args.nb3 +
|
|
5060
|
+
(uint64_t) c * args.nb2 +
|
|
5061
|
+
(uint64_t) oh * args.nb1 +
|
|
5062
|
+
(uint64_t) ow * args.nb0;
|
|
5063
|
+
|
|
5064
|
+
*(device float *)(dst + dst_offs) = acc;
|
|
5065
|
+
}
|
|
5066
|
+
|
|
5067
|
+
template [[host_name("kernel_conv_2d_dw_f32_f32")]]
|
|
5068
|
+
kernel void kernel_conv_2d_dw<float>(
|
|
5069
|
+
constant ggml_metal_kargs_conv_2d_dw & args,
|
|
5070
|
+
device const char * weights,
|
|
5071
|
+
device const char * src,
|
|
5072
|
+
device char * dst,
|
|
5073
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
5074
|
+
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
5075
|
+
uint3 ntg[[threads_per_threadgroup]]);
|
|
5076
|
+
|
|
5077
|
+
template [[host_name("kernel_conv_2d_dw_f16_f32")]]
|
|
5078
|
+
kernel void kernel_conv_2d_dw<half>(
|
|
5079
|
+
constant ggml_metal_kargs_conv_2d_dw & args,
|
|
5080
|
+
device const char * weights,
|
|
5081
|
+
device const char * src,
|
|
5082
|
+
device char * dst,
|
|
5083
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
5084
|
+
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
5085
|
+
uint3 ntg[[threads_per_threadgroup]]);
|
|
5086
|
+
|
|
5087
|
+
template [[host_name("kernel_conv_2d_dw_tiled_f32_f32")]]
|
|
5088
|
+
kernel void kernel_conv_2d_dw_tiled<float>(
|
|
5089
|
+
constant ggml_metal_kargs_conv_2d_dw & args,
|
|
5090
|
+
device const char * weights,
|
|
5091
|
+
device const char * src,
|
|
5092
|
+
device char * dst,
|
|
5093
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
5094
|
+
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
5095
|
+
uint3 ntg[[threads_per_threadgroup]]);
|
|
5096
|
+
|
|
5097
|
+
template [[host_name("kernel_conv_2d_dw_tiled_f16_f32")]]
|
|
5098
|
+
kernel void kernel_conv_2d_dw_tiled<half>(
|
|
5099
|
+
constant ggml_metal_kargs_conv_2d_dw & args,
|
|
5100
|
+
device const char * weights,
|
|
5101
|
+
device const char * src,
|
|
5102
|
+
device char * dst,
|
|
5103
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
5104
|
+
uint3 tpitg[[thread_position_in_threadgroup]],
|
|
5105
|
+
uint3 ntg[[threads_per_threadgroup]]);
|
|
5106
|
+
|
|
4902
5107
|
typedef void (conv_transpose_1d_t)(
|
|
4903
5108
|
constant ggml_metal_kargs_conv_transpose_1d & args,
|
|
4904
5109
|
device const float * src0,
|
|
@@ -4970,6 +5175,49 @@ kernel void kernel_conv_transpose_1d<half>(
|
|
|
4970
5175
|
uint3 tgpg[[threadgroups_per_grid]]);
|
|
4971
5176
|
|
|
4972
5177
|
|
|
5178
|
+
template <typename T>
|
|
5179
|
+
kernel void kernel_col2im_1d(
|
|
5180
|
+
constant ggml_metal_kargs_col2im_1d & args,
|
|
5181
|
+
device const T * col,
|
|
5182
|
+
device T * dst,
|
|
5183
|
+
uint tgpig [[threadgroup_position_in_grid]],
|
|
5184
|
+
uint tpitg [[thread_position_in_threadgroup]],
|
|
5185
|
+
uint ntg [[threads_per_threadgroup]]) {
|
|
5186
|
+
|
|
5187
|
+
const int idx = tgpig * ntg + tpitg;
|
|
5188
|
+
if (idx >= args.T_out * args.OC) {
|
|
5189
|
+
return;
|
|
5190
|
+
}
|
|
5191
|
+
|
|
5192
|
+
const int t_out = idx % args.T_out;
|
|
5193
|
+
const int oc = idx / args.T_out;
|
|
5194
|
+
const int t_abs = t_out + args.p0; // absolute position in uncropped signal
|
|
5195
|
+
|
|
5196
|
+
int t_in_min = (t_abs - args.K + args.s0) / args.s0; // ceil((t_abs - K + 1) / s0)
|
|
5197
|
+
if (t_in_min < 0) {
|
|
5198
|
+
t_in_min = 0;
|
|
5199
|
+
}
|
|
5200
|
+
int t_in_max = t_abs / args.s0;
|
|
5201
|
+
if (t_in_max >= args.T_in) {
|
|
5202
|
+
t_in_max = args.T_in - 1;
|
|
5203
|
+
}
|
|
5204
|
+
|
|
5205
|
+
float sum = 0.0f;
|
|
5206
|
+
for (int t_in = t_in_min; t_in <= t_in_max; t_in++) {
|
|
5207
|
+
const int k = t_abs - t_in * args.s0;
|
|
5208
|
+
sum += float(col[(oc * args.K + k) + t_in * args.K_OC]);
|
|
5209
|
+
}
|
|
5210
|
+
|
|
5211
|
+
dst[t_out + oc * args.T_out] = T(sum);
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5214
|
+
template [[host_name("kernel_col2im_1d_f32")]] kernel void kernel_col2im_1d<float>(constant ggml_metal_kargs_col2im_1d &, device const float *, device float *, uint, uint, uint);
|
|
5215
|
+
template [[host_name("kernel_col2im_1d_f16")]] kernel void kernel_col2im_1d<half>(constant ggml_metal_kargs_col2im_1d &, device const half *, device half *, uint, uint, uint);
|
|
5216
|
+
#if defined(GGML_METAL_HAS_BF16)
|
|
5217
|
+
template [[host_name("kernel_col2im_1d_bf16")]] kernel void kernel_col2im_1d<bfloat>(constant ggml_metal_kargs_col2im_1d &, device const bfloat *, device bfloat *, uint, uint, uint);
|
|
5218
|
+
#endif
|
|
5219
|
+
|
|
5220
|
+
|
|
4973
5221
|
typedef void (conv_transpose_2d_t)(
|
|
4974
5222
|
constant ggml_metal_kargs_conv_transpose_2d & args,
|
|
4975
5223
|
device const float * src0,
|
|
@@ -7510,14 +7758,15 @@ template [[host_name("kernel_cpy_q5_0_f16")]] kernel cpy_q_f_t kernel_cpy_q_f32<
|
|
|
7510
7758
|
template [[host_name("kernel_cpy_q5_1_f16")]] kernel cpy_q_f_t kernel_cpy_q_f32<half4x4, block_q5_1, 2, dequantize_q5_1>;
|
|
7511
7759
|
template [[host_name("kernel_cpy_q8_0_f16")]] kernel cpy_q_f_t kernel_cpy_q_f32<half4x4, block_q8_0, 2, dequantize_q8_0>;
|
|
7512
7760
|
|
|
7761
|
+
template<typename T>
|
|
7513
7762
|
kernel void kernel_concat(
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
|
|
7763
|
+
constant ggml_metal_kargs_concat & args,
|
|
7764
|
+
device const char * src0,
|
|
7765
|
+
device const char * src1,
|
|
7766
|
+
device char * dst,
|
|
7767
|
+
uint3 tgpig[[threadgroup_position_in_grid]],
|
|
7768
|
+
ushort3 tpitg[[thread_position_in_threadgroup]],
|
|
7769
|
+
ushort3 ntg[[threads_per_threadgroup]]) {
|
|
7521
7770
|
|
|
7522
7771
|
const int i3 = tgpig.z;
|
|
7523
7772
|
const int i2 = tgpig.y;
|
|
@@ -7530,21 +7779,33 @@ kernel void kernel_concat(
|
|
|
7530
7779
|
int o[4] = {0, 0, 0, 0};
|
|
7531
7780
|
o[args.dim] = args.dim == 0 ? args.ne00 : (args.dim == 1 ? args.ne01 : (args.dim == 2 ? args.ne02 : args.ne03));
|
|
7532
7781
|
|
|
7533
|
-
device const float * x;
|
|
7534
|
-
|
|
7535
7782
|
for (int i0 = tpitg.x; i0 < args.ne0; i0 += ntg.x) {
|
|
7783
|
+
device const T * x;
|
|
7784
|
+
|
|
7536
7785
|
if (i0 < args.ne00 && i1 < args.ne01 && i2 < args.ne02 && i3 < args.ne03) {
|
|
7537
|
-
x = (device const
|
|
7786
|
+
x = (device const T *)(src0 + (i3 )*args.nb03 + (i2 )*args.nb02 + (i1 )*args.nb01 + (i0 )*args.nb00);
|
|
7538
7787
|
} else {
|
|
7539
|
-
x = (device const
|
|
7788
|
+
x = (device const T *)(src1 + (i3 - o[3])*args.nb13 + (i2 - o[2])*args.nb12 + (i1 - o[1])*args.nb11 + (i0 - o[0])*args.nb10);
|
|
7540
7789
|
}
|
|
7541
7790
|
|
|
7542
|
-
device
|
|
7791
|
+
device T * y = (device T *)(dst + i3*args.nb3 + i2*args.nb2 + i1*args.nb1 + i0*args.nb0);
|
|
7543
7792
|
|
|
7544
7793
|
*y = *x;
|
|
7545
7794
|
}
|
|
7546
7795
|
}
|
|
7547
7796
|
|
|
7797
|
+
typedef decltype(kernel_concat<float>) kernel_concat_t;
|
|
7798
|
+
|
|
7799
|
+
template [[host_name("kernel_concat_f32")]] kernel kernel_concat_t kernel_concat<float>;
|
|
7800
|
+
template [[host_name("kernel_concat_f16")]] kernel kernel_concat_t kernel_concat<half>;
|
|
7801
|
+
#if defined(GGML_METAL_HAS_BF16)
|
|
7802
|
+
template [[host_name("kernel_concat_bf16")]] kernel kernel_concat_t kernel_concat<bfloat>;
|
|
7803
|
+
#endif
|
|
7804
|
+
template [[host_name("kernel_concat_i8")]] kernel kernel_concat_t kernel_concat<char>;
|
|
7805
|
+
template [[host_name("kernel_concat_i16")]] kernel kernel_concat_t kernel_concat<short>;
|
|
7806
|
+
template [[host_name("kernel_concat_i32")]] kernel kernel_concat_t kernel_concat<int>;
|
|
7807
|
+
template [[host_name("kernel_concat_i64")]] kernel kernel_concat_t kernel_concat<long>;
|
|
7808
|
+
|
|
7548
7809
|
template<int nr0, typename args_t>
|
|
7549
7810
|
void kernel_mul_mv_q2_K_f32_impl(
|
|
7550
7811
|
args_t args,
|
|
@@ -9323,7 +9584,40 @@ kernel void kernel_get_rows_f(
|
|
|
9323
9584
|
}
|
|
9324
9585
|
}
|
|
9325
9586
|
|
|
9326
|
-
|
|
9587
|
+
typedef decltype(kernel_get_rows_f<float, float>) get_rows_f_t;
|
|
9588
|
+
|
|
9589
|
+
template [[host_name("kernel_get_rows_f32")]] kernel get_rows_f_t kernel_get_rows_f<float, float>;
|
|
9590
|
+
template [[host_name("kernel_get_rows_f16")]] kernel get_rows_f_t kernel_get_rows_f<half, float>;
|
|
9591
|
+
template [[host_name("kernel_get_rows_i32")]] kernel get_rows_f_t kernel_get_rows_f<int32_t, int32_t>;
|
|
9592
|
+
#if defined(GGML_METAL_HAS_BF16)
|
|
9593
|
+
template [[host_name("kernel_get_rows_bf16")]] kernel get_rows_f_t kernel_get_rows_f<bfloat, float>;
|
|
9594
|
+
#endif
|
|
9595
|
+
|
|
9596
|
+
typedef decltype(kernel_get_rows_q<block_q4_0, 2, dequantize_q4_0>) get_rows_q_t;
|
|
9597
|
+
|
|
9598
|
+
template [[host_name("kernel_get_rows_q1_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q1_0, 8, dequantize_q1_0>;
|
|
9599
|
+
template [[host_name("kernel_get_rows_q4_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q4_0, 2, dequantize_q4_0>;
|
|
9600
|
+
template [[host_name("kernel_get_rows_q4_1")]] kernel get_rows_q_t kernel_get_rows_q<block_q4_1, 2, dequantize_q4_1>;
|
|
9601
|
+
template [[host_name("kernel_get_rows_q5_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q5_0, 2, dequantize_q5_0>;
|
|
9602
|
+
template [[host_name("kernel_get_rows_q5_1")]] kernel get_rows_q_t kernel_get_rows_q<block_q5_1, 2, dequantize_q5_1>;
|
|
9603
|
+
template [[host_name("kernel_get_rows_q8_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q8_0, 2, dequantize_q8_0>;
|
|
9604
|
+
template [[host_name("kernel_get_rows_mxfp4")]] kernel get_rows_q_t kernel_get_rows_q<block_mxfp4, 2, dequantize_mxfp4>;
|
|
9605
|
+
template [[host_name("kernel_get_rows_q2_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q2_K, QK_NL, dequantize_q2_K>;
|
|
9606
|
+
template [[host_name("kernel_get_rows_q3_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q3_K, QK_NL, dequantize_q3_K>;
|
|
9607
|
+
template [[host_name("kernel_get_rows_q4_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q4_K, QK_NL, dequantize_q4_K>;
|
|
9608
|
+
template [[host_name("kernel_get_rows_q5_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q5_K, QK_NL, dequantize_q5_K>;
|
|
9609
|
+
template [[host_name("kernel_get_rows_q6_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q6_K, QK_NL, dequantize_q6_K>;
|
|
9610
|
+
template [[host_name("kernel_get_rows_iq2_xxs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq2_xxs, QK_NL, dequantize_iq2_xxs>;
|
|
9611
|
+
template [[host_name("kernel_get_rows_iq2_xs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq2_xs, QK_NL, dequantize_iq2_xs>;
|
|
9612
|
+
template [[host_name("kernel_get_rows_iq3_xxs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq3_xxs, QK_NL, dequantize_iq3_xxs>;
|
|
9613
|
+
template [[host_name("kernel_get_rows_iq3_s")]] kernel get_rows_q_t kernel_get_rows_q<block_iq3_s, QK_NL, dequantize_iq3_s>;
|
|
9614
|
+
template [[host_name("kernel_get_rows_iq2_s")]] kernel get_rows_q_t kernel_get_rows_q<block_iq2_s, QK_NL, dequantize_iq2_s>;
|
|
9615
|
+
template [[host_name("kernel_get_rows_iq1_s")]] kernel get_rows_q_t kernel_get_rows_q<block_iq1_s, QK_NL, dequantize_iq1_s>;
|
|
9616
|
+
template [[host_name("kernel_get_rows_iq1_m")]] kernel get_rows_q_t kernel_get_rows_q<block_iq1_m, QK_NL, dequantize_iq1_m>;
|
|
9617
|
+
template [[host_name("kernel_get_rows_iq4_nl")]] kernel get_rows_q_t kernel_get_rows_q<block_iq4_nl, 2, dequantize_iq4_nl>;
|
|
9618
|
+
template [[host_name("kernel_get_rows_iq4_xs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq4_xs, QK_NL, dequantize_iq4_xs>;
|
|
9619
|
+
|
|
9620
|
+
template<typename TS, typename TI, typename block_q, void (*quantize_func)(device const float *, device block_q &)>
|
|
9327
9621
|
kernel void kernel_set_rows_q32(
|
|
9328
9622
|
constant ggml_metal_kargs_set_rows & args,
|
|
9329
9623
|
device const void * src0,
|
|
@@ -9347,14 +9641,14 @@ kernel void kernel_set_rows_q32(
|
|
|
9347
9641
|
const TI i1 = ((const device TI *) ((const device char *) src1 + i10*args.nb10 + i11*args.nb11 + i12*args.nb12))[0];
|
|
9348
9642
|
|
|
9349
9643
|
device block_q * dst_row = ( device block_q *) (( device char *) dst + i1*args.nb1 + i02*args.nb2 + i03*args.nb3);
|
|
9350
|
-
const device
|
|
9644
|
+
const device TS * src_row = (const device TS *) ((const device char *) src0 + i01*args.nb01 + i02*args.nb02 + i03*args.nb03);
|
|
9351
9645
|
|
|
9352
9646
|
for (int ind = tiitg%tptg.x; ind < args.nk0; ind += tptg.x) {
|
|
9353
9647
|
quantize_func(src_row + 32*ind, dst_row[ind]);
|
|
9354
9648
|
}
|
|
9355
9649
|
}
|
|
9356
9650
|
|
|
9357
|
-
template<typename
|
|
9651
|
+
template<typename TS, typename TI, typename TD>
|
|
9358
9652
|
kernel void kernel_set_rows_f(
|
|
9359
9653
|
constant ggml_metal_kargs_set_rows & args,
|
|
9360
9654
|
device const void * src0,
|
|
@@ -9377,14 +9671,47 @@ kernel void kernel_set_rows_f(
|
|
|
9377
9671
|
const int32_t i10 = i01;
|
|
9378
9672
|
const TI i1 = ((const device TI *) ((const device char *) src1 + i10*args.nb10 + i11*args.nb11 + i12*args.nb12))[0];
|
|
9379
9673
|
|
|
9380
|
-
device
|
|
9381
|
-
const device
|
|
9674
|
+
device TD * dst_row = ( device TD *) (( device char *) dst + i1*args.nb1 + i02*args.nb2 + i03*args.nb3);
|
|
9675
|
+
const device TS * src_row = (const device TS *) ((const device char *) src0 + i01*args.nb01 + i02*args.nb02 + i03*args.nb03);
|
|
9382
9676
|
|
|
9383
9677
|
for (int ind = tiitg%tptg.x; ind < args.nk0; ind += tptg.x) {
|
|
9384
|
-
dst_row[ind] = (
|
|
9678
|
+
dst_row[ind] = (TD) src_row[ind];
|
|
9385
9679
|
}
|
|
9386
9680
|
}
|
|
9387
9681
|
|
|
9682
|
+
typedef decltype(kernel_set_rows_f<float, int64_t, float>) set_rows_f_t;
|
|
9683
|
+
|
|
9684
|
+
template [[host_name("kernel_set_rows_f32_i64_f32")]] kernel set_rows_f_t kernel_set_rows_f<float, int64_t, float>;
|
|
9685
|
+
template [[host_name("kernel_set_rows_f32_i32_f32")]] kernel set_rows_f_t kernel_set_rows_f<float, int32_t, float>;
|
|
9686
|
+
template [[host_name("kernel_set_rows_f32_i64_f16")]] kernel set_rows_f_t kernel_set_rows_f<float, int64_t, half>;
|
|
9687
|
+
template [[host_name("kernel_set_rows_f32_i32_f16")]] kernel set_rows_f_t kernel_set_rows_f<float, int32_t, half>;
|
|
9688
|
+
#if defined(GGML_METAL_HAS_BF16)
|
|
9689
|
+
template [[host_name("kernel_set_rows_f32_i64_bf16")]] kernel set_rows_f_t kernel_set_rows_f<float, int64_t, bfloat>;
|
|
9690
|
+
template [[host_name("kernel_set_rows_f32_i32_bf16")]] kernel set_rows_f_t kernel_set_rows_f<float, int32_t, bfloat>;
|
|
9691
|
+
#endif
|
|
9692
|
+
|
|
9693
|
+
template [[host_name("kernel_set_rows_f16_i64_f16")]] kernel set_rows_f_t kernel_set_rows_f<half, int64_t, half>;
|
|
9694
|
+
template [[host_name("kernel_set_rows_f16_i32_f16")]] kernel set_rows_f_t kernel_set_rows_f<half, int32_t, half>;
|
|
9695
|
+
#if defined(GGML_METAL_HAS_BF16)
|
|
9696
|
+
template [[host_name("kernel_set_rows_bf16_i64_bf16")]] kernel set_rows_f_t kernel_set_rows_f<bfloat, int64_t, bfloat>;
|
|
9697
|
+
template [[host_name("kernel_set_rows_bf16_i32_bf16")]] kernel set_rows_f_t kernel_set_rows_f<bfloat, int32_t, bfloat>;
|
|
9698
|
+
#endif
|
|
9699
|
+
|
|
9700
|
+
typedef decltype(kernel_set_rows_q32<float, int64_t, block_q8_0, quantize_q8_0>) set_rows_q32_t;
|
|
9701
|
+
|
|
9702
|
+
template [[host_name("kernel_set_rows_f32_i64_q8_0")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int64_t, block_q8_0, quantize_q8_0>;
|
|
9703
|
+
template [[host_name("kernel_set_rows_f32_i32_q8_0")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int32_t, block_q8_0, quantize_q8_0>;
|
|
9704
|
+
template [[host_name("kernel_set_rows_f32_i64_q4_0")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int64_t, block_q4_0, quantize_q4_0>;
|
|
9705
|
+
template [[host_name("kernel_set_rows_f32_i32_q4_0")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int32_t, block_q4_0, quantize_q4_0>;
|
|
9706
|
+
template [[host_name("kernel_set_rows_f32_i64_q4_1")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int64_t, block_q4_1, quantize_q4_1>;
|
|
9707
|
+
template [[host_name("kernel_set_rows_f32_i32_q4_1")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int32_t, block_q4_1, quantize_q4_1>;
|
|
9708
|
+
template [[host_name("kernel_set_rows_f32_i64_q5_0")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int64_t, block_q5_0, quantize_q5_0>;
|
|
9709
|
+
template [[host_name("kernel_set_rows_f32_i32_q5_0")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int32_t, block_q5_0, quantize_q5_0>;
|
|
9710
|
+
template [[host_name("kernel_set_rows_f32_i64_q5_1")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int64_t, block_q5_1, quantize_q5_1>;
|
|
9711
|
+
template [[host_name("kernel_set_rows_f32_i32_q5_1")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int32_t, block_q5_1, quantize_q5_1>;
|
|
9712
|
+
template [[host_name("kernel_set_rows_f32_i64_iq4_nl")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int64_t, block_iq4_nl, quantize_iq4_nl>;
|
|
9713
|
+
template [[host_name("kernel_set_rows_f32_i32_iq4_nl")]] kernel set_rows_q32_t kernel_set_rows_q32<float, int32_t, block_iq4_nl, quantize_iq4_nl>;
|
|
9714
|
+
|
|
9388
9715
|
kernel void kernel_diag_f32(
|
|
9389
9716
|
constant ggml_metal_kargs_diag & args,
|
|
9390
9717
|
device const char * src0,
|
|
@@ -10127,75 +10454,6 @@ kernel void kernel_mul_mm_id(
|
|
|
10127
10454
|
}
|
|
10128
10455
|
}
|
|
10129
10456
|
|
|
10130
|
-
#define QK_NL 16
|
|
10131
|
-
|
|
10132
|
-
//
|
|
10133
|
-
// get rows
|
|
10134
|
-
//
|
|
10135
|
-
|
|
10136
|
-
typedef decltype(kernel_get_rows_f<float, float>) get_rows_f_t;
|
|
10137
|
-
|
|
10138
|
-
template [[host_name("kernel_get_rows_f32")]] kernel get_rows_f_t kernel_get_rows_f<float, float>;
|
|
10139
|
-
template [[host_name("kernel_get_rows_f16")]] kernel get_rows_f_t kernel_get_rows_f<half, float>;
|
|
10140
|
-
template [[host_name("kernel_get_rows_i32")]] kernel get_rows_f_t kernel_get_rows_f<int32_t, int32_t>;
|
|
10141
|
-
#if defined(GGML_METAL_HAS_BF16)
|
|
10142
|
-
template [[host_name("kernel_get_rows_bf16")]] kernel get_rows_f_t kernel_get_rows_f<bfloat, float>;
|
|
10143
|
-
#endif
|
|
10144
|
-
|
|
10145
|
-
typedef decltype(kernel_get_rows_q<block_q4_0, 2, dequantize_q4_0>) get_rows_q_t;
|
|
10146
|
-
|
|
10147
|
-
template [[host_name("kernel_get_rows_q1_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q1_0, 8, dequantize_q1_0>;
|
|
10148
|
-
template [[host_name("kernel_get_rows_q4_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q4_0, 2, dequantize_q4_0>;
|
|
10149
|
-
template [[host_name("kernel_get_rows_q4_1")]] kernel get_rows_q_t kernel_get_rows_q<block_q4_1, 2, dequantize_q4_1>;
|
|
10150
|
-
template [[host_name("kernel_get_rows_q5_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q5_0, 2, dequantize_q5_0>;
|
|
10151
|
-
template [[host_name("kernel_get_rows_q5_1")]] kernel get_rows_q_t kernel_get_rows_q<block_q5_1, 2, dequantize_q5_1>;
|
|
10152
|
-
template [[host_name("kernel_get_rows_q8_0")]] kernel get_rows_q_t kernel_get_rows_q<block_q8_0, 2, dequantize_q8_0>;
|
|
10153
|
-
template [[host_name("kernel_get_rows_mxfp4")]] kernel get_rows_q_t kernel_get_rows_q<block_mxfp4, 2, dequantize_mxfp4>;
|
|
10154
|
-
template [[host_name("kernel_get_rows_q2_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q2_K, QK_NL, dequantize_q2_K>;
|
|
10155
|
-
template [[host_name("kernel_get_rows_q3_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q3_K, QK_NL, dequantize_q3_K>;
|
|
10156
|
-
template [[host_name("kernel_get_rows_q4_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q4_K, QK_NL, dequantize_q4_K>;
|
|
10157
|
-
template [[host_name("kernel_get_rows_q5_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q5_K, QK_NL, dequantize_q5_K>;
|
|
10158
|
-
template [[host_name("kernel_get_rows_q6_K")]] kernel get_rows_q_t kernel_get_rows_q<block_q6_K, QK_NL, dequantize_q6_K>;
|
|
10159
|
-
template [[host_name("kernel_get_rows_iq2_xxs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq2_xxs, QK_NL, dequantize_iq2_xxs>;
|
|
10160
|
-
template [[host_name("kernel_get_rows_iq2_xs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq2_xs, QK_NL, dequantize_iq2_xs>;
|
|
10161
|
-
template [[host_name("kernel_get_rows_iq3_xxs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq3_xxs, QK_NL, dequantize_iq3_xxs>;
|
|
10162
|
-
template [[host_name("kernel_get_rows_iq3_s")]] kernel get_rows_q_t kernel_get_rows_q<block_iq3_s, QK_NL, dequantize_iq3_s>;
|
|
10163
|
-
template [[host_name("kernel_get_rows_iq2_s")]] kernel get_rows_q_t kernel_get_rows_q<block_iq2_s, QK_NL, dequantize_iq2_s>;
|
|
10164
|
-
template [[host_name("kernel_get_rows_iq1_s")]] kernel get_rows_q_t kernel_get_rows_q<block_iq1_s, QK_NL, dequantize_iq1_s>;
|
|
10165
|
-
template [[host_name("kernel_get_rows_iq1_m")]] kernel get_rows_q_t kernel_get_rows_q<block_iq1_m, QK_NL, dequantize_iq1_m>;
|
|
10166
|
-
template [[host_name("kernel_get_rows_iq4_nl")]] kernel get_rows_q_t kernel_get_rows_q<block_iq4_nl, 2, dequantize_iq4_nl>;
|
|
10167
|
-
template [[host_name("kernel_get_rows_iq4_xs")]] kernel get_rows_q_t kernel_get_rows_q<block_iq4_xs, QK_NL, dequantize_iq4_xs>;
|
|
10168
|
-
|
|
10169
|
-
//
|
|
10170
|
-
// set rows
|
|
10171
|
-
//
|
|
10172
|
-
|
|
10173
|
-
typedef decltype(kernel_set_rows_f<float, int64_t>) set_rows_f_t;
|
|
10174
|
-
|
|
10175
|
-
template [[host_name("kernel_set_rows_f32_i64")]] kernel set_rows_f_t kernel_set_rows_f<float, int64_t>;
|
|
10176
|
-
template [[host_name("kernel_set_rows_f32_i32")]] kernel set_rows_f_t kernel_set_rows_f<float, int32_t>;
|
|
10177
|
-
template [[host_name("kernel_set_rows_f16_i64")]] kernel set_rows_f_t kernel_set_rows_f<half, int64_t>;
|
|
10178
|
-
template [[host_name("kernel_set_rows_f16_i32")]] kernel set_rows_f_t kernel_set_rows_f<half, int32_t>;
|
|
10179
|
-
#if defined(GGML_METAL_HAS_BF16)
|
|
10180
|
-
template [[host_name("kernel_set_rows_bf16_i64")]] kernel set_rows_f_t kernel_set_rows_f<bfloat, int64_t>;
|
|
10181
|
-
template [[host_name("kernel_set_rows_bf16_i32")]] kernel set_rows_f_t kernel_set_rows_f<bfloat, int32_t>;
|
|
10182
|
-
#endif
|
|
10183
|
-
|
|
10184
|
-
typedef decltype(kernel_set_rows_q32<int64_t, block_q8_0, quantize_q8_0>) set_rows_q32_t;
|
|
10185
|
-
|
|
10186
|
-
template [[host_name("kernel_set_rows_q8_0_i64")]] kernel set_rows_q32_t kernel_set_rows_q32<int64_t, block_q8_0, quantize_q8_0>;
|
|
10187
|
-
template [[host_name("kernel_set_rows_q8_0_i32")]] kernel set_rows_q32_t kernel_set_rows_q32<int32_t, block_q8_0, quantize_q8_0>;
|
|
10188
|
-
template [[host_name("kernel_set_rows_q4_0_i64")]] kernel set_rows_q32_t kernel_set_rows_q32<int64_t, block_q4_0, quantize_q4_0>;
|
|
10189
|
-
template [[host_name("kernel_set_rows_q4_0_i32")]] kernel set_rows_q32_t kernel_set_rows_q32<int32_t, block_q4_0, quantize_q4_0>;
|
|
10190
|
-
template [[host_name("kernel_set_rows_q4_1_i64")]] kernel set_rows_q32_t kernel_set_rows_q32<int64_t, block_q4_1, quantize_q4_1>;
|
|
10191
|
-
template [[host_name("kernel_set_rows_q4_1_i32")]] kernel set_rows_q32_t kernel_set_rows_q32<int32_t, block_q4_1, quantize_q4_1>;
|
|
10192
|
-
template [[host_name("kernel_set_rows_q5_0_i64")]] kernel set_rows_q32_t kernel_set_rows_q32<int64_t, block_q5_0, quantize_q5_0>;
|
|
10193
|
-
template [[host_name("kernel_set_rows_q5_0_i32")]] kernel set_rows_q32_t kernel_set_rows_q32<int32_t, block_q5_0, quantize_q5_0>;
|
|
10194
|
-
template [[host_name("kernel_set_rows_q5_1_i64")]] kernel set_rows_q32_t kernel_set_rows_q32<int64_t, block_q5_1, quantize_q5_1>;
|
|
10195
|
-
template [[host_name("kernel_set_rows_q5_1_i32")]] kernel set_rows_q32_t kernel_set_rows_q32<int32_t, block_q5_1, quantize_q5_1>;
|
|
10196
|
-
template [[host_name("kernel_set_rows_iq4_nl_i64")]] kernel set_rows_q32_t kernel_set_rows_q32<int64_t, block_iq4_nl, quantize_iq4_nl>;
|
|
10197
|
-
template [[host_name("kernel_set_rows_iq4_nl_i32")]] kernel set_rows_q32_t kernel_set_rows_q32<int32_t, block_iq4_nl, quantize_iq4_nl>;
|
|
10198
|
-
|
|
10199
10457
|
//
|
|
10200
10458
|
// matrix-matrix multiplication
|
|
10201
10459
|
//
|
|
@@ -31,6 +31,11 @@ if (GGML_OPENCL_EMBED_KERNELS)
|
|
|
31
31
|
target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/autogenerated")
|
|
32
32
|
endif ()
|
|
33
33
|
|
|
34
|
+
if (GGML_OPENCL_USE_ADRENO_BIN_KERNELS)
|
|
35
|
+
message(STATUS "OpenCL will use precompiled binary kernels for Adreno (improved performance on some platforms)")
|
|
36
|
+
add_compile_definitions(GGML_OPENCL_USE_ADRENO_BIN_KERNELS)
|
|
37
|
+
endif ()
|
|
38
|
+
|
|
34
39
|
function(ggml_opencl_add_kernel KNAME)
|
|
35
40
|
set(KERN_HDR ${CMAKE_CURRENT_BINARY_DIR}/autogenerated/${KNAME}.cl.h)
|
|
36
41
|
set(KERN_SRC ${CMAKE_CURRENT_SOURCE_DIR}/kernels/${KNAME}.cl)
|
|
@@ -78,6 +83,8 @@ set(GGML_OPENCL_KERNELS
|
|
|
78
83
|
mul_mv_f16_f32_l4
|
|
79
84
|
mul_mv_f16_f32
|
|
80
85
|
mul_mv_f32_f32
|
|
86
|
+
mul_mv_q1_0_f32
|
|
87
|
+
mul_mv_q1_0_f32_flat
|
|
81
88
|
mul_mv_q4_0_f32
|
|
82
89
|
mul_mv_q4_0_f32_v
|
|
83
90
|
mul_mv_q4_0_f32_8x_flat
|
|
@@ -128,6 +135,7 @@ set(GGML_OPENCL_KERNELS
|
|
|
128
135
|
moe_sort_by_expert
|
|
129
136
|
mul_mm_f32_f32_l4_lm
|
|
130
137
|
mul_mm_f16_f32_l4_lm
|
|
138
|
+
mul_mm_q1_0_f32_l4_lm
|
|
131
139
|
mul_mm_q4_0_f32_l4_lm
|
|
132
140
|
mul_mm_q4_1_f32_l4_lm
|
|
133
141
|
mul_mm_q5_0_f32_l4_lm
|
|
@@ -137,6 +145,8 @@ set(GGML_OPENCL_KERNELS
|
|
|
137
145
|
mul_mm_q4_k_f32_l4_lm
|
|
138
146
|
mul_mm_q5_k_f32_l4_lm
|
|
139
147
|
mul_mm_q6_k_f32_l4_lm
|
|
148
|
+
gemv_noshuffle_q1_0_f32
|
|
149
|
+
gemm_noshuffle_q1_0_f32
|
|
140
150
|
gemv_noshuffle_q4_0_f32
|
|
141
151
|
gemv_noshuffle_q4_0_f32_spec
|
|
142
152
|
gemm_noshuffle_q4_0_f32
|
|
@@ -192,7 +202,10 @@ set(GGML_OPENCL_KERNELS
|
|
|
192
202
|
mul_mm_f16_f32_kq_kqv
|
|
193
203
|
conv2d
|
|
194
204
|
conv2d_f16_f32
|
|
205
|
+
flash_attn_pre_f16
|
|
195
206
|
flash_attn_f32_f16
|
|
207
|
+
flash_attn_f32_q8_0
|
|
208
|
+
flash_attn_f32_q4_0
|
|
196
209
|
flash_attn_f16
|
|
197
210
|
flash_attn_f32
|
|
198
211
|
)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
// Flash-attention per-(dk,dv) tile tuning for the Adreno OpenCL backend.
|
|
4
|
+
// Isolated from ggml-opencl.cpp so the tuning numbers are easy to find and
|
|
5
|
+
// edit; the FA dispatch and kernel-compile logic stay in the main file.
|
|
6
|
+
// This header is a file section — it is #included exactly once, at the point
|
|
7
|
+
// in ggml-opencl.cpp where the ggml logging macros are already in scope.
|
|
8
|
+
|
|
9
|
+
// Per-(dk, dv) FA config; shared by dispatch and supports_op.
|
|
10
|
+
struct ggml_opencl_fa_dim {
|
|
11
|
+
int dk; int dv; int bm; int bn; int n_split; int nkv_split_threshold;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Split variant fires when n_kv >= threshold (threshold=0 -> always split).
|
|
15
|
+
// Default tuning covers Adreno 7xx/8xx mobile and X1-series laptop GPUs.
|
|
16
|
+
static const ggml_opencl_fa_dim g_fa_dims_adreno_default[] = {
|
|
17
|
+
{ 40, 40, 64, 32, 1, 0}, { 64, 64, 64, 32, 2, 64},
|
|
18
|
+
{ 80, 80, 64, 32, 2, 64}, { 96, 96, 64, 32, 2, 64},
|
|
19
|
+
{112, 112, 64, 32, 2, 64}, {128, 128, 64, 32, 2, 64},
|
|
20
|
+
{192, 128, 16, 16, 1, 0},
|
|
21
|
+
{192, 192, 16, 16, 1, 0},
|
|
22
|
+
{256, 256, 16, 16, 16, 0},
|
|
23
|
+
{512, 512, 8, 16, 64, 0},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
struct ggml_opencl_fa_dim_table {
|
|
27
|
+
const ggml_opencl_fa_dim * data;
|
|
28
|
+
size_t count;
|
|
29
|
+
|
|
30
|
+
const ggml_opencl_fa_dim * begin() const { return data; }
|
|
31
|
+
const ggml_opencl_fa_dim * end() const { return data + count; }
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Mutable copy of the active table; GGML_OPENCL_FA_TUNE patches entries here
|
|
35
|
+
// at backend init without touching the const source table.
|
|
36
|
+
static ggml_opencl_fa_dim g_fa_dims_runtime[
|
|
37
|
+
sizeof(g_fa_dims_adreno_default) / sizeof(g_fa_dims_adreno_default[0])];
|
|
38
|
+
|
|
39
|
+
static ggml_opencl_fa_dim_table g_opencl_fa_dims = {
|
|
40
|
+
g_fa_dims_adreno_default,
|
|
41
|
+
sizeof(g_fa_dims_adreno_default) / sizeof(g_fa_dims_adreno_default[0]),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// GGML_OPENCL_FA_TUNE=dk:dv:bm:bn:nsplit:thr[,…] — patches matching entries
|
|
45
|
+
// in the active table at backend init, before the first FA kernel compiles.
|
|
46
|
+
// Unmatched (dk,dv) pairs are warned and ignored.
|
|
47
|
+
static void ggml_opencl_fa_apply_env_overrides() {
|
|
48
|
+
const char * e = std::getenv("GGML_OPENCL_FA_TUNE");
|
|
49
|
+
if (!e || !e[0]) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
std::string s = e;
|
|
54
|
+
size_t pos = 0;
|
|
55
|
+
while (pos < s.size()) {
|
|
56
|
+
size_t comma = s.find(',', pos);
|
|
57
|
+
std::string entry = s.substr(pos, comma == std::string::npos ? std::string::npos : comma - pos);
|
|
58
|
+
int dk, dv, bm, bn, nsplit, thr;
|
|
59
|
+
if (std::sscanf(entry.c_str(), "%d:%d:%d:%d:%d:%d", &dk, &dv, &bm, &bn, &nsplit, &thr) == 6) {
|
|
60
|
+
bool patched = false;
|
|
61
|
+
for (size_t i = 0; i < g_opencl_fa_dims.count; ++i) {
|
|
62
|
+
ggml_opencl_fa_dim & d = g_fa_dims_runtime[i];
|
|
63
|
+
if (d.dk == dk && d.dv == dv) {
|
|
64
|
+
d.bm = bm; d.bn = bn; d.n_split = nsplit; d.nkv_split_threshold = thr;
|
|
65
|
+
GGML_LOG_INFO("ggml_opencl: FA tune override DK=%d DV=%d -> bm=%d bn=%d n_split=%d thr=%d\n",
|
|
66
|
+
dk, dv, bm, bn, nsplit, thr);
|
|
67
|
+
patched = true;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!patched) {
|
|
72
|
+
GGML_LOG_WARN("ggml_opencl: FA tune override DK=%d DV=%d ignored (no matching dim)\n", dk, dv);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
GGML_LOG_WARN("ggml_opencl: FA tune override entry malformed: '%s'\n", entry.c_str());
|
|
76
|
+
}
|
|
77
|
+
if (comma == std::string::npos) break;
|
|
78
|
+
pos = comma + 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Copy the default table into the mutable runtime buffer and apply any
|
|
83
|
+
// GGML_OPENCL_FA_TUNE overrides. A per-generation table can be added here
|
|
84
|
+
// once it has been tuned on hardware.
|
|
85
|
+
static void ggml_cl_init_fa_dims_table() {
|
|
86
|
+
const size_t count = sizeof(g_fa_dims_adreno_default) / sizeof(g_fa_dims_adreno_default[0]);
|
|
87
|
+
for (size_t i = 0; i < count; ++i) {
|
|
88
|
+
g_fa_dims_runtime[i] = g_fa_dims_adreno_default[i];
|
|
89
|
+
}
|
|
90
|
+
g_opencl_fa_dims = { g_fa_dims_runtime, count };
|
|
91
|
+
ggml_opencl_fa_apply_env_overrides();
|
|
92
|
+
}
|