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
|
@@ -158,6 +158,239 @@ kernel void kernel_set_rows_f32_i32(
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
// f32 -> q8_0 quantize set_rows. Block = half d + char qs[32].
|
|
162
|
+
#define QK8_0 32
|
|
163
|
+
|
|
164
|
+
inline void quantize_q8_0_block(global float * x, global char * qs, global half * d_out) {
|
|
165
|
+
float amax = 0.0f;
|
|
166
|
+
for (int j = 0; j < QK8_0; j++) {
|
|
167
|
+
amax = fmax(amax, fabs(x[j]));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
float d = amax / 127.0f;
|
|
171
|
+
float id = (d != 0.0f) ? 127.0f / amax : 0.0f;
|
|
172
|
+
|
|
173
|
+
vstore_half(d, 0, d_out);
|
|
174
|
+
|
|
175
|
+
for (int j = 0; j < QK8_0; j++) {
|
|
176
|
+
qs[j] = (char)((int)round(x[j] * id));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
kernel void kernel_set_rows_q8_0_i64(
|
|
181
|
+
global char * src0,
|
|
182
|
+
ulong offset0,
|
|
183
|
+
global char * src1,
|
|
184
|
+
ulong offset1,
|
|
185
|
+
global char * dst,
|
|
186
|
+
ulong offsetd,
|
|
187
|
+
int ne01,
|
|
188
|
+
ulong nb01,
|
|
189
|
+
ulong nb02,
|
|
190
|
+
ulong nb03,
|
|
191
|
+
uint4 ne11,
|
|
192
|
+
uint4 ne12,
|
|
193
|
+
ulong nb10,
|
|
194
|
+
ulong nb11,
|
|
195
|
+
ulong nb12,
|
|
196
|
+
int nblk0,
|
|
197
|
+
ulong nb1,
|
|
198
|
+
ulong nb2,
|
|
199
|
+
ulong nb3
|
|
200
|
+
) {
|
|
201
|
+
src0 = src0 + offset0;
|
|
202
|
+
src1 = src1 + offset1;
|
|
203
|
+
dst = dst + offsetd;
|
|
204
|
+
|
|
205
|
+
int i03 = get_group_id(2);
|
|
206
|
+
int i02 = get_group_id(1);
|
|
207
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
208
|
+
|
|
209
|
+
if (i01 >= ne01) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
int i12 = fastmod(i03, ne12);
|
|
214
|
+
int i11 = fastmod(i02, ne11);
|
|
215
|
+
|
|
216
|
+
int i10 = i01;
|
|
217
|
+
long i1 = ((global long *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
218
|
+
|
|
219
|
+
global char * dst_row = (global char *) (dst + i1*nb1 + i02*nb2 + i03*nb3);
|
|
220
|
+
global float * src_row = (global float *) (src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
221
|
+
|
|
222
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
223
|
+
global float * x = src_row + blk * QK8_0;
|
|
224
|
+
global char * y = dst_row + blk * (2 + QK8_0);
|
|
225
|
+
|
|
226
|
+
quantize_q8_0_block(x, y + 2, (global half *)y);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
kernel void kernel_set_rows_q8_0_i32(
|
|
231
|
+
global char * src0,
|
|
232
|
+
ulong offset0,
|
|
233
|
+
global char * src1,
|
|
234
|
+
ulong offset1,
|
|
235
|
+
global char * dst,
|
|
236
|
+
ulong offsetd,
|
|
237
|
+
int ne01,
|
|
238
|
+
ulong nb01,
|
|
239
|
+
ulong nb02,
|
|
240
|
+
ulong nb03,
|
|
241
|
+
uint4 ne11,
|
|
242
|
+
uint4 ne12,
|
|
243
|
+
ulong nb10,
|
|
244
|
+
ulong nb11,
|
|
245
|
+
ulong nb12,
|
|
246
|
+
int nblk0,
|
|
247
|
+
ulong nb1,
|
|
248
|
+
ulong nb2,
|
|
249
|
+
ulong nb3
|
|
250
|
+
) {
|
|
251
|
+
src0 = src0 + offset0;
|
|
252
|
+
src1 = src1 + offset1;
|
|
253
|
+
dst = dst + offsetd;
|
|
254
|
+
|
|
255
|
+
int i03 = get_group_id(2);
|
|
256
|
+
int i02 = get_group_id(1);
|
|
257
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
258
|
+
|
|
259
|
+
if (i01 >= ne01) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
int i12 = fastmod(i03, ne12);
|
|
264
|
+
int i11 = fastmod(i02, ne11);
|
|
265
|
+
|
|
266
|
+
int i10 = i01;
|
|
267
|
+
int i1 = ((global int *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
268
|
+
|
|
269
|
+
global char * dst_row = (global char *) (dst + i1*nb1 + i02*nb2 + i03*nb3);
|
|
270
|
+
global float * src_row = (global float *) (src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
271
|
+
|
|
272
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
273
|
+
global float * x = src_row + blk * QK8_0;
|
|
274
|
+
global char * y = dst_row + blk * (2 + QK8_0);
|
|
275
|
+
|
|
276
|
+
quantize_q8_0_block(x, y + 2, (global half *)y);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// SoA q8_0 variants. dst_q: int8[QK8_0] per block; dst_d: fp16 scale per block.
|
|
281
|
+
// Layout matches kernel_convert_block_q8_0; block index follows dst element order.
|
|
282
|
+
kernel void kernel_set_rows_q8_0_soa_i64(
|
|
283
|
+
global char * src0,
|
|
284
|
+
ulong offset0,
|
|
285
|
+
global char * src1,
|
|
286
|
+
ulong offset1,
|
|
287
|
+
global char * dst_q,
|
|
288
|
+
ulong offset_q,
|
|
289
|
+
global char * dst_d,
|
|
290
|
+
ulong offset_d,
|
|
291
|
+
int ne01,
|
|
292
|
+
ulong nb01,
|
|
293
|
+
ulong nb02,
|
|
294
|
+
ulong nb03,
|
|
295
|
+
uint4 ne11,
|
|
296
|
+
uint4 ne12,
|
|
297
|
+
ulong nb10,
|
|
298
|
+
ulong nb11,
|
|
299
|
+
ulong nb12,
|
|
300
|
+
int nblk0,
|
|
301
|
+
int ne1_dst,
|
|
302
|
+
int ne2_dst,
|
|
303
|
+
int ne3_dst
|
|
304
|
+
) {
|
|
305
|
+
src0 = src0 + offset0;
|
|
306
|
+
src1 = src1 + offset1;
|
|
307
|
+
dst_q = dst_q + offset_q;
|
|
308
|
+
dst_d = dst_d + offset_d;
|
|
309
|
+
|
|
310
|
+
int i03 = get_group_id(2);
|
|
311
|
+
int i02 = get_group_id(1);
|
|
312
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
313
|
+
|
|
314
|
+
if (i01 >= ne01) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
int i12 = fastmod(i03, ne12);
|
|
319
|
+
int i11 = fastmod(i02, ne11);
|
|
320
|
+
|
|
321
|
+
int i10 = i01;
|
|
322
|
+
long i1 = ((global long *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
323
|
+
|
|
324
|
+
long row_blk_base = ((long)i03 * ne2_dst * ne1_dst + (long)i02 * ne1_dst + i1) * nblk0;
|
|
325
|
+
|
|
326
|
+
global half * d_row = (global half *)(dst_d) + row_blk_base;
|
|
327
|
+
global char * q_row = (global char *)(dst_q) + row_blk_base * QK8_0;
|
|
328
|
+
global float * src_row = (global float *)(src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
329
|
+
|
|
330
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
331
|
+
global float * x = src_row + blk * QK8_0;
|
|
332
|
+
global char * q = q_row + blk * QK8_0;
|
|
333
|
+
|
|
334
|
+
quantize_q8_0_block(x, q, d_row + blk);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
kernel void kernel_set_rows_q8_0_soa_i32(
|
|
339
|
+
global char * src0,
|
|
340
|
+
ulong offset0,
|
|
341
|
+
global char * src1,
|
|
342
|
+
ulong offset1,
|
|
343
|
+
global char * dst_q,
|
|
344
|
+
ulong offset_q,
|
|
345
|
+
global char * dst_d,
|
|
346
|
+
ulong offset_d,
|
|
347
|
+
int ne01,
|
|
348
|
+
ulong nb01,
|
|
349
|
+
ulong nb02,
|
|
350
|
+
ulong nb03,
|
|
351
|
+
uint4 ne11,
|
|
352
|
+
uint4 ne12,
|
|
353
|
+
ulong nb10,
|
|
354
|
+
ulong nb11,
|
|
355
|
+
ulong nb12,
|
|
356
|
+
int nblk0,
|
|
357
|
+
int ne1_dst,
|
|
358
|
+
int ne2_dst,
|
|
359
|
+
int ne3_dst
|
|
360
|
+
) {
|
|
361
|
+
src0 = src0 + offset0;
|
|
362
|
+
src1 = src1 + offset1;
|
|
363
|
+
dst_q = dst_q + offset_q;
|
|
364
|
+
dst_d = dst_d + offset_d;
|
|
365
|
+
|
|
366
|
+
int i03 = get_group_id(2);
|
|
367
|
+
int i02 = get_group_id(1);
|
|
368
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
369
|
+
|
|
370
|
+
if (i01 >= ne01) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
int i12 = fastmod(i03, ne12);
|
|
375
|
+
int i11 = fastmod(i02, ne11);
|
|
376
|
+
|
|
377
|
+
int i10 = i01;
|
|
378
|
+
int i1 = ((global int *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
379
|
+
|
|
380
|
+
long row_blk_base = ((long)i03 * ne2_dst * ne1_dst + (long)i02 * ne1_dst + i1) * nblk0;
|
|
381
|
+
|
|
382
|
+
global half * d_row = (global half *)(dst_d) + row_blk_base;
|
|
383
|
+
global char * q_row = (global char *)(dst_q) + row_blk_base * QK8_0;
|
|
384
|
+
global float * src_row = (global float *)(src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
385
|
+
|
|
386
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
387
|
+
global float * x = src_row + blk * QK8_0;
|
|
388
|
+
global char * q = q_row + blk * QK8_0;
|
|
389
|
+
|
|
390
|
+
quantize_q8_0_block(x, q, d_row + blk);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
161
394
|
kernel void kernel_set_rows_f16_i32(
|
|
162
395
|
global char * src0,
|
|
163
396
|
ulong offset0,
|
|
@@ -206,3 +439,270 @@ kernel void kernel_set_rows_f16_i32(
|
|
|
206
439
|
dst_row[ind] = src_row[ind];
|
|
207
440
|
}
|
|
208
441
|
}
|
|
442
|
+
|
|
443
|
+
// f32 -> q4_0 quantize set_rows. Block = half d + uchar qs[16] (shuffled
|
|
444
|
+
// nibbles: qs[j] low/high = elem j / j+16).
|
|
445
|
+
// Dequant: val[i] = d * (nibble_i - 8)
|
|
446
|
+
// nblk0 = number of q4_0 blocks per row = ne00 / 32.
|
|
447
|
+
#define QK4_0 32
|
|
448
|
+
#define Q4_0_BLOCK_SIZE 18
|
|
449
|
+
|
|
450
|
+
inline void quantize_q4_0_block(global float * x, global uchar * qs, global half * d_out) {
|
|
451
|
+
// Find the signed value with the largest absolute magnitude (matches ggml ref).
|
|
452
|
+
float max = 0.0f;
|
|
453
|
+
float amax = 0.0f;
|
|
454
|
+
for (int j = 0; j < QK4_0; j++) {
|
|
455
|
+
float v = x[j];
|
|
456
|
+
float a = fabs(v);
|
|
457
|
+
if (a > amax) {
|
|
458
|
+
amax = a;
|
|
459
|
+
max = v;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
float d = max / -8.0f;
|
|
464
|
+
float id = (d != 0.0f) ? 1.0f / d : 0.0f;
|
|
465
|
+
|
|
466
|
+
vstore_half(d, 0, d_out);
|
|
467
|
+
|
|
468
|
+
for (int j = 0; j < QK4_0/2; j++) {
|
|
469
|
+
float x0 = x[j] * id;
|
|
470
|
+
float x1 = x[j + QK4_0/2] * id;
|
|
471
|
+
|
|
472
|
+
int i0 = (int)(x0 + 8.5f);
|
|
473
|
+
int i1 = (int)(x1 + 8.5f);
|
|
474
|
+
if (i0 < 0) i0 = 0;
|
|
475
|
+
if (i0 > 15) i0 = 15;
|
|
476
|
+
if (i1 < 0) i1 = 0;
|
|
477
|
+
if (i1 > 15) i1 = 15;
|
|
478
|
+
|
|
479
|
+
qs[j] = (uchar)i0 | ((uchar)i1 << 4);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
kernel void kernel_set_rows_q4_0_i64(
|
|
484
|
+
global char * src0,
|
|
485
|
+
ulong offset0,
|
|
486
|
+
global char * src1,
|
|
487
|
+
ulong offset1,
|
|
488
|
+
global char * dst,
|
|
489
|
+
ulong offsetd,
|
|
490
|
+
int ne01,
|
|
491
|
+
ulong nb01,
|
|
492
|
+
ulong nb02,
|
|
493
|
+
ulong nb03,
|
|
494
|
+
uint4 ne11,
|
|
495
|
+
uint4 ne12,
|
|
496
|
+
ulong nb10,
|
|
497
|
+
ulong nb11,
|
|
498
|
+
ulong nb12,
|
|
499
|
+
int nblk0,
|
|
500
|
+
ulong nb1,
|
|
501
|
+
ulong nb2,
|
|
502
|
+
ulong nb3
|
|
503
|
+
) {
|
|
504
|
+
src0 = src0 + offset0;
|
|
505
|
+
src1 = src1 + offset1;
|
|
506
|
+
dst = dst + offsetd;
|
|
507
|
+
|
|
508
|
+
int i03 = get_group_id(2);
|
|
509
|
+
int i02 = get_group_id(1);
|
|
510
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
511
|
+
|
|
512
|
+
if (i01 >= ne01) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
int i12 = fastmod(i03, ne12);
|
|
517
|
+
int i11 = fastmod(i02, ne11);
|
|
518
|
+
|
|
519
|
+
int i10 = i01;
|
|
520
|
+
long i1 = ((global long *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
521
|
+
|
|
522
|
+
global char * dst_row = (global char *) (dst + i1*nb1 + i02*nb2 + i03*nb3);
|
|
523
|
+
global float * src_row = (global float *) (src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
524
|
+
|
|
525
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
526
|
+
global float * x = src_row + blk * QK4_0;
|
|
527
|
+
global char * y = dst_row + blk * Q4_0_BLOCK_SIZE;
|
|
528
|
+
global half * yd = (global half *)(y);
|
|
529
|
+
global uchar * yqs = (global uchar *)(y + 2);
|
|
530
|
+
|
|
531
|
+
quantize_q4_0_block(x, yqs, yd);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
kernel void kernel_set_rows_q4_0_i32(
|
|
536
|
+
global char * src0,
|
|
537
|
+
ulong offset0,
|
|
538
|
+
global char * src1,
|
|
539
|
+
ulong offset1,
|
|
540
|
+
global char * dst,
|
|
541
|
+
ulong offsetd,
|
|
542
|
+
int ne01,
|
|
543
|
+
ulong nb01,
|
|
544
|
+
ulong nb02,
|
|
545
|
+
ulong nb03,
|
|
546
|
+
uint4 ne11,
|
|
547
|
+
uint4 ne12,
|
|
548
|
+
ulong nb10,
|
|
549
|
+
ulong nb11,
|
|
550
|
+
ulong nb12,
|
|
551
|
+
int nblk0,
|
|
552
|
+
ulong nb1,
|
|
553
|
+
ulong nb2,
|
|
554
|
+
ulong nb3
|
|
555
|
+
) {
|
|
556
|
+
src0 = src0 + offset0;
|
|
557
|
+
src1 = src1 + offset1;
|
|
558
|
+
dst = dst + offsetd;
|
|
559
|
+
|
|
560
|
+
int i03 = get_group_id(2);
|
|
561
|
+
int i02 = get_group_id(1);
|
|
562
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
563
|
+
|
|
564
|
+
if (i01 >= ne01) {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
int i12 = fastmod(i03, ne12);
|
|
569
|
+
int i11 = fastmod(i02, ne11);
|
|
570
|
+
|
|
571
|
+
int i10 = i01;
|
|
572
|
+
int i1 = ((global int *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
573
|
+
|
|
574
|
+
global char * dst_row = (global char *) (dst + i1*nb1 + i02*nb2 + i03*nb3);
|
|
575
|
+
global float * src_row = (global float *) (src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
576
|
+
|
|
577
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
578
|
+
global float * x = src_row + blk * QK4_0;
|
|
579
|
+
global char * y = dst_row + blk * Q4_0_BLOCK_SIZE;
|
|
580
|
+
global half * yd = (global half *)(y);
|
|
581
|
+
global uchar * yqs = (global uchar *)(y + 2);
|
|
582
|
+
|
|
583
|
+
quantize_q4_0_block(x, yqs, yd);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
// SoA variants for q4_0 dst. Used when the backend has split block_q4_0 records
|
|
588
|
+
// into separate quant (dst_q) and scale (dst_d) sub-buffers — same pattern as
|
|
589
|
+
// the q8_0 SoA variants above.
|
|
590
|
+
//
|
|
591
|
+
// Layout (matches kernel_convert_block_q4_0, the "shuffled" variant):
|
|
592
|
+
// dst_q: contiguous 16 packed nibbles per block, block i at offset i * 16 bytes.
|
|
593
|
+
// dst_d: contiguous fp16 scales, block i at offset i * 2 bytes.
|
|
594
|
+
// Nibble layout inside each byte is unchanged from AoS: qs[j] low nibble = element j,
|
|
595
|
+
// qs[j] high nibble = element j+16. kernel_restore_block_q4_0 copies bytes as-is.
|
|
596
|
+
kernel void kernel_set_rows_q4_0_soa_i64(
|
|
597
|
+
global char * src0,
|
|
598
|
+
ulong offset0,
|
|
599
|
+
global char * src1,
|
|
600
|
+
ulong offset1,
|
|
601
|
+
global char * dst_q,
|
|
602
|
+
ulong offset_q,
|
|
603
|
+
global char * dst_d,
|
|
604
|
+
ulong offset_d,
|
|
605
|
+
int ne01,
|
|
606
|
+
ulong nb01,
|
|
607
|
+
ulong nb02,
|
|
608
|
+
ulong nb03,
|
|
609
|
+
uint4 ne11,
|
|
610
|
+
uint4 ne12,
|
|
611
|
+
ulong nb10,
|
|
612
|
+
ulong nb11,
|
|
613
|
+
ulong nb12,
|
|
614
|
+
int nblk0,
|
|
615
|
+
int ne1_dst,
|
|
616
|
+
int ne2_dst,
|
|
617
|
+
int ne3_dst
|
|
618
|
+
) {
|
|
619
|
+
src0 = src0 + offset0;
|
|
620
|
+
src1 = src1 + offset1;
|
|
621
|
+
dst_q = dst_q + offset_q;
|
|
622
|
+
dst_d = dst_d + offset_d;
|
|
623
|
+
|
|
624
|
+
int i03 = get_group_id(2);
|
|
625
|
+
int i02 = get_group_id(1);
|
|
626
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
627
|
+
|
|
628
|
+
if (i01 >= ne01) {
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
int i12 = fastmod(i03, ne12);
|
|
633
|
+
int i11 = fastmod(i02, ne11);
|
|
634
|
+
|
|
635
|
+
int i10 = i01;
|
|
636
|
+
long i1 = ((global long *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
637
|
+
|
|
638
|
+
long row_blk_base = ((long)i03 * ne2_dst * ne1_dst + (long)i02 * ne1_dst + i1) * nblk0;
|
|
639
|
+
|
|
640
|
+
global half * d_row = (global half *)(dst_d) + row_blk_base;
|
|
641
|
+
global uchar * q_row = (global uchar *)(dst_q) + row_blk_base * (QK4_0/2);
|
|
642
|
+
global float * src_row = (global float *)(src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
643
|
+
|
|
644
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
645
|
+
global float * x = src_row + blk * QK4_0;
|
|
646
|
+
global uchar * qs = q_row + blk * (QK4_0/2);
|
|
647
|
+
global half * d_bk = d_row + blk;
|
|
648
|
+
|
|
649
|
+
quantize_q4_0_block(x, qs, d_bk);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
kernel void kernel_set_rows_q4_0_soa_i32(
|
|
654
|
+
global char * src0,
|
|
655
|
+
ulong offset0,
|
|
656
|
+
global char * src1,
|
|
657
|
+
ulong offset1,
|
|
658
|
+
global char * dst_q,
|
|
659
|
+
ulong offset_q,
|
|
660
|
+
global char * dst_d,
|
|
661
|
+
ulong offset_d,
|
|
662
|
+
int ne01,
|
|
663
|
+
ulong nb01,
|
|
664
|
+
ulong nb02,
|
|
665
|
+
ulong nb03,
|
|
666
|
+
uint4 ne11,
|
|
667
|
+
uint4 ne12,
|
|
668
|
+
ulong nb10,
|
|
669
|
+
ulong nb11,
|
|
670
|
+
ulong nb12,
|
|
671
|
+
int nblk0,
|
|
672
|
+
int ne1_dst,
|
|
673
|
+
int ne2_dst,
|
|
674
|
+
int ne3_dst
|
|
675
|
+
) {
|
|
676
|
+
src0 = src0 + offset0;
|
|
677
|
+
src1 = src1 + offset1;
|
|
678
|
+
dst_q = dst_q + offset_q;
|
|
679
|
+
dst_d = dst_d + offset_d;
|
|
680
|
+
|
|
681
|
+
int i03 = get_group_id(2);
|
|
682
|
+
int i02 = get_group_id(1);
|
|
683
|
+
int i01 = get_group_id(0)*get_local_size(1) + get_local_id(1);
|
|
684
|
+
|
|
685
|
+
if (i01 >= ne01) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
int i12 = fastmod(i03, ne12);
|
|
690
|
+
int i11 = fastmod(i02, ne11);
|
|
691
|
+
|
|
692
|
+
int i10 = i01;
|
|
693
|
+
int i1 = ((global int *)(src1 + i10*nb10 + i11*nb11 + i12*nb12))[0];
|
|
694
|
+
|
|
695
|
+
long row_blk_base = ((long)i03 * ne2_dst * ne1_dst + (long)i02 * ne1_dst + i1) * nblk0;
|
|
696
|
+
|
|
697
|
+
global half * d_row = (global half *)(dst_d) + row_blk_base;
|
|
698
|
+
global uchar * q_row = (global uchar *)(dst_q) + row_blk_base * (QK4_0/2);
|
|
699
|
+
global float * src_row = (global float *)(src0 + i01*nb01 + i02*nb02 + i03*nb03);
|
|
700
|
+
|
|
701
|
+
for (int blk = get_local_id(0); blk < nblk0; blk += get_local_size(0)) {
|
|
702
|
+
global float * x = src_row + blk * QK4_0;
|
|
703
|
+
global uchar * qs = q_row + blk * (QK4_0/2);
|
|
704
|
+
global half * d_bk = d_row + blk;
|
|
705
|
+
|
|
706
|
+
quantize_q4_0_block(x, qs, d_bk);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifdef _WIN32
|
|
4
|
+
# define WIN32_LEAN_AND_MEAN
|
|
5
|
+
# ifndef NOMINMAX
|
|
6
|
+
# define NOMINMAX
|
|
7
|
+
# endif
|
|
8
|
+
# include <windows.h>
|
|
9
|
+
# include <winevt.h>
|
|
10
|
+
#else
|
|
11
|
+
# include <dlfcn.h>
|
|
12
|
+
# include <unistd.h>
|
|
13
|
+
#endif
|
|
14
|
+
#include <filesystem>
|
|
15
|
+
|
|
16
|
+
namespace fs = std::filesystem;
|
|
17
|
+
|
|
18
|
+
#ifdef _WIN32
|
|
19
|
+
|
|
20
|
+
using dl_handle = std::remove_pointer_t<HMODULE>;
|
|
21
|
+
|
|
22
|
+
struct dl_handle_deleter {
|
|
23
|
+
void operator()(HMODULE handle) {
|
|
24
|
+
FreeLibrary(handle);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static inline dl_handle * dl_load_library(const fs::path & path) {
|
|
29
|
+
// suppress error dialogs for missing DLLs
|
|
30
|
+
DWORD old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
|
31
|
+
SetErrorMode(old_mode | SEM_FAILCRITICALERRORS);
|
|
32
|
+
|
|
33
|
+
HMODULE handle = LoadLibraryW(path.wstring().c_str());
|
|
34
|
+
|
|
35
|
+
SetErrorMode(old_mode);
|
|
36
|
+
|
|
37
|
+
return handle;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static inline void * dl_get_sym(dl_handle * handle, const char * name) {
|
|
41
|
+
DWORD old_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
|
42
|
+
SetErrorMode(old_mode | SEM_FAILCRITICALERRORS);
|
|
43
|
+
|
|
44
|
+
void * p = (void *) GetProcAddress(handle, name);
|
|
45
|
+
|
|
46
|
+
SetErrorMode(old_mode);
|
|
47
|
+
|
|
48
|
+
return p;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static inline const char * dl_error() {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#else
|
|
56
|
+
|
|
57
|
+
using dl_handle = void;
|
|
58
|
+
|
|
59
|
+
struct dl_handle_deleter {
|
|
60
|
+
void operator()(void * handle) {
|
|
61
|
+
dlclose(handle);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
static inline dl_handle * dl_load_library(const fs::path & path) {
|
|
66
|
+
dl_handle * handle = dlopen(path.string().c_str(), RTLD_NOW | RTLD_LOCAL);
|
|
67
|
+
return handle;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static inline void * dl_get_sym(dl_handle * handle, const char * name) {
|
|
71
|
+
return dlsym(handle, name);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static inline const char * dl_error() {
|
|
75
|
+
const char *rslt = dlerror();
|
|
76
|
+
return rslt != nullptr ? rslt : "";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
#endif
|
|
@@ -2,12 +2,7 @@
|
|
|
2
2
|
# Override root .clang-format
|
|
3
3
|
AlignConsecutiveAssignments: false
|
|
4
4
|
AlignConsecutiveDeclarations: false
|
|
5
|
-
Cpp11BracedListStyle: true
|
|
6
|
-
SpacesInContainerLiterals: false
|
|
7
|
-
BreakBeforeBraces: Attach
|
|
8
5
|
AccessModifierOffset: -4
|
|
9
|
-
IndentCaseBlocks: false
|
|
10
|
-
IndentCaseLabels: false
|
|
11
6
|
|
|
12
7
|
Language: Cpp
|
|
13
8
|
AlignAfterOpenBracket: Align
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
find_package(OpenVINO REQUIRED)
|
|
1
|
+
find_package(OpenVINO REQUIRED COMPONENTS Runtime Threading)
|
|
2
2
|
find_package(OpenCL REQUIRED)
|
|
3
3
|
|
|
4
|
-
include("${OpenVINO_DIR}/../3rdparty/tbb/lib/cmake/TBB/TBBConfig.cmake")
|
|
5
|
-
|
|
6
4
|
file(GLOB_RECURSE GGML_HEADERS_OPENVINO "*.h" "*.hpp")
|
|
7
5
|
file(GLOB_RECURSE GGML_SOURCES_OPENVINO "*.cpp")
|
|
8
6
|
|
|
@@ -11,7 +9,7 @@ ggml_add_backend_library(ggml-openvino
|
|
|
11
9
|
${GGML_HEADERS_OPENVINO}
|
|
12
10
|
)
|
|
13
11
|
|
|
14
|
-
target_link_libraries(ggml-openvino PRIVATE openvino::runtime
|
|
12
|
+
target_link_libraries(ggml-openvino PRIVATE openvino::runtime openvino::threading OpenCL::OpenCL)
|
|
15
13
|
|
|
16
14
|
if (GGML_OPENVINO)
|
|
17
15
|
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
|