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
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
|
2
|
+
|
|
3
|
+
#ifdef cl_intel_subgroups
|
|
4
|
+
#pragma OPENCL EXTENSION cl_intel_subgroups : enable
|
|
5
|
+
#else
|
|
6
|
+
#pragma OPENCL EXTENSION cl_khr_subgroups : enable
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#ifdef cl_intel_required_subgroup_size
|
|
10
|
+
#pragma OPENCL EXTENSION cl_intel_required_subgroup_size : enable
|
|
11
|
+
#define INTEL_GPU 1
|
|
12
|
+
#define REQD_SUBGROUP_SIZE_16 __attribute__((intel_reqd_sub_group_size(16)))
|
|
13
|
+
#define REQD_SUBGROUP_SIZE_32 __attribute__((intel_reqd_sub_group_size(32)))
|
|
14
|
+
#elif defined(cl_qcom_reqd_sub_group_size)
|
|
15
|
+
#pragma OPENCL EXTENSION cl_qcom_reqd_sub_group_size : enable
|
|
16
|
+
#define ADRENO_GPU 1
|
|
17
|
+
#define REQD_SUBGROUP_SIZE_64 __attribute__((qcom_reqd_sub_group_size("half")))
|
|
18
|
+
#define REQD_SUBGROUP_SIZE_128 __attribute__((qcom_reqd_sub_group_size("full")))
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#define QK1_0 128
|
|
22
|
+
typedef struct {
|
|
23
|
+
half d;
|
|
24
|
+
uchar qs[QK1_0/8];
|
|
25
|
+
} block_q1_0;
|
|
26
|
+
|
|
27
|
+
#define NB_Q1_0 16
|
|
28
|
+
|
|
29
|
+
#ifdef INTEL_GPU
|
|
30
|
+
#define N_R0_Q1_0 4 // number of rows each subgroup works on
|
|
31
|
+
#define N_SG_Q1_0 2 // number of subgroups in a work group
|
|
32
|
+
#define N_SIMDWIDTH 16 // subgroup size
|
|
33
|
+
#elif defined (ADRENO_GPU)
|
|
34
|
+
#define N_R0_Q1_0 4
|
|
35
|
+
#define N_SG_Q1_0 2
|
|
36
|
+
#define N_SIMDWIDTH 64
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
inline float block_q_1_0_dot_y(global block_q1_0 * qb, float sumy, float yl[NB_Q1_0], short il) {
|
|
40
|
+
global uchar * qs = qb->qs + il*2;
|
|
41
|
+
uint b0 = qs[0];
|
|
42
|
+
uint b1 = qs[1];
|
|
43
|
+
|
|
44
|
+
float acc = 0.f;
|
|
45
|
+
acc += yl[ 0]*(float)((b0 >> 0) & 1) + yl[ 1]*(float)((b0 >> 1) & 1);
|
|
46
|
+
acc += yl[ 2]*(float)((b0 >> 2) & 1) + yl[ 3]*(float)((b0 >> 3) & 1);
|
|
47
|
+
acc += yl[ 4]*(float)((b0 >> 4) & 1) + yl[ 5]*(float)((b0 >> 5) & 1);
|
|
48
|
+
acc += yl[ 6]*(float)((b0 >> 6) & 1) + yl[ 7]*(float)((b0 >> 7) & 1);
|
|
49
|
+
|
|
50
|
+
acc += yl[ 8]*(float)((b1 >> 0) & 1) + yl[ 9]*(float)((b1 >> 1) & 1);
|
|
51
|
+
acc += yl[10]*(float)((b1 >> 2) & 1) + yl[11]*(float)((b1 >> 3) & 1);
|
|
52
|
+
acc += yl[12]*(float)((b1 >> 4) & 1) + yl[13]*(float)((b1 >> 5) & 1);
|
|
53
|
+
acc += yl[14]*(float)((b1 >> 6) & 1) + yl[15]*(float)((b1 >> 7) & 1);
|
|
54
|
+
|
|
55
|
+
return qb->d * (2.0f*acc - sumy);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#ifdef INTEL_GPU
|
|
59
|
+
REQD_SUBGROUP_SIZE_16
|
|
60
|
+
#elif defined (ADRENO_GPU)
|
|
61
|
+
REQD_SUBGROUP_SIZE_64
|
|
62
|
+
#endif
|
|
63
|
+
kernel void kernel_mul_mv_q1_0_f32(
|
|
64
|
+
global char * src0,
|
|
65
|
+
ulong offset0,
|
|
66
|
+
global char * src1,
|
|
67
|
+
ulong offset1,
|
|
68
|
+
global char * dst,
|
|
69
|
+
ulong offsetd,
|
|
70
|
+
int ne00,
|
|
71
|
+
int ne01,
|
|
72
|
+
ulong nb01,
|
|
73
|
+
ulong nb02,
|
|
74
|
+
ulong nb03,
|
|
75
|
+
int ne12,
|
|
76
|
+
ulong nb11,
|
|
77
|
+
ulong nb12,
|
|
78
|
+
ulong nb13,
|
|
79
|
+
int ne0,
|
|
80
|
+
int ne1,
|
|
81
|
+
int r2,
|
|
82
|
+
int r3
|
|
83
|
+
) {
|
|
84
|
+
src0 = (global char*)((global char*)src0 + offset0);
|
|
85
|
+
src1 = (global char*)((global char*)src1 + offset1);
|
|
86
|
+
dst = (global char*)((global char*)dst + offsetd);
|
|
87
|
+
|
|
88
|
+
int nb = ne00/QK1_0;
|
|
89
|
+
|
|
90
|
+
int r0 = get_group_id(0);
|
|
91
|
+
int r1 = get_group_id(1);
|
|
92
|
+
int im = get_group_id(2);
|
|
93
|
+
|
|
94
|
+
int first_row = (r0*N_SG_Q1_0 + get_sub_group_id()) * N_R0_Q1_0;
|
|
95
|
+
|
|
96
|
+
uint i12 = im%ne12;
|
|
97
|
+
uint i13 = im/ne12;
|
|
98
|
+
|
|
99
|
+
ulong offset_src1 = r1*nb11 + i12*nb12 + i13*nb13;
|
|
100
|
+
global float * y = (global float *) (src1 + offset_src1);
|
|
101
|
+
|
|
102
|
+
// pointers to src0 rows
|
|
103
|
+
global block_q1_0 * ax[N_R0_Q1_0];
|
|
104
|
+
for (int row = 0; row < N_R0_Q1_0; ++row) {
|
|
105
|
+
ulong offset_src0 = (first_row + row)*nb01 + (i12/r2)*nb02 + (i13/r3)*nb03;
|
|
106
|
+
ax[row] = (global block_q1_0 *) ((global char *) src0 + offset_src0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
float yl[NB_Q1_0];
|
|
110
|
+
float sumf[N_R0_Q1_0] = { 0.f };
|
|
111
|
+
|
|
112
|
+
const short ix = get_sub_group_local_id()/8;
|
|
113
|
+
const short il = get_sub_group_local_id()%8;
|
|
114
|
+
|
|
115
|
+
global float * yb = y + ix*QK1_0 + il*NB_Q1_0;
|
|
116
|
+
|
|
117
|
+
// each thread handles NB_Q1_0 quants at a time
|
|
118
|
+
for (int ib = ix; ib < nb; ib += N_SIMDWIDTH/8) {
|
|
119
|
+
float sumy = 0.f;
|
|
120
|
+
for (short i = 0; i < NB_Q1_0; ++i) {
|
|
121
|
+
yl[i] = yb[i];
|
|
122
|
+
sumy += yb[i];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
for (short row = 0; row < N_R0_Q1_0; row++) {
|
|
126
|
+
sumf[row] += block_q_1_0_dot_y(ax[row] + ib, sumy, yl, il);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
yb += N_SIMDWIDTH*NB_Q1_0;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
global float * dst_f32 = (global float *) dst + (ulong)im*ne0*ne1 + (ulong)r1*ne0;
|
|
133
|
+
|
|
134
|
+
for (int row = 0; row < N_R0_Q1_0; ++row) {
|
|
135
|
+
float tot = sub_group_reduce_add(sumf[row]);
|
|
136
|
+
|
|
137
|
+
if (get_sub_group_local_id() == 0 && first_row + row < ne01) {
|
|
138
|
+
dst_f32[first_row + row] = tot;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#pragma OPENCL EXTENSION cl_khr_fp16 : enable
|
|
2
|
+
|
|
3
|
+
#ifdef cl_intel_subgroups
|
|
4
|
+
#pragma OPENCL EXTENSION cl_intel_subgroups : enable
|
|
5
|
+
#else
|
|
6
|
+
#pragma OPENCL EXTENSION cl_khr_subgroups : enable
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
#ifdef cl_intel_required_subgroup_size
|
|
10
|
+
#pragma OPENCL EXTENSION cl_intel_required_subgroup_size : enable
|
|
11
|
+
#define INTEL_GPU 1
|
|
12
|
+
#define REQD_SUBGROUP_SIZE_16 __attribute__((intel_reqd_sub_group_size(16)))
|
|
13
|
+
#define REQD_SUBGROUP_SIZE_32 __attribute__((intel_reqd_sub_group_size(32)))
|
|
14
|
+
#elif defined(cl_qcom_reqd_sub_group_size)
|
|
15
|
+
#pragma OPENCL EXTENSION cl_qcom_reqd_sub_group_size : enable
|
|
16
|
+
#define ADRENO_GPU 1
|
|
17
|
+
#define REQD_SUBGROUP_SIZE_64 __attribute__((qcom_reqd_sub_group_size("half")))
|
|
18
|
+
#define REQD_SUBGROUP_SIZE_128 __attribute__((qcom_reqd_sub_group_size("full")))
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#define QK1_0 128
|
|
22
|
+
#define QK1_0_BYTES (QK1_0/8) // 16 quant bytes per block
|
|
23
|
+
#define QK1_0_BLK_BYTES (QK1_0_BYTES + 2) // d + qs in original tensor = 18
|
|
24
|
+
|
|
25
|
+
#define NB_Q1_0 16 // quants handled per thread (two qs bytes)
|
|
26
|
+
|
|
27
|
+
#ifdef INTEL_GPU
|
|
28
|
+
#define N_R0_Q1_0 4 // number of rows each subgroup works on
|
|
29
|
+
#define N_SG_Q1_0 2 // number of subgroups in a work group
|
|
30
|
+
#define N_SIMDWIDTH 16 // subgroup size
|
|
31
|
+
#elif defined (ADRENO_GPU)
|
|
32
|
+
#define N_R0_Q1_0 4
|
|
33
|
+
#define N_SG_Q1_0 2
|
|
34
|
+
#define N_SIMDWIDTH 64
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
#ifdef INTEL_GPU
|
|
38
|
+
REQD_SUBGROUP_SIZE_16
|
|
39
|
+
#elif defined (ADRENO_GPU)
|
|
40
|
+
REQD_SUBGROUP_SIZE_64
|
|
41
|
+
#endif
|
|
42
|
+
kernel void kernel_mul_mv_q1_0_f32_flat(
|
|
43
|
+
global char * src0_q,
|
|
44
|
+
global half * src0_d,
|
|
45
|
+
global char * src1,
|
|
46
|
+
ulong offset1,
|
|
47
|
+
global char * dst,
|
|
48
|
+
ulong offsetd,
|
|
49
|
+
int ne00,
|
|
50
|
+
int ne01,
|
|
51
|
+
ulong nb01,
|
|
52
|
+
ulong nb02,
|
|
53
|
+
ulong nb03,
|
|
54
|
+
int ne12,
|
|
55
|
+
ulong nb11,
|
|
56
|
+
ulong nb12,
|
|
57
|
+
ulong nb13,
|
|
58
|
+
int ne0,
|
|
59
|
+
int ne1,
|
|
60
|
+
int r2,
|
|
61
|
+
int r3
|
|
62
|
+
) {
|
|
63
|
+
src1 = (global char*)((global char*)src1 + offset1);
|
|
64
|
+
dst = (global char*)((global char*)dst + offsetd);
|
|
65
|
+
|
|
66
|
+
int nb = ne00/QK1_0;
|
|
67
|
+
|
|
68
|
+
int r0 = get_group_id(0);
|
|
69
|
+
int r1 = get_group_id(1);
|
|
70
|
+
int im = get_group_id(2);
|
|
71
|
+
|
|
72
|
+
int first_row = (r0*N_SG_Q1_0 + get_sub_group_id()) * N_R0_Q1_0;
|
|
73
|
+
|
|
74
|
+
uint i12 = im%ne12;
|
|
75
|
+
uint i13 = im/ne12;
|
|
76
|
+
|
|
77
|
+
ulong offset_src1 = r1*nb11 + i12*nb12 + i13*nb13;
|
|
78
|
+
global float * y = (global float *) (src1 + offset_src1);
|
|
79
|
+
|
|
80
|
+
// pointers to src0 rows (flat: q bytes + scales)
|
|
81
|
+
uint offset_src0_base = first_row*nb01 + (i12/r2)*nb02 + (i13/r3)*nb03;
|
|
82
|
+
|
|
83
|
+
global uchar * ax0, * ax1, * ax2, * ax3;
|
|
84
|
+
global half * ad0, * ad1, * ad2, * ad3;
|
|
85
|
+
uint offset_src0;
|
|
86
|
+
|
|
87
|
+
offset_src0 = (offset_src0_base + 0*nb01) / QK1_0_BLK_BYTES;
|
|
88
|
+
ax0 = (global uchar *) ((global char *) src0_q + offset_src0*QK1_0_BYTES);
|
|
89
|
+
ad0 = (global half *) ((global char *) src0_d + offset_src0*sizeof(half));
|
|
90
|
+
|
|
91
|
+
offset_src0 = (offset_src0_base + 1*nb01) / QK1_0_BLK_BYTES;
|
|
92
|
+
ax1 = (global uchar *) ((global char *) src0_q + offset_src0*QK1_0_BYTES);
|
|
93
|
+
ad1 = (global half *) ((global char *) src0_d + offset_src0*sizeof(half));
|
|
94
|
+
|
|
95
|
+
offset_src0 = (offset_src0_base + 2*nb01) / QK1_0_BLK_BYTES;
|
|
96
|
+
ax2 = (global uchar *) ((global char *) src0_q + offset_src0*QK1_0_BYTES);
|
|
97
|
+
ad2 = (global half *) ((global char *) src0_d + offset_src0*sizeof(half));
|
|
98
|
+
|
|
99
|
+
offset_src0 = (offset_src0_base + 3*nb01) / QK1_0_BLK_BYTES;
|
|
100
|
+
ax3 = (global uchar *) ((global char *) src0_q + offset_src0*QK1_0_BYTES);
|
|
101
|
+
ad3 = (global half *) ((global char *) src0_d + offset_src0*sizeof(half));
|
|
102
|
+
|
|
103
|
+
const short ix = get_sub_group_local_id()/8;
|
|
104
|
+
const short il = get_sub_group_local_id()%8;
|
|
105
|
+
|
|
106
|
+
global float * yb = y + ix*QK1_0 + il*NB_Q1_0;
|
|
107
|
+
|
|
108
|
+
float8 yl_lo;
|
|
109
|
+
float8 yl_hi;
|
|
110
|
+
float4 sumf = 0.f;
|
|
111
|
+
|
|
112
|
+
// each thread handles NB_Q1_0 = 16 quants (two qs bytes) at a time
|
|
113
|
+
for (int ib = ix; ib < nb; ib += N_SIMDWIDTH/8) {
|
|
114
|
+
yl_lo = vload8(0, yb);
|
|
115
|
+
yl_hi = vload8(0, yb + 8);
|
|
116
|
+
float sumy = yl_lo.s0 + yl_lo.s1 + yl_lo.s2 + yl_lo.s3
|
|
117
|
+
+ yl_lo.s4 + yl_lo.s5 + yl_lo.s6 + yl_lo.s7
|
|
118
|
+
+ yl_hi.s0 + yl_hi.s1 + yl_hi.s2 + yl_hi.s3
|
|
119
|
+
+ yl_hi.s4 + yl_hi.s5 + yl_hi.s6 + yl_hi.s7;
|
|
120
|
+
|
|
121
|
+
uint b0, b1;
|
|
122
|
+
float acc;
|
|
123
|
+
|
|
124
|
+
b0 = ax0[ib*QK1_0_BYTES + il*2 + 0];
|
|
125
|
+
b1 = ax0[ib*QK1_0_BYTES + il*2 + 1];
|
|
126
|
+
acc = yl_lo.s0*(float)((b0 >> 0) & 1) + yl_lo.s1*(float)((b0 >> 1) & 1)
|
|
127
|
+
+ yl_lo.s2*(float)((b0 >> 2) & 1) + yl_lo.s3*(float)((b0 >> 3) & 1)
|
|
128
|
+
+ yl_lo.s4*(float)((b0 >> 4) & 1) + yl_lo.s5*(float)((b0 >> 5) & 1)
|
|
129
|
+
+ yl_lo.s6*(float)((b0 >> 6) & 1) + yl_lo.s7*(float)((b0 >> 7) & 1)
|
|
130
|
+
+ yl_hi.s0*(float)((b1 >> 0) & 1) + yl_hi.s1*(float)((b1 >> 1) & 1)
|
|
131
|
+
+ yl_hi.s2*(float)((b1 >> 2) & 1) + yl_hi.s3*(float)((b1 >> 3) & 1)
|
|
132
|
+
+ yl_hi.s4*(float)((b1 >> 4) & 1) + yl_hi.s5*(float)((b1 >> 5) & 1)
|
|
133
|
+
+ yl_hi.s6*(float)((b1 >> 6) & 1) + yl_hi.s7*(float)((b1 >> 7) & 1);
|
|
134
|
+
sumf.s0 += (float)ad0[ib] * (2.0f*acc - sumy);
|
|
135
|
+
|
|
136
|
+
b0 = ax1[ib*QK1_0_BYTES + il*2 + 0];
|
|
137
|
+
b1 = ax1[ib*QK1_0_BYTES + il*2 + 1];
|
|
138
|
+
acc = yl_lo.s0*(float)((b0 >> 0) & 1) + yl_lo.s1*(float)((b0 >> 1) & 1)
|
|
139
|
+
+ yl_lo.s2*(float)((b0 >> 2) & 1) + yl_lo.s3*(float)((b0 >> 3) & 1)
|
|
140
|
+
+ yl_lo.s4*(float)((b0 >> 4) & 1) + yl_lo.s5*(float)((b0 >> 5) & 1)
|
|
141
|
+
+ yl_lo.s6*(float)((b0 >> 6) & 1) + yl_lo.s7*(float)((b0 >> 7) & 1)
|
|
142
|
+
+ yl_hi.s0*(float)((b1 >> 0) & 1) + yl_hi.s1*(float)((b1 >> 1) & 1)
|
|
143
|
+
+ yl_hi.s2*(float)((b1 >> 2) & 1) + yl_hi.s3*(float)((b1 >> 3) & 1)
|
|
144
|
+
+ yl_hi.s4*(float)((b1 >> 4) & 1) + yl_hi.s5*(float)((b1 >> 5) & 1)
|
|
145
|
+
+ yl_hi.s6*(float)((b1 >> 6) & 1) + yl_hi.s7*(float)((b1 >> 7) & 1);
|
|
146
|
+
sumf.s1 += (float)ad1[ib] * (2.0f*acc - sumy);
|
|
147
|
+
|
|
148
|
+
b0 = ax2[ib*QK1_0_BYTES + il*2 + 0];
|
|
149
|
+
b1 = ax2[ib*QK1_0_BYTES + il*2 + 1];
|
|
150
|
+
acc = yl_lo.s0*(float)((b0 >> 0) & 1) + yl_lo.s1*(float)((b0 >> 1) & 1)
|
|
151
|
+
+ yl_lo.s2*(float)((b0 >> 2) & 1) + yl_lo.s3*(float)((b0 >> 3) & 1)
|
|
152
|
+
+ yl_lo.s4*(float)((b0 >> 4) & 1) + yl_lo.s5*(float)((b0 >> 5) & 1)
|
|
153
|
+
+ yl_lo.s6*(float)((b0 >> 6) & 1) + yl_lo.s7*(float)((b0 >> 7) & 1)
|
|
154
|
+
+ yl_hi.s0*(float)((b1 >> 0) & 1) + yl_hi.s1*(float)((b1 >> 1) & 1)
|
|
155
|
+
+ yl_hi.s2*(float)((b1 >> 2) & 1) + yl_hi.s3*(float)((b1 >> 3) & 1)
|
|
156
|
+
+ yl_hi.s4*(float)((b1 >> 4) & 1) + yl_hi.s5*(float)((b1 >> 5) & 1)
|
|
157
|
+
+ yl_hi.s6*(float)((b1 >> 6) & 1) + yl_hi.s7*(float)((b1 >> 7) & 1);
|
|
158
|
+
sumf.s2 += (float)ad2[ib] * (2.0f*acc - sumy);
|
|
159
|
+
|
|
160
|
+
b0 = ax3[ib*QK1_0_BYTES + il*2 + 0];
|
|
161
|
+
b1 = ax3[ib*QK1_0_BYTES + il*2 + 1];
|
|
162
|
+
acc = yl_lo.s0*(float)((b0 >> 0) & 1) + yl_lo.s1*(float)((b0 >> 1) & 1)
|
|
163
|
+
+ yl_lo.s2*(float)((b0 >> 2) & 1) + yl_lo.s3*(float)((b0 >> 3) & 1)
|
|
164
|
+
+ yl_lo.s4*(float)((b0 >> 4) & 1) + yl_lo.s5*(float)((b0 >> 5) & 1)
|
|
165
|
+
+ yl_lo.s6*(float)((b0 >> 6) & 1) + yl_lo.s7*(float)((b0 >> 7) & 1)
|
|
166
|
+
+ yl_hi.s0*(float)((b1 >> 0) & 1) + yl_hi.s1*(float)((b1 >> 1) & 1)
|
|
167
|
+
+ yl_hi.s2*(float)((b1 >> 2) & 1) + yl_hi.s3*(float)((b1 >> 3) & 1)
|
|
168
|
+
+ yl_hi.s4*(float)((b1 >> 4) & 1) + yl_hi.s5*(float)((b1 >> 5) & 1)
|
|
169
|
+
+ yl_hi.s6*(float)((b1 >> 6) & 1) + yl_hi.s7*(float)((b1 >> 7) & 1);
|
|
170
|
+
sumf.s3 += (float)ad3[ib] * (2.0f*acc - sumy);
|
|
171
|
+
|
|
172
|
+
yb += N_SIMDWIDTH*NB_Q1_0;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
global float * dst_f32 = (global float *) dst + (ulong)im*ne0*ne1 + (ulong)r1*ne0;
|
|
176
|
+
|
|
177
|
+
float4 tot = (float4)(
|
|
178
|
+
sub_group_reduce_add(sumf.s0),
|
|
179
|
+
sub_group_reduce_add(sumf.s1),
|
|
180
|
+
sub_group_reduce_add(sumf.s2),
|
|
181
|
+
sub_group_reduce_add(sumf.s3)
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
if (get_sub_group_local_id() == 0) {
|
|
185
|
+
if (first_row + 0 < ne01) dst_f32[first_row + 0] = tot.s0;
|
|
186
|
+
if (first_row + 1 < ne01) dst_f32[first_row + 1] = tot.s1;
|
|
187
|
+
if (first_row + 2 < ne01) dst_f32[first_row + 2] = tot.s2;
|
|
188
|
+
if (first_row + 3 < ne01) dst_f32[first_row + 3] = tot.s3;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -24,6 +24,7 @@ kernel void kernel_norm(
|
|
|
24
24
|
int ne01,
|
|
25
25
|
int ne02,
|
|
26
26
|
int ne03,
|
|
27
|
+
ulong nb00,
|
|
27
28
|
ulong nb01,
|
|
28
29
|
ulong nb02,
|
|
29
30
|
ulong nb03,
|
|
@@ -43,7 +44,8 @@ kernel void kernel_norm(
|
|
|
43
44
|
// parallel sum
|
|
44
45
|
sum[get_local_id(0)] = 0.0f;
|
|
45
46
|
for (int i00 = get_local_id(0); i00 < ne00; i00 += get_local_size(0)) {
|
|
46
|
-
|
|
47
|
+
// this kernel handles float, nb00/4 translates byte offset to element offset
|
|
48
|
+
sum[get_local_id(0)] += x[i00*nb00/4];
|
|
47
49
|
}
|
|
48
50
|
// reduce
|
|
49
51
|
barrier(CLK_LOCAL_MEM_FENCE);
|
|
@@ -60,7 +62,8 @@ kernel void kernel_norm(
|
|
|
60
62
|
global float * y = dst + i03*ne02*ne01*ne00 + i02*ne01*ne00 + i01*ne00;
|
|
61
63
|
sum[get_local_id(0)] = 0.0f;
|
|
62
64
|
for (int i00 = get_local_id(0); i00 < ne00; i00 += get_local_size(0)) {
|
|
63
|
-
|
|
65
|
+
// this kernel handles float, nb00/4 translates byte offset to element offset
|
|
66
|
+
y[i00] = x[i00*nb00/4] - mean;
|
|
64
67
|
sum[get_local_id(0)] += y[i00] * y[i00];
|
|
65
68
|
}
|
|
66
69
|
|