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,61 @@
|
|
|
1
|
+
#version 450
|
|
2
|
+
|
|
3
|
+
#include "types.glsl"
|
|
4
|
+
|
|
5
|
+
layout (binding = 0) readonly buffer A {A_TYPE data_a[];}; // columns: [K_OC, T_in]
|
|
6
|
+
layout (binding = 1) writeonly buffer D {D_TYPE data_d[];}; // output: [T_out, OC]
|
|
7
|
+
|
|
8
|
+
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;
|
|
9
|
+
|
|
10
|
+
layout (push_constant) uniform parameter {
|
|
11
|
+
uint32_t T_out;
|
|
12
|
+
uint32_t OC;
|
|
13
|
+
uint32_t K_OC;
|
|
14
|
+
uint32_t T_in;
|
|
15
|
+
uint32_t K;
|
|
16
|
+
int32_t stride;
|
|
17
|
+
int32_t p0;
|
|
18
|
+
} p;
|
|
19
|
+
|
|
20
|
+
// Load A_TYPE to float
|
|
21
|
+
float load_col(uint32_t idx) {
|
|
22
|
+
#if defined(DATA_A_BF16)
|
|
23
|
+
return bf16_to_fp32(uint32_t(data_a[idx]));
|
|
24
|
+
#else
|
|
25
|
+
return float(data_a[idx]);
|
|
26
|
+
#endif
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Store float as D_TYPE
|
|
30
|
+
void store_dst(uint32_t idx, float v) {
|
|
31
|
+
#if defined(DATA_A_BF16)
|
|
32
|
+
data_d[idx] = D_TYPE(fp32_to_bf16(v));
|
|
33
|
+
#else
|
|
34
|
+
data_d[idx] = D_TYPE(v);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
void main() {
|
|
39
|
+
const uint32_t t_out = gl_GlobalInvocationID.x;
|
|
40
|
+
const uint32_t oc = gl_GlobalInvocationID.y;
|
|
41
|
+
if (t_out >= p.T_out || oc >= p.OC) return;
|
|
42
|
+
|
|
43
|
+
const int32_t t_abs = int32_t(t_out) + p.p0; // absolute position in uncropped signal
|
|
44
|
+
|
|
45
|
+
// Gather: only the ceil(K/stride) columns that scatter into t_abs, no modulo
|
|
46
|
+
int32_t t_in_min = (t_abs - int32_t(p.K) + p.stride) / p.stride;
|
|
47
|
+
if (t_in_min < 0) t_in_min = 0;
|
|
48
|
+
int32_t t_in_max = t_abs / p.stride;
|
|
49
|
+
if (t_in_max >= int32_t(p.T_in)) t_in_max = int32_t(p.T_in) - 1;
|
|
50
|
+
|
|
51
|
+
float val = 0.0;
|
|
52
|
+
for (int32_t t_in = t_in_min; t_in <= t_in_max; t_in++) {
|
|
53
|
+
int32_t k = t_abs - t_in * p.stride;
|
|
54
|
+
// col layout: [K_OC, T_in], column index = oc * K + k
|
|
55
|
+
uint32_t col_idx = (oc * p.K + uint32_t(k)) + uint32_t(t_in) * p.K_OC;
|
|
56
|
+
val += load_col(col_idx);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// dst layout: [T_out, OC], element (t_out, oc) = t_out + oc * T_out
|
|
60
|
+
store_dst(t_out + oc * p.T_out, val);
|
|
61
|
+
}
|
|
@@ -158,7 +158,7 @@ const uint32_t Csh_stride = BS_NPQ;
|
|
|
158
158
|
#ifdef COOPMAT
|
|
159
159
|
const uint32_t Csh_len = BS_K * Csh_stride;
|
|
160
160
|
#else
|
|
161
|
-
const uint32_t Csh_len = csh_store != 0 ? BS_K * Csh_stride :
|
|
161
|
+
const uint32_t Csh_len = csh_store != 0 ? BS_K * Csh_stride : 8; // 8 to workaround compiler bug
|
|
162
162
|
#endif
|
|
163
163
|
shared SHMEM_TYPE Csh[Csh_len]; // K x NPQ
|
|
164
164
|
#endif
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
#version 450
|
|
2
|
+
|
|
3
|
+
#extension GL_EXT_control_flow_attributes : enable
|
|
4
|
+
#ifdef COOPMAT2
|
|
5
|
+
#extension GL_NV_cooperative_matrix2 : enable
|
|
6
|
+
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
|
|
7
|
+
#extension GL_KHR_memory_scope_semantics : enable
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
#ifdef COOPMAT
|
|
11
|
+
#extension GL_KHR_cooperative_matrix : enable
|
|
12
|
+
#extension GL_KHR_shader_subgroup_basic : enable
|
|
13
|
+
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
|
|
14
|
+
#extension GL_KHR_memory_scope_semantics : enable
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#include "types.glsl"
|
|
18
|
+
|
|
19
|
+
// shape notation: [dim(N), ..., dim(0)] -- stride(dim(j)) >= stride(dim(i)) if i > j
|
|
20
|
+
layout(binding = 0) readonly buffer A {
|
|
21
|
+
A_TYPE knl_data[];
|
|
22
|
+
}; // src0 - kernel: [KW, KH, KD, IC*OC]
|
|
23
|
+
|
|
24
|
+
layout(binding = 1) readonly buffer B {
|
|
25
|
+
B_TYPE src_data[];
|
|
26
|
+
}; // src1 - input: [IW, IH, ID, IC*N] -- channel_first format
|
|
27
|
+
|
|
28
|
+
layout(binding = 2) writeonly buffer D {
|
|
29
|
+
D_TYPE dst_data[];
|
|
30
|
+
}; // dst - result: [OW, OH, OD, OC*N]
|
|
31
|
+
|
|
32
|
+
layout(push_constant) uniform parameter {
|
|
33
|
+
// I/O channels, batch size
|
|
34
|
+
uint32_t OC;
|
|
35
|
+
uint32_t IC;
|
|
36
|
+
uint32_t N;
|
|
37
|
+
|
|
38
|
+
// Tensor spatial sizes: input, output
|
|
39
|
+
uint32_t IW;
|
|
40
|
+
uint32_t IH;
|
|
41
|
+
uint32_t ID;
|
|
42
|
+
uint32_t OW;
|
|
43
|
+
uint32_t OH;
|
|
44
|
+
uint32_t OD;
|
|
45
|
+
|
|
46
|
+
// Strides in elements
|
|
47
|
+
uint32_t nb01;
|
|
48
|
+
uint32_t nb02;
|
|
49
|
+
uint32_t nb03;
|
|
50
|
+
|
|
51
|
+
uint32_t nb11;
|
|
52
|
+
uint32_t nb12;
|
|
53
|
+
uint32_t nb13;
|
|
54
|
+
|
|
55
|
+
uint32_t nb1;
|
|
56
|
+
uint32_t nb2;
|
|
57
|
+
uint32_t nb3;
|
|
58
|
+
|
|
59
|
+
// fastdiv helper values
|
|
60
|
+
uint32_t OWmp; uint32_t OWL;
|
|
61
|
+
uint32_t OWOHmp; uint32_t OWOHL;
|
|
62
|
+
uint32_t OWOHODmp; uint32_t OWOHODL;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
p;
|
|
66
|
+
|
|
67
|
+
layout(local_size_x_id = 0, local_size_y = 1, local_size_z = 1) in;
|
|
68
|
+
// Blocktile sizes
|
|
69
|
+
layout(constant_id = 1) const uint BS_K = 128;
|
|
70
|
+
layout(constant_id = 2) const uint BS_CRS = 16;
|
|
71
|
+
layout(constant_id = 3) const uint BS_NPQ = 128;
|
|
72
|
+
// Thread-tile sizes
|
|
73
|
+
layout(constant_id = 4) const uint TS_K = 8;
|
|
74
|
+
layout(constant_id = 5) const uint SHMEM_PAD = 4;
|
|
75
|
+
// Stride, padding, dilation
|
|
76
|
+
layout(constant_id = 6) const uint s0 = 1;
|
|
77
|
+
layout(constant_id = 7) const uint s1 = 1;
|
|
78
|
+
layout(constant_id = 8) const uint s2 = 1;
|
|
79
|
+
layout(constant_id = 9) const uint p0 = 0;
|
|
80
|
+
layout(constant_id = 10) const uint p1 = 0;
|
|
81
|
+
layout(constant_id = 11) const uint p2 = 0;
|
|
82
|
+
layout(constant_id = 12) const uint d0 = 1;
|
|
83
|
+
layout(constant_id = 13) const uint d1 = 1;
|
|
84
|
+
layout(constant_id = 14) const uint d2 = 1;
|
|
85
|
+
// Kernel spatial sizes
|
|
86
|
+
layout(constant_id = 15) const uint KW = 1;
|
|
87
|
+
layout(constant_id = 16) const uint KH = 1;
|
|
88
|
+
layout(constant_id = 17) const uint KD = 1;
|
|
89
|
+
// when set, skip bounds checks and address clamps (K/CRS/NPQ are tile-aligned)
|
|
90
|
+
layout(constant_id = 18) const uint aligned = 0;
|
|
91
|
+
// stage cm2 result through shmem (Csh) for coalesced stores. cm1 always does this.
|
|
92
|
+
layout(constant_id = 19) const uint csh_store = 0;
|
|
93
|
+
|
|
94
|
+
#ifdef COOPMAT
|
|
95
|
+
// cm1 subgroup tile: each subgroup computes a WM x WN region as a grid of
|
|
96
|
+
// TM x TN x TK fragments. Requires WM%TM == WN%TN == BS_K%WM == BS_NPQ%WN ==
|
|
97
|
+
// BS_CRS%TK == 0, and WG_SIZE == (BS_K/WM) * (BS_NPQ/WN) * subgroup_size.
|
|
98
|
+
layout(constant_id = 20) const uint WM = 32;
|
|
99
|
+
layout(constant_id = 21) const uint WN = 32;
|
|
100
|
+
const uint TM = 16;
|
|
101
|
+
const uint TN = 16;
|
|
102
|
+
const uint TK = 16;
|
|
103
|
+
const uint cms_per_row = WM / TM;
|
|
104
|
+
const uint cms_per_col = WN / TN;
|
|
105
|
+
const uint warps_M = BS_K / WM;
|
|
106
|
+
const uint warps_N = BS_NPQ / WN;
|
|
107
|
+
#endif
|
|
108
|
+
|
|
109
|
+
// without padding, ID_idx/IH_idx/IW_idx are in bounds by construction
|
|
110
|
+
const bool dhw_in_bounds = (p0 == 0) && (p1 == 0) && (p2 == 0);
|
|
111
|
+
|
|
112
|
+
uint32_t tid = gl_LocalInvocationID.x;
|
|
113
|
+
const uint32_t WG_SIZE = gl_WorkGroupSize.x;
|
|
114
|
+
|
|
115
|
+
uint splitWork(uint work_size, uint block_size) {
|
|
116
|
+
return (block_size + work_size - 1) / block_size;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
uint32_t K = p.OC;
|
|
120
|
+
uint32_t CRS = p.IC * KD * KH * KW;
|
|
121
|
+
uint32_t NPQ = p.N * p.OD * p.OH * p.OW;
|
|
122
|
+
|
|
123
|
+
// Number of blocktiles per input
|
|
124
|
+
uint32_t NB_CRS = splitWork(CRS, BS_CRS);
|
|
125
|
+
|
|
126
|
+
#if defined(COOPMAT2) || defined(COOPMAT)
|
|
127
|
+
#define SHMEM_TYPE float16_t
|
|
128
|
+
#else
|
|
129
|
+
#define SHMEM_TYPE float
|
|
130
|
+
#endif
|
|
131
|
+
|
|
132
|
+
const uint32_t Ash_stride = BS_CRS + SHMEM_PAD;
|
|
133
|
+
const uint32_t Bsh_stride = BS_NPQ + SHMEM_PAD;
|
|
134
|
+
|
|
135
|
+
const uint32_t Ash_len = BS_K * Ash_stride;
|
|
136
|
+
const uint32_t Bsh_len = BS_CRS * Bsh_stride;
|
|
137
|
+
|
|
138
|
+
shared SHMEM_TYPE Ash[Ash_len]; // K x CRS
|
|
139
|
+
shared SHMEM_TYPE Bsh[Bsh_len]; // CRS x NPQ
|
|
140
|
+
|
|
141
|
+
#if defined(COOPMAT2) || defined(COOPMAT)
|
|
142
|
+
// stage matC through shmem so global stores are row-major (NPQ-contiguous)
|
|
143
|
+
const uint32_t Csh_stride = BS_NPQ;
|
|
144
|
+
#ifdef COOPMAT
|
|
145
|
+
const uint32_t Csh_len = BS_K * Csh_stride;
|
|
146
|
+
#else
|
|
147
|
+
const uint32_t Csh_len = csh_store != 0 ? BS_K * Csh_stride : 8; // 8 to workaround compiler bug
|
|
148
|
+
#endif
|
|
149
|
+
shared SHMEM_TYPE Csh[Csh_len]; // K x NPQ
|
|
150
|
+
#endif
|
|
151
|
+
|
|
152
|
+
// Threadtile sizes
|
|
153
|
+
const uint32_t TS_NPQ = BS_K * BS_NPQ / WG_SIZE / TS_K;
|
|
154
|
+
|
|
155
|
+
// Number of threadtiles per blocktile
|
|
156
|
+
const uint32_t NT_NPQ = BS_NPQ / TS_NPQ;
|
|
157
|
+
|
|
158
|
+
/*
|
|
159
|
+
Compute
|
|
160
|
+
KxCRS @ CRSxNPQ = K x NPQ
|
|
161
|
+
K=OC
|
|
162
|
+
C=IC
|
|
163
|
+
D,R,S=KD,KH,KW
|
|
164
|
+
Z,P,Q=OD,OH,OW
|
|
165
|
+
*/
|
|
166
|
+
|
|
167
|
+
uint32_t B_idx_K = gl_WorkGroupID.x;
|
|
168
|
+
uint32_t B_idx_NPQ = gl_WorkGroupID.y + gl_WorkGroupID.z * 512;
|
|
169
|
+
|
|
170
|
+
uint32_t T_y = tid / NT_NPQ;
|
|
171
|
+
uint32_t T_x = tid % NT_NPQ;
|
|
172
|
+
|
|
173
|
+
uint32_t Ar = tid / BS_CRS;
|
|
174
|
+
uint32_t Ac = tid % BS_CRS;
|
|
175
|
+
const uint32_t ArpWg = WG_SIZE / BS_CRS;
|
|
176
|
+
|
|
177
|
+
uint32_t Br = tid / BS_NPQ;
|
|
178
|
+
uint32_t Bc = tid % BS_NPQ;
|
|
179
|
+
const uint32_t BrpWg = WG_SIZE / BS_NPQ;
|
|
180
|
+
|
|
181
|
+
// see init_fastdiv_values in ggml-vulkan.cpp
|
|
182
|
+
uint fastdiv(uint n, uint mp, uint L) {
|
|
183
|
+
uint msbs, lsbs;
|
|
184
|
+
// msbs = mulhi(n, mp)
|
|
185
|
+
umulExtended(n, mp, msbs, lsbs);
|
|
186
|
+
return (msbs + n) >> L;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
void split_crs(uint32_t crs_idx, out uint32_t ic, out uint32_t kd, out uint32_t kh, out uint32_t kw) {
|
|
190
|
+
const uint32_t KHKW = KH * KW;
|
|
191
|
+
const uint32_t KDKHKW = KD * KHKW;
|
|
192
|
+
ic = crs_idx / KDKHKW;
|
|
193
|
+
uint32_t rem = crs_idx - ic * KDKHKW;
|
|
194
|
+
kd = rem / KHKW;
|
|
195
|
+
rem = rem - kd * KHKW;
|
|
196
|
+
kh = rem / KW;
|
|
197
|
+
kw = rem - kh * KW;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
void split_npq(uint32_t npq_idx, out uint32_t n, out uint32_t od, out uint32_t oh, out uint32_t ow) {
|
|
201
|
+
const uint32_t OWOH = p.OW * p.OH;
|
|
202
|
+
n = fastdiv(npq_idx, p.OWOHODmp, p.OWOHODL);
|
|
203
|
+
uint32_t rem = npq_idx - n * p.OD * OWOH;
|
|
204
|
+
od = fastdiv(rem, p.OWOHmp, p.OWOHL);
|
|
205
|
+
rem = rem - od * OWOH;
|
|
206
|
+
oh = fastdiv(rem, p.OWmp, p.OWL);
|
|
207
|
+
ow = rem - oh * p.OW;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#ifdef COOPMAT2
|
|
211
|
+
#define ACC_TYPE float16_t
|
|
212
|
+
|
|
213
|
+
ACC_TYPE perElemOpStore(const in uint32_t r, const in uint32_t c, const in ACC_TYPE elem)
|
|
214
|
+
{
|
|
215
|
+
uint32_t K_idx = B_idx_K * BS_K + r;
|
|
216
|
+
uint32_t NPQ_idx = B_idx_NPQ * BS_NPQ + c;
|
|
217
|
+
uint32_t N_idx;
|
|
218
|
+
uint32_t OD_idx;
|
|
219
|
+
uint32_t OH_idx;
|
|
220
|
+
uint32_t OW_idx;
|
|
221
|
+
split_npq(NPQ_idx, N_idx, OD_idx, OH_idx, OW_idx);
|
|
222
|
+
uint32_t dst_idx = OW_idx + OH_idx * p.nb1 + OD_idx * p.nb2 + (N_idx * p.OC + K_idx) * p.nb3;
|
|
223
|
+
if (aligned != 0 || (K_idx < K && NPQ_idx < NPQ)) {
|
|
224
|
+
dst_data[dst_idx] = D_TYPE(elem);
|
|
225
|
+
}
|
|
226
|
+
return elem;
|
|
227
|
+
}
|
|
228
|
+
#endif
|
|
229
|
+
|
|
230
|
+
void main() {
|
|
231
|
+
if (B_idx_NPQ * BS_NPQ >= NPQ) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
#ifdef COOPMAT2
|
|
236
|
+
coopmat<ACC_TYPE, gl_ScopeWorkgroup, BS_K, BS_NPQ, gl_MatrixUseAccumulator> matC;
|
|
237
|
+
matC = coopmat<ACC_TYPE, gl_ScopeWorkgroup, BS_K, BS_NPQ, gl_MatrixUseAccumulator>(0.0);
|
|
238
|
+
#elif defined(COOPMAT)
|
|
239
|
+
coopmat<float16_t, gl_ScopeSubgroup, TM, TN, gl_MatrixUseAccumulator> sums[cms_per_row * cms_per_col];
|
|
240
|
+
[[unroll]] for (uint i = 0; i < cms_per_row * cms_per_col; i++) {
|
|
241
|
+
sums[i] = coopmat<float16_t, gl_ScopeSubgroup, TM, TN, gl_MatrixUseAccumulator>(0.0);
|
|
242
|
+
}
|
|
243
|
+
const uint warp_r = gl_SubgroupID / warps_N;
|
|
244
|
+
const uint warp_c = gl_SubgroupID % warps_N;
|
|
245
|
+
#else
|
|
246
|
+
float regC[TS_K][TS_NPQ];
|
|
247
|
+
for (uint32_t T_ly = 0; T_ly < TS_K; T_ly++) {
|
|
248
|
+
for (uint32_t T_lx = 0; T_lx < TS_NPQ; T_lx++) {
|
|
249
|
+
regC[T_ly][T_lx] = 0.0;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
#endif
|
|
253
|
+
/* Advance block in CRS dim */
|
|
254
|
+
[[dont_unroll]] for (uint32_t B_idx_CRS = 0; B_idx_CRS < NB_CRS; B_idx_CRS++) {
|
|
255
|
+
uint32_t CRS_idx_a = B_idx_CRS * BS_CRS + Ac;
|
|
256
|
+
uint32_t IC_idx_a;
|
|
257
|
+
uint32_t KD_idx_a;
|
|
258
|
+
uint32_t KH_idx_a;
|
|
259
|
+
uint32_t KW_idx_a;
|
|
260
|
+
split_crs(CRS_idx_a, IC_idx_a, KD_idx_a, KH_idx_a, KW_idx_a);
|
|
261
|
+
|
|
262
|
+
/* Load kernel to A_block: (BS_K x BS_CRS)*/
|
|
263
|
+
UNROLL for (uint32_t r_offset = 0; r_offset < BS_K; r_offset += ArpWg) {
|
|
264
|
+
uint32_t B_ly = r_offset + Ar;
|
|
265
|
+
uint32_t B_lx = Ac;
|
|
266
|
+
uint32_t K_idx = B_idx_K * BS_K + B_ly; /* Global K_idx (row index of A)*/
|
|
267
|
+
uint32_t knl_idx = KW_idx_a + KH_idx_a * p.nb01 + KD_idx_a * p.nb02 + (K_idx * p.IC + IC_idx_a) * p.nb03;
|
|
268
|
+
if (aligned == 0) {
|
|
269
|
+
knl_idx = min(knl_idx, K * CRS - 1);
|
|
270
|
+
}
|
|
271
|
+
float val = knl_data[knl_idx];
|
|
272
|
+
if (aligned == 0 && (K_idx >= K || CRS_idx_a >= CRS)) {
|
|
273
|
+
val = 0.0;
|
|
274
|
+
}
|
|
275
|
+
Ash[B_ly * Ash_stride + B_lx] = SHMEM_TYPE(val);
|
|
276
|
+
}
|
|
277
|
+
/* Load input to B_block: (BS_CRS x BS_NPQ) */
|
|
278
|
+
UNROLL for (uint32_t r_offset = 0; r_offset < BS_CRS; r_offset += BrpWg) {
|
|
279
|
+
uint32_t B_ly = r_offset + Br; /* Row index of B block */
|
|
280
|
+
uint32_t B_lx = Bc;
|
|
281
|
+
uint32_t NPQ_idx = B_idx_NPQ * BS_NPQ + B_lx; /* Global NPQ index (column index of B) */
|
|
282
|
+
uint32_t N_idx;
|
|
283
|
+
uint32_t OD_idx;
|
|
284
|
+
uint32_t OH_idx;
|
|
285
|
+
uint32_t OW_idx;
|
|
286
|
+
split_npq(NPQ_idx, N_idx, OD_idx, OH_idx, OW_idx);
|
|
287
|
+
|
|
288
|
+
uint32_t CRS_idx_b = B_idx_CRS * BS_CRS + B_ly;
|
|
289
|
+
uint32_t IC_idx_b;
|
|
290
|
+
uint32_t KD_idx_b;
|
|
291
|
+
uint32_t KH_idx_b;
|
|
292
|
+
uint32_t KW_idx_b;
|
|
293
|
+
split_crs(CRS_idx_b, IC_idx_b, KD_idx_b, KH_idx_b, KW_idx_b);
|
|
294
|
+
|
|
295
|
+
uint32_t ID_idx = OD_idx * s2 + KD_idx_b * d2 - p2;
|
|
296
|
+
uint32_t IH_idx = OH_idx * s1 + KH_idx_b * d1 - p1;
|
|
297
|
+
uint32_t IW_idx = OW_idx * s0 + KW_idx_b * d0 - p0;
|
|
298
|
+
|
|
299
|
+
uint32_t src_idx = IW_idx + IH_idx * p.nb11 + ID_idx * p.nb12 + (N_idx * p.IC + IC_idx_b) * p.nb13;
|
|
300
|
+
// skip clamp when address can't go OOB
|
|
301
|
+
if (aligned == 0 || !dhw_in_bounds) {
|
|
302
|
+
src_idx = min(src_idx, p.IC * p.N * p.IW * p.IH * p.ID - 1);
|
|
303
|
+
}
|
|
304
|
+
float val = src_data[src_idx];
|
|
305
|
+
bool oob = false;
|
|
306
|
+
if (aligned == 0 && (CRS_idx_b >= CRS || NPQ_idx >= NPQ)) {
|
|
307
|
+
oob = true;
|
|
308
|
+
}
|
|
309
|
+
// also catches lower-bound underflow (idx wraps to 0x80000000+)
|
|
310
|
+
if (!dhw_in_bounds && (ID_idx >= p.ID || IH_idx >= p.IH || IW_idx >= p.IW)) {
|
|
311
|
+
oob = true;
|
|
312
|
+
}
|
|
313
|
+
if (oob) {
|
|
314
|
+
val = 0.0;
|
|
315
|
+
}
|
|
316
|
+
Bsh[B_ly * Bsh_stride + B_lx] = SHMEM_TYPE(val);
|
|
317
|
+
}
|
|
318
|
+
barrier();
|
|
319
|
+
#ifdef COOPMAT2
|
|
320
|
+
coopmat<float16_t, gl_ScopeWorkgroup, BS_K, BS_CRS, gl_MatrixUseA> matA;
|
|
321
|
+
coopmat<float16_t, gl_ScopeWorkgroup, BS_CRS, BS_NPQ, gl_MatrixUseB> matB;
|
|
322
|
+
|
|
323
|
+
coopMatLoad(matA, Ash, 0, Ash_stride, gl_CooperativeMatrixLayoutRowMajor);
|
|
324
|
+
coopMatLoad(matB, Bsh, 0, Bsh_stride, gl_CooperativeMatrixLayoutRowMajor);
|
|
325
|
+
matC = coopMatMulAdd(matA, matB, matC);
|
|
326
|
+
#elif defined(COOPMAT)
|
|
327
|
+
// each subgroup multiplies its grid of fragments per TK-sized CRS chunk
|
|
328
|
+
[[unroll]] for (uint k_step = 0; k_step < BS_CRS / TK; k_step++) {
|
|
329
|
+
coopmat<float16_t, gl_ScopeSubgroup, TM, TK, gl_MatrixUseA> cache_a[cms_per_row];
|
|
330
|
+
[[unroll]] for (uint cm_row = 0; cm_row < cms_per_row; cm_row++) {
|
|
331
|
+
const uint a_off = (warp_r * WM + cm_row * TM) * Ash_stride + k_step * TK;
|
|
332
|
+
coopMatLoad(cache_a[cm_row], Ash, a_off, Ash_stride, gl_CooperativeMatrixLayoutRowMajor);
|
|
333
|
+
}
|
|
334
|
+
[[unroll]] for (uint cm_col = 0; cm_col < cms_per_col; cm_col++) {
|
|
335
|
+
coopmat<float16_t, gl_ScopeSubgroup, TK, TN, gl_MatrixUseB> cache_b;
|
|
336
|
+
const uint b_off = k_step * TK * Bsh_stride + warp_c * WN + cm_col * TN;
|
|
337
|
+
coopMatLoad(cache_b, Bsh, b_off, Bsh_stride, gl_CooperativeMatrixLayoutRowMajor);
|
|
338
|
+
[[unroll]] for (uint cm_row = 0; cm_row < cms_per_row; cm_row++) {
|
|
339
|
+
sums[cm_col * cms_per_row + cm_row] = coopMatMulAdd(cache_a[cm_row], cache_b, sums[cm_col * cms_per_row + cm_row]);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
#else
|
|
344
|
+
if (T_y * TS_K < K) {
|
|
345
|
+
UNROLL for (uint32_t CRS_lidx = 0; CRS_lidx < BS_CRS; CRS_lidx++) {
|
|
346
|
+
float regA[TS_K];
|
|
347
|
+
float regB[TS_NPQ];
|
|
348
|
+
for (uint32_t T_ly = 0; T_ly < TS_K; T_ly++) {
|
|
349
|
+
regA[T_ly] = Ash[(T_y * TS_K + T_ly) * Ash_stride + CRS_lidx];
|
|
350
|
+
}
|
|
351
|
+
for (uint32_t T_lx = 0; T_lx < TS_NPQ; T_lx++) {
|
|
352
|
+
regB[T_lx] = Bsh[CRS_lidx * Bsh_stride + T_x * TS_NPQ + T_lx];
|
|
353
|
+
}
|
|
354
|
+
for (uint32_t T_ly = 0; T_ly < TS_K; T_ly++) {
|
|
355
|
+
for (uint32_t T_lx = 0; T_lx < TS_NPQ; T_lx++) {
|
|
356
|
+
regC[T_ly][T_lx] = fma(regA[T_ly], regB[T_lx], regC[T_ly][T_lx]);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
#endif
|
|
362
|
+
barrier();
|
|
363
|
+
}
|
|
364
|
+
/* Save C* */
|
|
365
|
+
#if defined(COOPMAT2) || defined(COOPMAT)
|
|
366
|
+
// stage matC into Csh, then write to dst with coalesced NPQ-contiguous stores
|
|
367
|
+
#ifdef COOPMAT
|
|
368
|
+
const bool use_staged_store = true;
|
|
369
|
+
#else
|
|
370
|
+
const bool use_staged_store = (csh_store != 0);
|
|
371
|
+
#endif
|
|
372
|
+
if (use_staged_store) {
|
|
373
|
+
#ifdef COOPMAT
|
|
374
|
+
// cm1: each subgroup stores its fragment grid into its Csh slot
|
|
375
|
+
[[unroll]] for (uint cm_row = 0; cm_row < cms_per_row; cm_row++) {
|
|
376
|
+
[[unroll]] for (uint cm_col = 0; cm_col < cms_per_col; cm_col++) {
|
|
377
|
+
const uint csh_off = (warp_r * WM + cm_row * TM) * Csh_stride + warp_c * WN + cm_col * TN;
|
|
378
|
+
coopMatStore(sums[cm_col * cms_per_row + cm_row], Csh, csh_off, Csh_stride, gl_CooperativeMatrixLayoutRowMajor);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
#else
|
|
382
|
+
coopMatStore(matC, Csh, 0, Csh_stride, gl_CooperativeMatrixLayoutRowMajor);
|
|
383
|
+
#endif
|
|
384
|
+
barrier();
|
|
385
|
+
|
|
386
|
+
// cooperative shmem->global: WG threads spread across BS_NPQ (the
|
|
387
|
+
// contiguous direction of dst), each iter covers store_rows_per_iter K-rows
|
|
388
|
+
const uint32_t store_rows_per_iter = WG_SIZE / BS_NPQ;
|
|
389
|
+
const uint32_t store_iters = BS_K / store_rows_per_iter;
|
|
390
|
+
const uint32_t k_thread_offset = tid / BS_NPQ;
|
|
391
|
+
const uint32_t npq_thread = tid % BS_NPQ;
|
|
392
|
+
[[unroll]] for (uint32_t i = 0; i < store_iters; i++) {
|
|
393
|
+
uint32_t k_local = i * store_rows_per_iter + k_thread_offset;
|
|
394
|
+
uint32_t K_idx = B_idx_K * BS_K + k_local;
|
|
395
|
+
uint32_t NPQ_idx = B_idx_NPQ * BS_NPQ + npq_thread;
|
|
396
|
+
uint32_t N_idx;
|
|
397
|
+
uint32_t OD_idx;
|
|
398
|
+
uint32_t OH_idx;
|
|
399
|
+
uint32_t OW_idx;
|
|
400
|
+
split_npq(NPQ_idx, N_idx, OD_idx, OH_idx, OW_idx);
|
|
401
|
+
uint32_t dst_idx = OW_idx + OH_idx * p.nb1 + OD_idx * p.nb2 + (N_idx * p.OC + K_idx) * p.nb3;
|
|
402
|
+
if (aligned != 0 || (K_idx < K && NPQ_idx < NPQ)) {
|
|
403
|
+
dst_data[dst_idx] = D_TYPE(Csh[k_local * Csh_stride + npq_thread]);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
#ifdef COOPMAT2
|
|
408
|
+
else {
|
|
409
|
+
coopMatPerElementNV(matC, matC, perElemOpStore);
|
|
410
|
+
}
|
|
411
|
+
#endif
|
|
412
|
+
#else
|
|
413
|
+
if (T_y * TS_K < K) {
|
|
414
|
+
for (uint32_t T_ly = 0; T_ly < TS_K; T_ly++) {
|
|
415
|
+
for (uint32_t T_lx = 0; T_lx < TS_NPQ; T_lx++) {
|
|
416
|
+
uint32_t K_idx = B_idx_K * BS_K + T_y * TS_K + T_ly;
|
|
417
|
+
uint32_t NPQ_idx = B_idx_NPQ * BS_NPQ + T_x * TS_NPQ + T_lx;
|
|
418
|
+
uint32_t N_idx;
|
|
419
|
+
uint32_t OD_idx;
|
|
420
|
+
uint32_t OH_idx;
|
|
421
|
+
uint32_t OW_idx;
|
|
422
|
+
split_npq(NPQ_idx, N_idx, OD_idx, OH_idx, OW_idx);
|
|
423
|
+
uint32_t dst_idx = OW_idx + OH_idx * p.nb1 + OD_idx * p.nb2 + (N_idx * p.OC + K_idx) * p.nb3;
|
|
424
|
+
if (aligned != 0 || (K_idx < K && NPQ_idx < NPQ)) {
|
|
425
|
+
dst_data[dst_idx] = D_TYPE(regC[T_ly][T_lx]);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
#endif
|
|
431
|
+
}
|
|
@@ -12,11 +12,11 @@ void main() {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const uint i13 = fastdiv(idx, p.ne1_012mp, p.
|
|
15
|
+
const uint i13 = fastdiv(idx, p.ne1_012mp, fastdiv_L(p.ne1_Ls, 0));
|
|
16
16
|
const uint i13_offset = i13 * p.ne12*p.ne11*p.ne10;
|
|
17
|
-
const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, p.
|
|
17
|
+
const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, fastdiv_L(p.ne1_Ls, 1));
|
|
18
18
|
const uint i12_offset = i12*p.ne11*p.ne10;
|
|
19
|
-
const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, p.
|
|
19
|
+
const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, fastdiv_L(p.ne1_Ls, 2));
|
|
20
20
|
const uint i10 = idx - i13_offset - i12_offset - i11*p.ne10;
|
|
21
21
|
|
|
22
22
|
if (i10 == i11) {
|
|
@@ -7,14 +7,12 @@ layout (push_constant) uniform parameter
|
|
|
7
7
|
uint ne00; uint ne01; uint ne02; uint ne03; uint nb00; uint nb01; uint nb02; uint nb03;
|
|
8
8
|
uint ne10; uint ne11; uint ne12; uint ne13; uint nb10; uint nb11; uint nb12; uint nb13;
|
|
9
9
|
uint misalign_offsets;
|
|
10
|
-
float param1; float param2;
|
|
10
|
+
float param1; float param2; float param3; float param4;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
uint ne0_0mp;
|
|
15
|
-
uint ne1_012mp; uint
|
|
16
|
-
uint ne1_01mp; uint ne1_01L;
|
|
17
|
-
uint ne1_0mp; uint ne1_0L;
|
|
12
|
+
// The three L values are packed as bytes to keep this layout under the 128B
|
|
13
|
+
// push constant limit while still leaving room for four float parameters.
|
|
14
|
+
uint ne0_012mp; uint ne0_01mp; uint ne0_0mp; uint ne0_Ls;
|
|
15
|
+
uint ne1_012mp; uint ne1_01mp; uint ne1_0mp; uint ne1_Ls;
|
|
18
16
|
} p;
|
|
19
17
|
|
|
20
18
|
layout (binding = 0) readonly buffer A {A_TYPE data_a[];};
|
|
@@ -42,42 +40,46 @@ uint fastdiv(uint n, uint mp, uint L) {
|
|
|
42
40
|
return (msbs + n) >> L;
|
|
43
41
|
}
|
|
44
42
|
|
|
43
|
+
uint fastdiv_L(uint packed, uint slot) {
|
|
44
|
+
return (packed >> (slot * 8)) & 0x3Fu;
|
|
45
|
+
}
|
|
46
|
+
|
|
45
47
|
uint src0_idx(uint idx) {
|
|
46
|
-
const uint i03 = fastdiv(idx, p.ne0_012mp, p.
|
|
48
|
+
const uint i03 = fastdiv(idx, p.ne0_012mp, fastdiv_L(p.ne0_Ls, 0));
|
|
47
49
|
const uint i03_offset = i03 * p.ne02*p.ne01*p.ne00;
|
|
48
|
-
const uint i02 = fastdiv(idx - i03_offset, p.ne0_01mp, p.
|
|
50
|
+
const uint i02 = fastdiv(idx - i03_offset, p.ne0_01mp, fastdiv_L(p.ne0_Ls, 1));
|
|
49
51
|
const uint i02_offset = i02*p.ne01*p.ne00;
|
|
50
|
-
const uint i01 = fastdiv(idx - i03_offset - i02_offset, p.ne0_0mp, p.
|
|
52
|
+
const uint i01 = fastdiv(idx - i03_offset - i02_offset, p.ne0_0mp, fastdiv_L(p.ne0_Ls, 2));
|
|
51
53
|
const uint i00 = idx - i03_offset - i02_offset - i01*p.ne00;
|
|
52
54
|
return i03*p.nb03 + i02*p.nb02 + i01*p.nb01 + i00*p.nb00;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
uint dst_idx(uint idx) {
|
|
56
|
-
const uint i13 = fastdiv(idx, p.ne1_012mp, p.
|
|
58
|
+
const uint i13 = fastdiv(idx, p.ne1_012mp, fastdiv_L(p.ne1_Ls, 0));
|
|
57
59
|
const uint i13_offset = i13 * p.ne12*p.ne11*p.ne10;
|
|
58
|
-
const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, p.
|
|
60
|
+
const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, fastdiv_L(p.ne1_Ls, 1));
|
|
59
61
|
const uint i12_offset = i12*p.ne11*p.ne10;
|
|
60
|
-
const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, p.
|
|
62
|
+
const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, fastdiv_L(p.ne1_Ls, 2));
|
|
61
63
|
const uint i10 = idx - i13_offset - i12_offset - i11*p.ne10;
|
|
62
64
|
return i13*p.nb13 + i12*p.nb12 + i11*p.nb11 + i10*p.nb10;
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
uint src0_idx_quant(uint idx, uint qk) {
|
|
66
|
-
const uint i03 = fastdiv(idx, p.ne0_012mp, p.
|
|
68
|
+
const uint i03 = fastdiv(idx, p.ne0_012mp, fastdiv_L(p.ne0_Ls, 0));
|
|
67
69
|
const uint i03_offset = i03 * p.ne02*p.ne01*p.ne00;
|
|
68
|
-
const uint i02 = fastdiv(idx - i03_offset, p.ne0_01mp, p.
|
|
70
|
+
const uint i02 = fastdiv(idx - i03_offset, p.ne0_01mp, fastdiv_L(p.ne0_Ls, 1));
|
|
69
71
|
const uint i02_offset = i02*p.ne01*p.ne00;
|
|
70
|
-
const uint i01 = fastdiv(idx - i03_offset - i02_offset, p.ne0_0mp, p.
|
|
72
|
+
const uint i01 = fastdiv(idx - i03_offset - i02_offset, p.ne0_0mp, fastdiv_L(p.ne0_Ls, 2));
|
|
71
73
|
const uint i00 = idx - i03_offset - i02_offset - i01*p.ne00;
|
|
72
74
|
return i03*p.nb03 + i02*p.nb02 + i01*p.nb01 + (i00/qk)*p.nb00;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
uint dst_idx_quant(uint idx, uint qk) {
|
|
76
|
-
const uint i13 = fastdiv(idx, p.ne1_012mp, p.
|
|
78
|
+
const uint i13 = fastdiv(idx, p.ne1_012mp, fastdiv_L(p.ne1_Ls, 0));
|
|
77
79
|
const uint i13_offset = i13 * p.ne12*p.ne11*p.ne10;
|
|
78
|
-
const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, p.
|
|
80
|
+
const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, fastdiv_L(p.ne1_Ls, 1));
|
|
79
81
|
const uint i12_offset = i12*p.ne11*p.ne10;
|
|
80
|
-
const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, p.
|
|
82
|
+
const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, fastdiv_L(p.ne1_Ls, 2));
|
|
81
83
|
const uint i10 = idx - i13_offset - i12_offset - i11*p.ne10;
|
|
82
84
|
return i13*p.nb13 + i12*p.nb12 + i11*p.nb11 + (i10/qk)*p.nb10;
|
|
83
85
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#version 450
|
|
2
|
+
|
|
3
|
+
#include "types.glsl"
|
|
4
|
+
#include "generic_binary_head.glsl"
|
|
5
|
+
|
|
6
|
+
layout(local_size_x = 256, local_size_y = 1, local_size_z = 1) in;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
const uint col = gl_GlobalInvocationID.x;
|
|
10
|
+
|
|
11
|
+
if (col >= p.ne20) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (uint row = gl_GlobalInvocationID.y; row < p.ne21; row += gl_WorkGroupSize.y * gl_NumWorkGroups.y) {
|
|
16
|
+
float sum = 0.0f;
|
|
17
|
+
for (uint i = 0; i < p.ne10; ++i) {
|
|
18
|
+
if (data_b[get_boffset() + i*p.nb10] == int(row)) {
|
|
19
|
+
sum += data_a[get_aoffset() + i*p.nb01 + col*p.nb00];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
data_d[get_doffset() + row*p.nb21 + col*p.nb20] = sum;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -15,14 +15,33 @@ layout (push_constant) uniform parameter
|
|
|
15
15
|
uint mode;
|
|
16
16
|
float alpha;
|
|
17
17
|
float limit;
|
|
18
|
+
uint nb00;
|
|
18
19
|
uint nb01;
|
|
19
20
|
uint nb02;
|
|
20
21
|
uint nb03;
|
|
21
|
-
uint
|
|
22
|
-
uint ne02;
|
|
22
|
+
uint nb10;
|
|
23
23
|
uint nb11;
|
|
24
24
|
uint nb12;
|
|
25
25
|
uint nb13;
|
|
26
|
-
uint
|
|
27
|
-
uint
|
|
26
|
+
uint nb20;
|
|
27
|
+
uint nb21;
|
|
28
|
+
uint nb22;
|
|
29
|
+
uint nb23;
|
|
30
|
+
uint ne21;
|
|
31
|
+
uint ne22;
|
|
32
|
+
uint misalign_offsets;
|
|
33
|
+
uint ne2_012mp; uint ne2_012L;
|
|
34
|
+
uint ne2_01mp; uint ne2_01L;
|
|
35
|
+
uint ne2_0mp; uint ne2_0L;
|
|
28
36
|
} p;
|
|
37
|
+
|
|
38
|
+
uint get_aoffset() { return p.misalign_offsets >> 16; }
|
|
39
|
+
uint get_boffset() { return (p.misalign_offsets >> 8) & 0xFF; }
|
|
40
|
+
uint get_doffset() { return p.misalign_offsets & 0xFF; }
|
|
41
|
+
|
|
42
|
+
// see init_fastdiv_values in ggml-vulkan.cpp
|
|
43
|
+
uint fastdiv(uint n, uint mp, uint L) {
|
|
44
|
+
uint msbs, lsbs;
|
|
45
|
+
umulExtended(n, mp, msbs, lsbs);
|
|
46
|
+
return (msbs + n) >> L;
|
|
47
|
+
}
|