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
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
#include <qurt_thread.h>
|
|
8
8
|
#include <qurt_futex.h>
|
|
9
|
+
#include <qurt_hvx.h>
|
|
9
10
|
|
|
10
11
|
#include <HAP_compute_res.h>
|
|
11
12
|
|
|
@@ -42,9 +43,12 @@ static inline void hmx_queue_process(struct hmx_queue *q, bool* killed) {
|
|
|
42
43
|
case HMX_QUEUE_NOOP: /* noop */; break;
|
|
43
44
|
case HMX_QUEUE_KILL: *killed = true; break;
|
|
44
45
|
case HMX_QUEUE_SUSPEND: hmx_unlock(q); break;
|
|
46
|
+
case HMX_QUEUE_WAKEUP: hmx_lock(q); break;
|
|
45
47
|
default:
|
|
46
48
|
hmx_lock(q);
|
|
49
|
+
htp_trace_event_start(q->trace, HTP_TRACE_EVT_HMX_COMP, ir);
|
|
47
50
|
d->func(d->data);
|
|
51
|
+
htp_trace_event_stop(q->trace, HTP_TRACE_EVT_HMX_COMP, ir);
|
|
48
52
|
break;
|
|
49
53
|
}
|
|
50
54
|
|
|
@@ -68,9 +72,14 @@ static void hmx_queue_thread(void * arg) {
|
|
|
68
72
|
while (!killed) {
|
|
69
73
|
unsigned int seqn = atomic_load(&q->seqn);
|
|
70
74
|
if (seqn == prev_seqn) {
|
|
75
|
+
// drop HVX context while spinning
|
|
76
|
+
if (poll_cnt > 1 && poll_cnt == HMX_QUEUE_POLL_COUNT) {
|
|
77
|
+
qurt_hvx_unlock();
|
|
78
|
+
}
|
|
71
79
|
if (--poll_cnt) { hex_pause(); continue; }
|
|
72
80
|
FARF(HIGH, "hmx-queue-thread: sleeping");
|
|
73
81
|
qurt_futex_wait(&q->seqn, prev_seqn);
|
|
82
|
+
poll_cnt = HMX_QUEUE_POLL_COUNT;
|
|
74
83
|
continue;
|
|
75
84
|
}
|
|
76
85
|
prev_seqn = seqn;
|
|
@@ -11,19 +11,26 @@
|
|
|
11
11
|
#include <HAP_farf.h>
|
|
12
12
|
|
|
13
13
|
#include "hex-utils.h"
|
|
14
|
+
#include "hex-profile.h"
|
|
14
15
|
|
|
15
16
|
#ifdef __cplusplus
|
|
16
17
|
extern "C" {
|
|
17
18
|
#endif
|
|
18
19
|
|
|
19
20
|
#define HMX_QUEUE_THREAD_STACK_SIZE (16 * 1024)
|
|
20
|
-
|
|
21
|
+
|
|
22
|
+
#if __HVX_ARCH__ > 79
|
|
23
|
+
#define HMX_QUEUE_POLL_COUNT 2000
|
|
24
|
+
#else
|
|
25
|
+
#define HMX_QUEUE_POLL_COUNT 1
|
|
26
|
+
#endif
|
|
21
27
|
|
|
22
28
|
typedef void (*hmx_queue_func)(void *);
|
|
23
29
|
|
|
24
30
|
// Dummy funcs used as signals
|
|
25
31
|
enum hmx_queue_signal {
|
|
26
32
|
HMX_QUEUE_NOOP = 0, // aka NULL
|
|
33
|
+
HMX_QUEUE_WAKEUP,
|
|
27
34
|
HMX_QUEUE_SUSPEND,
|
|
28
35
|
HMX_QUEUE_KILL
|
|
29
36
|
};
|
|
@@ -47,6 +54,7 @@ struct hmx_queue {
|
|
|
47
54
|
void * stack;
|
|
48
55
|
uint32_t hap_rctx;
|
|
49
56
|
bool hmx_locked;
|
|
57
|
+
struct htp_thread_trace * trace;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
60
|
struct hmx_queue * hmx_queue_create(size_t capacity, uint32_t hap_rctx);
|
|
@@ -95,7 +103,7 @@ static inline uint32_t hmx_queue_capacity(struct hmx_queue * q) {
|
|
|
95
103
|
return q->capacity;
|
|
96
104
|
}
|
|
97
105
|
|
|
98
|
-
static inline struct hmx_queue_desc
|
|
106
|
+
static inline struct hmx_queue_desc hmx_queue_pop_one(struct hmx_queue * q) {
|
|
99
107
|
unsigned int ip = q->idx_pop;
|
|
100
108
|
unsigned int iw = q->idx_write;
|
|
101
109
|
|
|
@@ -118,13 +126,28 @@ static inline struct hmx_queue_desc hmx_queue_pop(struct hmx_queue * q) {
|
|
|
118
126
|
return rd;
|
|
119
127
|
}
|
|
120
128
|
|
|
129
|
+
static inline struct hmx_queue_desc hmx_queue_pop(struct hmx_queue * q) {
|
|
130
|
+
while (1) {
|
|
131
|
+
struct hmx_queue_desc d = hmx_queue_pop_one(q);
|
|
132
|
+
|
|
133
|
+
uint32_t sig = (uint32_t) d.func;
|
|
134
|
+
if (sig && sig <= HMX_QUEUE_KILL)
|
|
135
|
+
continue;
|
|
136
|
+
|
|
137
|
+
return d;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
121
141
|
static inline void hmx_queue_flush(struct hmx_queue * q) {
|
|
122
|
-
while (
|
|
142
|
+
while (hmx_queue_pop_one(q).func != NULL) ;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static inline void hmx_queue_wakeup(struct hmx_queue * q) {
|
|
146
|
+
hmx_queue_signal(q, HMX_QUEUE_WAKEUP);
|
|
123
147
|
}
|
|
124
148
|
|
|
125
149
|
static inline void hmx_queue_suspend(struct hmx_queue *q) {
|
|
126
150
|
hmx_queue_signal(q, HMX_QUEUE_SUSPEND);
|
|
127
|
-
hmx_queue_flush(q);
|
|
128
151
|
}
|
|
129
152
|
|
|
130
153
|
#ifdef __cplusplus
|
|
@@ -42,14 +42,14 @@ static const int32_t hmx_transpose_scatter_offsets[32] __attribute__((aligned(VL
|
|
|
42
42
|
// Full range: start_row=0, end_row=n_cols.
|
|
43
43
|
static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
44
44
|
const __fp16 * restrict vtcm_src,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
uint32_t n_cols,
|
|
46
|
+
uint32_t k,
|
|
47
|
+
size_t src_stride,
|
|
48
|
+
uint32_t start_row,
|
|
49
|
+
uint32_t end_row) {
|
|
50
50
|
assert(k % HMX_FP16_TILE_N_COLS == 0);
|
|
51
51
|
|
|
52
|
-
const
|
|
52
|
+
const uint32_t n_k_tiles = k / HMX_FP16_TILE_N_COLS;
|
|
53
53
|
const HVX_Vector v_scat_base = hvx_vmem(hmx_transpose_scatter_offsets);
|
|
54
54
|
const HVX_Vector v_scat_step = Q6_V_vsplat_R(4);
|
|
55
55
|
const HVX_VectorPred q_mask64 = Q6_Q_vsetq_R(64);
|
|
@@ -65,14 +65,14 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
65
65
|
|
|
66
66
|
if (pair_scatter) {
|
|
67
67
|
// Step c by 64 fp16 (two K-tiles per scatter), advance dst by 2 tiles per iter.
|
|
68
|
-
const
|
|
69
|
-
const size_t
|
|
70
|
-
const size_t
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
for (
|
|
74
|
-
const
|
|
75
|
-
const
|
|
68
|
+
const uint32_t c_step = 2 * HMX_FP16_TILE_N_COLS;
|
|
69
|
+
const size_t c_byte_step = (size_t) c_step * sizeof(__fp16);
|
|
70
|
+
const size_t dst_step = 2 * (size_t) HMX_FP16_TILE_N_ELMS;
|
|
71
|
+
const uint32_t n_c_iters = k / c_step;
|
|
72
|
+
|
|
73
|
+
for (uint32_t r = start_row; r < end_row; r += 2) {
|
|
74
|
+
const uint32_t ct = r / HMX_FP16_TILE_N_ROWS;
|
|
75
|
+
const uint32_t local_r = r % HMX_FP16_TILE_N_ROWS;
|
|
76
76
|
const bool next_row_valid = (r + 1) < end_row && (r + 1) < n_cols;
|
|
77
77
|
const HVX_Vector v_off0 = Q6_Vw_vadd_VwVw(v_scat_base, Q6_V_vsplat_R(local_r * 4));
|
|
78
78
|
const HVX_Vector v_off1 = Q6_Vw_vadd_VwVw(v_off0, v_scat_step);
|
|
@@ -86,7 +86,7 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
86
86
|
assert(c_byte_step % 128 == 0);
|
|
87
87
|
|
|
88
88
|
if (p1) {
|
|
89
|
-
for (
|
|
89
|
+
for (uint32_t i = 0; i < n_c_iters; ++i) {
|
|
90
90
|
HVX_Vector v0 = hvx_vmem(p0); p0 += c_byte_step;
|
|
91
91
|
HVX_Vector v1 = hvx_vmem(p1); p1 += c_byte_step;
|
|
92
92
|
Q6_vscatter_RMVwV((size_t) tile_base, pair_region, v_off0, v0);
|
|
@@ -95,7 +95,7 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
95
95
|
}
|
|
96
96
|
} else {
|
|
97
97
|
const HVX_Vector vzero = Q6_V_vzero();
|
|
98
|
-
for (
|
|
98
|
+
for (uint32_t i = 0; i < n_c_iters; ++i) {
|
|
99
99
|
HVX_Vector v0 = hvx_vmem(p0); p0 += c_byte_step;
|
|
100
100
|
Q6_vscatter_RMVwV((size_t) tile_base, pair_region, v_off0, v0);
|
|
101
101
|
Q6_vscatter_RMVwV((size_t) tile_base, pair_region, v_off1, vzero);
|
|
@@ -105,14 +105,14 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
105
105
|
}
|
|
106
106
|
} else {
|
|
107
107
|
// Fallback: scatter one K-tile per call (region 2047, masked).
|
|
108
|
-
const
|
|
109
|
-
const size_t
|
|
110
|
-
const size_t
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
for (
|
|
114
|
-
const
|
|
115
|
-
const
|
|
108
|
+
const uint32_t c_step = HMX_FP16_TILE_N_COLS;
|
|
109
|
+
const size_t c_byte_step = (size_t) c_step * sizeof(__fp16);
|
|
110
|
+
const size_t dst_step = (size_t) HMX_FP16_TILE_N_ELMS;
|
|
111
|
+
const uint32_t n_c_iters = k / c_step;
|
|
112
|
+
|
|
113
|
+
for (uint32_t r = start_row; r < end_row; r += 2) {
|
|
114
|
+
const uint32_t ct = r / HMX_FP16_TILE_N_ROWS;
|
|
115
|
+
const uint32_t local_r = r % HMX_FP16_TILE_N_ROWS;
|
|
116
116
|
const bool next_row_valid = (r + 1) < end_row && (r + 1) < n_cols;
|
|
117
117
|
const HVX_Vector v_off0 = Q6_Vw_vadd_VwVw(v_scat_base, Q6_V_vsplat_R(local_r * 4));
|
|
118
118
|
const HVX_Vector v_off1 = Q6_Vw_vadd_VwVw(v_off0, v_scat_step);
|
|
@@ -122,7 +122,7 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
122
122
|
const uint8_t * p1 = next_row_valid ? (const uint8_t *) (vtcm_src + (r + 1) * src_stride) : NULL;
|
|
123
123
|
|
|
124
124
|
if (p1) {
|
|
125
|
-
for (
|
|
125
|
+
for (uint32_t i = 0; i < n_c_iters; ++i) {
|
|
126
126
|
HVX_Vector v0 = hvx_vmemu(p0); p0 += c_byte_step;
|
|
127
127
|
HVX_Vector v1 = hvx_vmemu(p1); p1 += c_byte_step;
|
|
128
128
|
Q6_vscatter_QRMVwV(q_mask64, (size_t) tile_base, single_region, v_off0, v0);
|
|
@@ -131,7 +131,7 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
131
131
|
}
|
|
132
132
|
} else {
|
|
133
133
|
const HVX_Vector vzero = Q6_V_vzero();
|
|
134
|
-
for (
|
|
134
|
+
for (uint32_t i = 0; i < n_c_iters; ++i) {
|
|
135
135
|
HVX_Vector v0 = hvx_vmemu(p0); p0 += c_byte_step;
|
|
136
136
|
Q6_vscatter_QRMVwV(q_mask64, (size_t) tile_base, single_region, v_off0, v0);
|
|
137
137
|
Q6_vscatter_QRMVwV(q_mask64, (size_t) tile_base, single_region, v_off1, vzero);
|
|
@@ -148,24 +148,24 @@ static inline void hmx_interleave_rows_to_tiles(__fp16 * restrict vtcm_dst,
|
|
|
148
148
|
// Full range: start_row=0, end_row=n_rows.
|
|
149
149
|
static inline void hmx_interleave_cols_to_tiles(__fp16 * restrict tiles_out,
|
|
150
150
|
const __fp16 * restrict src,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
uint32_t n_rows,
|
|
152
|
+
uint32_t head_dim,
|
|
153
|
+
size_t src_stride,
|
|
154
|
+
uint32_t n_row_tiles,
|
|
155
|
+
uint32_t start_row,
|
|
156
|
+
uint32_t end_row) {
|
|
157
157
|
__builtin_assume(head_dim > 0);
|
|
158
158
|
const size_t tile_stride_elms = (size_t) n_row_tiles * HMX_FP16_TILE_N_ELMS;
|
|
159
159
|
|
|
160
|
-
for (
|
|
160
|
+
for (uint32_t r = start_row; r < end_row; r += 2) {
|
|
161
161
|
const bool next_row_valid = (r + 1) < end_row && (r + 1) < n_rows;
|
|
162
162
|
|
|
163
163
|
const HVX_Vector * pv_in0 = (const HVX_Vector *) (src + r * src_stride);
|
|
164
164
|
const HVX_Vector * pv_in1 = next_row_valid ? (const HVX_Vector *) (src + (r + 1) * src_stride) : NULL;
|
|
165
165
|
|
|
166
166
|
// Row-pair invariants hoisted out of the c loop.
|
|
167
|
-
const
|
|
168
|
-
const
|
|
167
|
+
const uint32_t r0 = r / HMX_FP16_TILE_N_ROWS;
|
|
168
|
+
const uint32_t r1_half = (r % HMX_FP16_TILE_N_ROWS) / 2;
|
|
169
169
|
|
|
170
170
|
// tb0 starts at tile (c0=0, r0); tb1 at the adjacent dim-tile (c0=1, r0).
|
|
171
171
|
// Each c step (+= 64) advances both by 2 dim-tiles worth of fp16.
|
|
@@ -174,7 +174,7 @@ static inline void hmx_interleave_cols_to_tiles(__fp16 * restrict tiles_out,
|
|
|
174
174
|
const size_t tb_step = 2 * tile_stride_elms;
|
|
175
175
|
|
|
176
176
|
if (pv_in1) {
|
|
177
|
-
for (
|
|
177
|
+
for (uint32_t c = 0; c < head_dim; c += 64) {
|
|
178
178
|
HVX_Vector v0 = *pv_in0++;
|
|
179
179
|
HVX_Vector v1 = *pv_in1++;
|
|
180
180
|
HVX_VectorPair vp = Q6_W_vshuff_VVR(v1, v0, -2);
|
|
@@ -185,7 +185,7 @@ static inline void hmx_interleave_cols_to_tiles(__fp16 * restrict tiles_out,
|
|
|
185
185
|
}
|
|
186
186
|
} else {
|
|
187
187
|
const HVX_Vector vzero = Q6_V_vzero();
|
|
188
|
-
for (
|
|
188
|
+
for (uint32_t c = 0; c < head_dim; c += 64) {
|
|
189
189
|
HVX_Vector v0 = *pv_in0++;
|
|
190
190
|
HVX_VectorPair vp = Q6_W_vshuff_VVR(vzero, v0, -2);
|
|
191
191
|
((HVX_Vector *) tb0)[r1_half] = Q6_V_lo_W(vp);
|
|
@@ -197,4 +197,26 @@ static inline void hmx_interleave_cols_to_tiles(__fp16 * restrict tiles_out,
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
// --- HMX inline asm macros for load-store packetization ---
|
|
201
|
+
#define HMX_LOAD_MPY_F16(act, wt, range) \
|
|
202
|
+
"{\n" \
|
|
203
|
+
" activation.hf = mxmem(" act ", " range ")\n" \
|
|
204
|
+
" weight.hf = mxmem(" wt ", " range ")\n" \
|
|
205
|
+
"}\n"
|
|
206
|
+
|
|
207
|
+
#define HMX_LOAD_MPY_DEEP_F16(act, wt, range) \
|
|
208
|
+
"{\n" \
|
|
209
|
+
" activation.hf = mxmem(" act ", " range "):deep\n" \
|
|
210
|
+
" weight.hf = mxmem(" wt ", " range ")\n" \
|
|
211
|
+
"}\n"
|
|
212
|
+
|
|
213
|
+
#define HMX_STORE_AFTER_F16(out, scale_reg) \
|
|
214
|
+
"mxmem(" out ", " scale_reg "):after.hf = acc\n"
|
|
215
|
+
|
|
216
|
+
#define HMX_SET_BIAS(scales) \
|
|
217
|
+
"bias = mxmem2(" scales ")\n"
|
|
218
|
+
|
|
219
|
+
#define HMX_CLRACC_F16() \
|
|
220
|
+
"mxclracc.hf\n"
|
|
221
|
+
|
|
200
222
|
#endif // HMX_UTILS_H
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "hex-dma.h"
|
|
5
5
|
#include "hmx-queue.h"
|
|
6
6
|
#include "htp-ops.h"
|
|
7
|
+
#include "hex-profile.h"
|
|
7
8
|
#include "worker-pool.h"
|
|
8
9
|
|
|
9
10
|
#include <assert.h>
|
|
@@ -12,7 +13,9 @@
|
|
|
12
13
|
#include <stdint.h>
|
|
13
14
|
#include <stdbool.h>
|
|
14
15
|
|
|
16
|
+
#ifndef HTP_MAX_NTHREADS
|
|
15
17
|
#define HTP_MAX_NTHREADS 10
|
|
18
|
+
#endif
|
|
16
19
|
#define HTP_MAX_MMAPS 16
|
|
17
20
|
|
|
18
21
|
// Memory mapping
|
|
@@ -41,9 +44,13 @@ struct htp_ops_context {
|
|
|
41
44
|
|
|
42
45
|
enum htp_op_code op; // FIXME: rename to opcode
|
|
43
46
|
int32_t op_params[HTP_OP_MAX_PARAMS];
|
|
47
|
+
int32_t kernel_params[HTP_OP_MAX_KERN_PARAMS];
|
|
44
48
|
|
|
45
49
|
const struct htp_tensor * src[HTP_OP_MAX_INPUTS];
|
|
46
|
-
|
|
50
|
+
union {
|
|
51
|
+
const struct htp_tensor * dst;
|
|
52
|
+
const struct htp_tensor * dsts[HTP_OP_MAX_OUTPUTS];
|
|
53
|
+
};
|
|
47
54
|
|
|
48
55
|
// TODO convert these to an array
|
|
49
56
|
struct htp_spad src0_spad;
|
|
@@ -70,6 +77,7 @@ struct htp_context {
|
|
|
70
77
|
bool hmx_enabled;
|
|
71
78
|
bool etm;
|
|
72
79
|
uint32_t profiler;
|
|
80
|
+
struct htp_thread_trace trace[HTP_MAX_NTHREADS + 1];
|
|
73
81
|
|
|
74
82
|
uint8_t * vtcm_base;
|
|
75
83
|
size_t vtcm_size;
|
|
@@ -85,13 +93,13 @@ struct htp_context {
|
|
|
85
93
|
|
|
86
94
|
struct htp_ops_context octx;
|
|
87
95
|
|
|
88
|
-
#ifdef HTP_HAS_HMX
|
|
89
96
|
struct hmx_queue * hmx_queue; // Async HMX queue for pipeline overlap
|
|
90
|
-
#endif
|
|
91
97
|
};
|
|
92
98
|
|
|
93
99
|
int op_matmul(struct htp_ops_context * octx);
|
|
94
100
|
int op_matmul_id(struct htp_ops_context * octx);
|
|
101
|
+
int op_matmul_qkv(struct htp_ops_context * octx);
|
|
102
|
+
int op_matmul_ffn(struct htp_ops_context * octx);
|
|
95
103
|
int op_binary(struct htp_ops_context * octx);
|
|
96
104
|
int op_unary(struct htp_ops_context * octx);
|
|
97
105
|
int op_sum_rows(struct htp_ops_context * octx);
|
|
@@ -28,18 +28,19 @@ enum htp_data_type {
|
|
|
28
28
|
HTP_TYPE_MXFP4 = 39,
|
|
29
29
|
|
|
30
30
|
// types used internally for repack, dyn.quant, etc
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
HTP_TYPE_Q4_0_TILED = 200,
|
|
32
|
+
HTP_TYPE_Q4_1_TILED,
|
|
33
|
+
HTP_TYPE_Q8_0_TILED,
|
|
34
|
+
HTP_TYPE_MXFP4_TILED,
|
|
35
35
|
|
|
36
36
|
HTP_TYPE_INVALID
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
// Constats for internal types
|
|
40
|
-
#define
|
|
41
|
-
#define
|
|
42
|
-
#define
|
|
40
|
+
#define QK_Q4_0_TILED 256 // 32x32 Q4_0 tiled layout
|
|
41
|
+
#define QK_Q8_0_TILED 128 // 32x32 Q8_0 tiled layout
|
|
42
|
+
#define QK_MXFP4_TILED 256 // 32x32 MXFP4 tiled layout
|
|
43
|
+
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
// Mask to enable various stages of the Ops.
|
|
@@ -57,6 +58,9 @@ enum htp_op_code {
|
|
|
57
58
|
HTP_OP_DIV = 3,
|
|
58
59
|
HTP_OP_MUL_MAT,
|
|
59
60
|
HTP_OP_MUL_MAT_ID,
|
|
61
|
+
HTP_OP_MUL_MAT_QKV,
|
|
62
|
+
HTP_OP_MUL_MAT_FFN,
|
|
63
|
+
HTP_OP_MUL_MAT_ADD,
|
|
60
64
|
HTP_OP_RMS_NORM,
|
|
61
65
|
HTP_OP_RMS_NORM_MUL,
|
|
62
66
|
HTP_OP_UNARY_SILU,
|
|
@@ -99,7 +103,9 @@ enum htp_op_code {
|
|
|
99
103
|
|
|
100
104
|
#define HTP_OP_MAX_DIMS 4 // aka GGML_MAX_DIMS
|
|
101
105
|
#define HTP_OP_MAX_INPUTS 6 // aka GGML_MAX_SRCS
|
|
106
|
+
#define HTP_OP_MAX_OUTPUTS 4
|
|
102
107
|
#define HTP_OP_MAX_PARAMS 16 // aka GGML_MAX_OP_PARAMS
|
|
108
|
+
#define HTP_OP_MAX_KERN_PARAMS 32
|
|
103
109
|
|
|
104
110
|
#define HTP_OP_MAX_BUFS 16
|
|
105
111
|
#define HTP_OP_MAX_REQS 256
|
|
@@ -142,14 +148,47 @@ struct htp_op_desc {
|
|
|
142
148
|
uint32_t opcode; // GGML/HTP Op
|
|
143
149
|
uint32_t flags; // Op flags
|
|
144
150
|
int32_t params[HTP_OP_MAX_PARAMS]; // Params for the op, e.g. epsilon of RMS norm
|
|
151
|
+
int32_t kernel_params[HTP_OP_MAX_KERN_PARAMS]; // generic blob for host-precomputed parameters
|
|
145
152
|
uint16_t src[HTP_OP_MAX_INPUTS]; // Input tensors indices
|
|
146
|
-
uint16_t dst;
|
|
153
|
+
uint16_t dst[HTP_OP_MAX_OUTPUTS]; // Output tensor indices
|
|
154
|
+
uint16_t pad[2]; // padding to align to 64 bits
|
|
147
155
|
};
|
|
148
156
|
|
|
157
|
+
#ifndef HTP_MAX_NTHREADS
|
|
158
|
+
#define HTP_MAX_NTHREADS 10
|
|
159
|
+
#endif
|
|
160
|
+
|
|
161
|
+
#define HTP_TRACE_MAX_EVENTS 256
|
|
162
|
+
|
|
149
163
|
enum htp_profiler_mode {
|
|
150
164
|
HTP_PROF_DISABLED = 0,
|
|
151
165
|
HTP_PROF_BASIC = 1,
|
|
152
166
|
HTP_PROF_PMU = 2,
|
|
167
|
+
HTP_PROF_TRACE = 3,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
enum htp_trace_event_id {
|
|
171
|
+
HTP_TRACE_EVT_DMA = 0,
|
|
172
|
+
|
|
173
|
+
HTP_TRACE_EVT_HVX_COMP = 20,
|
|
174
|
+
HTP_TRACE_EVT_HVX_A_QUANT = 21,
|
|
175
|
+
HTP_TRACE_EVT_HVX_A_PREP = 22,
|
|
176
|
+
HTP_TRACE_EVT_HVX_W_DEQUANT = 23,
|
|
177
|
+
HTP_TRACE_EVT_HVX_W_PREP = 24,
|
|
178
|
+
HTP_TRACE_EVT_HVX_O_PROC = 25,
|
|
179
|
+
HTP_TRACE_EVT_HVX_FA_QK = 26,
|
|
180
|
+
HTP_TRACE_EVT_HVX_FA_SFM = 27,
|
|
181
|
+
HTP_TRACE_EVT_HVX_FA_Q_PREP = 28,
|
|
182
|
+
HTP_TRACE_EVT_HVX_FA_K_PREP = 29,
|
|
183
|
+
HTP_TRACE_EVT_HVX_FA_V_PREP = 30,
|
|
184
|
+
|
|
185
|
+
HTP_TRACE_EVT_HMX_COMP = 40,
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
struct htp_trace_desc {
|
|
189
|
+
uint32_t cycles; // lower 32-bits of cycle counter
|
|
190
|
+
uint16_t id; // Event ID
|
|
191
|
+
uint16_t info; // bit 15: is_stop. bits 14-0: tile/chunk index or other metadata.
|
|
153
192
|
};
|
|
154
193
|
|
|
155
194
|
#define HTP_PROF_PMU_NCNT 8
|
|
@@ -158,8 +197,8 @@ enum htp_profiler_mode {
|
|
|
158
197
|
struct htp_prof_desc {
|
|
159
198
|
uint32_t opcode; // GGML/HTP Op
|
|
160
199
|
uint32_t usecs; // Number of usec
|
|
161
|
-
uint32_t
|
|
162
|
-
uint32_t
|
|
200
|
+
uint32_t cycles_start; // Start cycle counter
|
|
201
|
+
uint32_t cycles_stop; // Stop cycle counter
|
|
163
202
|
uint32_t pmu[HTP_PROF_PMU_NCNT]; // PMU counters
|
|
164
203
|
};
|
|
165
204
|
|
|
@@ -168,7 +207,7 @@ struct htp_opbatch_req {
|
|
|
168
207
|
uint32_t n_bufs; // Number of buffers
|
|
169
208
|
uint32_t n_tensors; // Number of tensors
|
|
170
209
|
uint32_t n_ops; // Number of ops
|
|
171
|
-
uint32_t
|
|
210
|
+
uint32_t n_traces; // Number of trace descriptors per thread
|
|
172
211
|
uint32_t pad; // unused
|
|
173
212
|
// struct htp_buf_desc bufs[]; -- dspqueue buf 0
|
|
174
213
|
// struct htp_tensor tensors[]; -- dspqueue buf 0
|
|
@@ -181,7 +220,8 @@ struct htp_opbatch_rsp {
|
|
|
181
220
|
uint32_t n_bufs; // Number of buffers
|
|
182
221
|
uint32_t n_tensors; // Number of tensors
|
|
183
222
|
uint32_t n_ops; // Number of op profile descriptors
|
|
184
|
-
uint32_t
|
|
223
|
+
uint32_t n_traces[HTP_MAX_NTHREADS + 1];
|
|
224
|
+
uint8_t pad[8]; // align to 8 bytes
|
|
185
225
|
// struct htp_prof_desc profs[]; -- dspqueue buf 0
|
|
186
226
|
};
|
|
187
227
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#ifndef HTP_VTCM_H
|
|
2
|
+
#define HTP_VTCM_H
|
|
3
|
+
|
|
4
|
+
#include <stddef.h>
|
|
5
|
+
#include <stdint.h>
|
|
6
|
+
|
|
7
|
+
static inline uint8_t *vtcm_seq_alloc(uint8_t **vtcm_ptr, size_t size) {
|
|
8
|
+
uint8_t *p = *vtcm_ptr;
|
|
9
|
+
*vtcm_ptr += size;
|
|
10
|
+
return p;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
#define VTCM_LAYOUT_ALLOC(off, field, sz) do { (L)->field = (off); (off) += (sz); } while (0)
|
|
14
|
+
#define VTCM_LAYOUT_ALLOC_OPTIONAL(off, field, sz, cond) do { if (cond) { VTCM_LAYOUT_ALLOC(off, field, sz); } else { (L)->field = 0; } } while (0)
|
|
15
|
+
|
|
16
|
+
#define VTCM_LAYOUT_PTR(type, base, offset) ((type *)((uint8_t *)(base) + (offset)))
|
|
17
|
+
#define VTCM_LAYOUT_PTR_OPTIONAL(type, base, offset, cond) ((cond) ? VTCM_LAYOUT_PTR(type, base, offset) : NULL)
|
|
18
|
+
|
|
19
|
+
#endif // HTP_VTCM_H
|
|
@@ -11,12 +11,13 @@ struct htp_iface_pmu_conf {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
interface htp_iface : remote_handle64 {
|
|
14
|
-
AEEResult start(in uint32 sess_id, in uint64 dsp_queue_id, in uint32 n_hvx, in uint32
|
|
14
|
+
AEEResult start(in uint32 sess_id, in uint64 dsp_queue_id, in uint32 n_hvx, in uint32 n_hmx, in uint64 max_vmem);
|
|
15
15
|
AEEResult stop();
|
|
16
16
|
AEEResult mmap(in uint32 fd, in uint32 size);
|
|
17
17
|
AEEResult munmap(in uint32 fd);
|
|
18
18
|
AEEResult profiler(in uint32 mode, in htp_iface_pmu_conf pmu);
|
|
19
19
|
AEEResult etm(in uint32 enable);
|
|
20
|
+
AEEResult hwinfo(rout uint32 n_threads, rout uint32 n_hvx, rout uint32 n_hmx, rout uint64 vtcm_size);
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
#endif /* HTP_IDL */
|
|
@@ -134,16 +134,7 @@ static inline HVX_Vector hvx_vec_f32_to_f16_shuff(HVX_Vector v0, HVX_Vector v1)
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
static inline HVX_Vector hvx_vec_f32_to_f16(HVX_Vector v0, HVX_Vector v1) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
#if __HVX_ARCH__ < 79
|
|
140
|
-
// replace NaNs with -INF, older arches produce NaNs for (-INF + 0.0)
|
|
141
|
-
const HVX_Vector neg_inf = hvx_vec_splat_f16(-INFINITY);
|
|
142
|
-
HVX_VectorPred nan = hvx_vec_is_nan_f16(v);
|
|
143
|
-
v = Q6_V_vmux_QVV(nan, neg_inf, v);
|
|
144
|
-
#endif
|
|
145
|
-
|
|
146
|
-
return v;
|
|
137
|
+
return Q6_Vh_vdeal_Vh(hvx_vec_f32_to_f16_shuff(v0, v1));
|
|
147
138
|
}
|
|
148
139
|
|
|
149
140
|
#if __HVX_ARCH__ >= 79
|
|
@@ -170,26 +161,6 @@ static inline HVX_VectorPair hvx_vec_f16_to_f32(HVX_Vector v) {
|
|
|
170
161
|
}
|
|
171
162
|
#endif
|
|
172
163
|
|
|
173
|
-
/* Q6_Vsf_equals_Vw is only available on v73+.*/
|
|
174
|
-
#if __HVX_ARCH__ < 73
|
|
175
|
-
static inline HVX_Vector hvx_vec_i32_to_qf32(HVX_Vector const in)
|
|
176
|
-
{
|
|
177
|
-
HVX_Vector const vzero = Q6_V_vzero();
|
|
178
|
-
HVX_VectorPred is_zero = Q6_Q_vcmp_eq_VwVw(in, vzero);
|
|
179
|
-
HVX_Vector lshift = Q6_Vw_vnormamt_Vw(in);
|
|
180
|
-
HVX_Vector normalized = Q6_Vw_vasl_VwVw(in, lshift);
|
|
181
|
-
HVX_Vector vexp = Q6_Vw_vsub_VwVw(Q6_V_vsplat_R(0x7f + 30), lshift);
|
|
182
|
-
HVX_Vector mant = Q6_V_vand_VV(Q6_V_vsplat_R(0xFFFFFF00), normalized);
|
|
183
|
-
HVX_Vector ret = Q6_V_vmux_QVV(is_zero, vzero, Q6_Vw_vadd_VwVw(mant, vexp));
|
|
184
|
-
return ret;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
static inline HVX_Vector Q6_Vsf_equals_Vw(HVX_Vector const in)
|
|
188
|
-
{
|
|
189
|
-
return Q6_Vsf_equals_Vqf32(hvx_vec_i32_to_qf32(in));
|
|
190
|
-
}
|
|
191
|
-
#endif
|
|
192
|
-
|
|
193
164
|
static inline HVX_Vector hvx_vec_i16_from_hf_rnd_sat(HVX_Vector vin) {
|
|
194
165
|
// This looks complicated.
|
|
195
166
|
// Ideally should just be Q6_Vh_equals_Vhf(vin)
|
|
@@ -305,4 +276,17 @@ static inline HVX_Vector hvx_vec_mul_f32_f32(HVX_Vector a, HVX_Vector b) {
|
|
|
305
276
|
|
|
306
277
|
#endif // __HVX_ARCH__ < 79
|
|
307
278
|
|
|
279
|
+
static inline HVX_Vector hvx_vec_load_act_tile(const uint8_t * y_q, uint32_t kt, HVX_Vector * v_act_all) {
|
|
280
|
+
if (kt % 4 == 0) {
|
|
281
|
+
*v_act_all = hvx_vmem(y_q + kt * 32);
|
|
282
|
+
return *v_act_all;
|
|
283
|
+
} else if (kt % 4 == 1) {
|
|
284
|
+
return Q6_V_vror_VR(*v_act_all, 32);
|
|
285
|
+
} else if (kt % 4 == 2) {
|
|
286
|
+
return Q6_V_vror_VR(*v_act_all, 64);
|
|
287
|
+
} else {
|
|
288
|
+
return Q6_V_vror_VR(*v_act_all, 96);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
308
292
|
#endif /* HVX_BASE_H */
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
#define EXP_COEFF_0 (0x3F000000) // 0.5 = 1/(2!)
|
|
17
17
|
#define EXP_LOGN2 (0x3F317218) // ln(2) = 0.6931471805
|
|
18
18
|
#define EXP_LOG2E (0x3FB8AA3B) // log2(e) = 1/ln(2) = 1.4426950408
|
|
19
|
+
#define EXP_LOG2E_F 1.44269504f
|
|
19
20
|
#define EXP_ONE (0x3f800000) // 1.0
|
|
20
21
|
#define EXP_RANGE_R (0x42B17218) // ln(FLT_MAX) approx = 88.7228
|
|
21
22
|
#define EXP_RANGE_L (0xC2B00000) // -88.0 (approx log(FLT_MIN))
|
|
@@ -213,4 +214,42 @@ static inline void hvx_exp_f32(uint8_t * restrict dst, const uint8_t * restrict
|
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
|
|
217
|
+
static inline HVX_Vector hvx_vec_exp2_f16(HVX_Vector x_v) {
|
|
218
|
+
const HVX_Vector zero_v = Q6_V_vzero();
|
|
219
|
+
const HVX_Vector half_hf_v = Q6_Vh_vsplat_R(0x3800); // fp16 0.5
|
|
220
|
+
|
|
221
|
+
// Clamp input to prevent integer underflow in FP16-to-INT16 conversion
|
|
222
|
+
const HVX_Vector v_clamp_min = hvx_vec_splat_f16(-24.0f);
|
|
223
|
+
x_v = Q6_Vhf_vmax_VhfVhf(v_clamp_min, x_v);
|
|
224
|
+
|
|
225
|
+
// k = round_toward_neg_inf(x); f = (float)k; frac = x - f
|
|
226
|
+
HVX_Vector x_minus_half = Q6_Vhf_equals_Vqf16(Q6_Vqf16_vsub_VhfVhf(x_v, half_hf_v));
|
|
227
|
+
HVX_Vector k_v = Q6_Vh_equals_Vhf(x_minus_half); // truncate to int16
|
|
228
|
+
HVX_Vector f_v = Q6_Vhf_equals_Vh(k_v); // back to fp16
|
|
229
|
+
|
|
230
|
+
HVX_Vector x_qf16 = Q6_Vqf16_vsub_VhfVhf(x_v, f_v); // fractional part in qf16
|
|
231
|
+
|
|
232
|
+
// Horner: y = ((((E5*x + E4)*x + E3)*x + E2)*x + E1)*x + E0
|
|
233
|
+
HVX_Vector y = Q6_Vqf16_vmpy_Vqf16Vqf16(Q6_Vh_vsplat_R(0x5082), x_qf16); // E5*x
|
|
234
|
+
y = Q6_Vqf16_vadd_Vqf16Vhf(y, Q6_Vh_vsplat_R(0x157d)); // + E4
|
|
235
|
+
y = Q6_Vqf16_vmpy_Vqf16Vqf16(y, x_qf16);
|
|
236
|
+
y = Q6_Vqf16_vadd_Vqf16Vhf(y, Q6_Vh_vsplat_R(0x20ed)); // + E3
|
|
237
|
+
y = Q6_Vqf16_vmpy_Vqf16Vqf16(y, x_qf16);
|
|
238
|
+
y = Q6_Vqf16_vadd_Vqf16Vhf(y, Q6_Vh_vsplat_R(0x2b1b)); // + E2
|
|
239
|
+
y = Q6_Vqf16_vmpy_Vqf16Vqf16(y, x_qf16);
|
|
240
|
+
y = Q6_Vqf16_vadd_Vqf16Vhf(y, Q6_Vh_vsplat_R(0x33b0)); // + E1
|
|
241
|
+
y = Q6_Vqf16_vmpy_Vqf16Vqf16(y, x_qf16);
|
|
242
|
+
y = Q6_Vqf16_vadd_Vqf16Vhf(y, Q6_Vh_vsplat_R(0x398c)); // + E0
|
|
243
|
+
y = Q6_Vqf16_vmpy_Vqf16Vqf16(y, x_qf16); // y = y * x
|
|
244
|
+
y = Q6_Vqf16_vadd_Vqf16Vhf(y, Q6_Vh_vsplat_R(0x3c00)); // + 1.0
|
|
245
|
+
|
|
246
|
+
// Combine polynomial (mantissa) with integer part (exponent): result = y * 2^k
|
|
247
|
+
y = Q6_Vhf_equals_Vqf16(y);
|
|
248
|
+
HVX_Vector y_exp = Q6_Vuh_vlsr_VuhR(Q6_Vh_vasl_VhR(y, 1), 11);
|
|
249
|
+
y_exp = Q6_Vh_vadd_VhVh(k_v, y_exp);
|
|
250
|
+
HVX_VectorPred q_underflow = Q6_Q_vcmp_gt_VhVh(zero_v, y_exp);
|
|
251
|
+
y = Q6_Vh_vaslacc_VhVhR(y, k_v, 10);
|
|
252
|
+
return Q6_V_vmux_QVV(q_underflow, zero_v, y);
|
|
253
|
+
}
|
|
254
|
+
|
|
216
255
|
#endif /* HVX_EXP_H */
|