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
|
@@ -66,7 +66,6 @@ struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_base(ggml
|
|
|
66
66
|
const char * op_str = "undefined";
|
|
67
67
|
switch (op) {
|
|
68
68
|
case GGML_OP_ADD_ID: op_str = "add_id"; break;
|
|
69
|
-
case GGML_OP_CONCAT: op_str = "concat"; break;
|
|
70
69
|
default: GGML_ABORT("fatal error");
|
|
71
70
|
};
|
|
72
71
|
|
|
@@ -161,11 +160,15 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_get_rows(ggml_me
|
|
|
161
160
|
return res;
|
|
162
161
|
}
|
|
163
162
|
|
|
164
|
-
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_set_rows(ggml_metal_library_t lib,
|
|
163
|
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_set_rows(ggml_metal_library_t lib, const ggml_tensor * op) {
|
|
165
164
|
char base[256];
|
|
166
165
|
char name[256];
|
|
167
166
|
|
|
168
|
-
|
|
167
|
+
const auto tsrc = op->src[0]->type;
|
|
168
|
+
const auto tidx = op->src[1]->type;
|
|
169
|
+
const auto tdst = op->type;
|
|
170
|
+
|
|
171
|
+
snprintf(base, 256, "kernel_set_rows_%s_%s_%s", ggml_type_name(tsrc), ggml_type_name(tidx), ggml_type_name(tdst));
|
|
169
172
|
snprintf(name, 256, "%s", base);
|
|
170
173
|
|
|
171
174
|
ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
|
@@ -211,6 +214,21 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_repeat(ggml_meta
|
|
|
211
214
|
return res;
|
|
212
215
|
}
|
|
213
216
|
|
|
217
|
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_concat(ggml_metal_library_t lib, ggml_type tsrc) {
|
|
218
|
+
char base[256];
|
|
219
|
+
char name[256];
|
|
220
|
+
|
|
221
|
+
snprintf(base, 256, "kernel_concat_%s", ggml_type_name(tsrc));
|
|
222
|
+
snprintf(name, 256, "%s", base);
|
|
223
|
+
|
|
224
|
+
ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
|
225
|
+
if (!res.pipeline) {
|
|
226
|
+
res = ggml_metal_library_compile_pipeline(lib, base, name, nullptr);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return res;
|
|
230
|
+
}
|
|
231
|
+
|
|
214
232
|
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_unary(ggml_metal_library_t lib, const ggml_tensor * op) {
|
|
215
233
|
char base[256];
|
|
216
234
|
char name[256];
|
|
@@ -1689,7 +1707,9 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_norm(ggml_metal_
|
|
|
1689
1707
|
}
|
|
1690
1708
|
|
|
1691
1709
|
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rope(ggml_metal_library_t lib, const ggml_tensor * op) {
|
|
1692
|
-
assert(op->op == GGML_OP_ROPE);
|
|
1710
|
+
assert(op->op == GGML_OP_ROPE || op->op == GGML_OP_ROPE_BACK);
|
|
1711
|
+
|
|
1712
|
+
const bool is_back = op->op == GGML_OP_ROPE_BACK;
|
|
1693
1713
|
|
|
1694
1714
|
char base[256];
|
|
1695
1715
|
char name[256];
|
|
@@ -1713,13 +1733,14 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rope(ggml_metal_
|
|
|
1713
1733
|
snprintf(base, 256, "kernel_rope_norm_%s", ggml_type_name(op->src[0]->type));
|
|
1714
1734
|
}
|
|
1715
1735
|
|
|
1716
|
-
snprintf(name, 256, "%s_imrope=%d", base, is_imrope ? 1 : 0);
|
|
1736
|
+
snprintf(name, 256, "%s_imrope=%d_is_back=%d", base, is_imrope ? 1 : 0, is_back ? 1 : 0);
|
|
1717
1737
|
|
|
1718
1738
|
ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
|
1719
1739
|
if (!res.pipeline) {
|
|
1720
1740
|
ggml_metal_cv_t cv = ggml_metal_cv_init();
|
|
1721
1741
|
|
|
1722
1742
|
ggml_metal_cv_set_bool(cv, is_imrope, FC_ROPE + 0);
|
|
1743
|
+
ggml_metal_cv_set_bool(cv, is_back, FC_ROPE + 1);
|
|
1723
1744
|
|
|
1724
1745
|
res = ggml_metal_library_compile_pipeline(lib, base, name, cv);
|
|
1725
1746
|
|
|
@@ -1783,6 +1804,26 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_1
|
|
|
1783
1804
|
return res;
|
|
1784
1805
|
}
|
|
1785
1806
|
|
|
1807
|
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_col2im_1d(ggml_metal_library_t lib, const ggml_tensor * op) {
|
|
1808
|
+
assert(op->op == GGML_OP_COL2IM_1D);
|
|
1809
|
+
|
|
1810
|
+
GGML_ASSERT(ggml_is_contiguous(op->src[0]));
|
|
1811
|
+
GGML_ASSERT(op->src[0]->type == GGML_TYPE_F32 || op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_BF16);
|
|
1812
|
+
|
|
1813
|
+
char base[256];
|
|
1814
|
+
char name[256];
|
|
1815
|
+
|
|
1816
|
+
snprintf(base, 256, "kernel_col2im_1d_%s", ggml_type_name(op->src[0]->type));
|
|
1817
|
+
snprintf(name, 256, "%s", base);
|
|
1818
|
+
|
|
1819
|
+
ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
|
1820
|
+
if (!res.pipeline) {
|
|
1821
|
+
res = ggml_metal_library_compile_pipeline(lib, base, name, nullptr);
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
return res;
|
|
1825
|
+
}
|
|
1826
|
+
|
|
1786
1827
|
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_2d(ggml_metal_library_t lib, const ggml_tensor * op) {
|
|
1787
1828
|
assert(op->op == GGML_OP_CONV_TRANSPOSE_2D);
|
|
1788
1829
|
|
|
@@ -1828,6 +1869,29 @@ ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d(ggml_met
|
|
|
1828
1869
|
return res;
|
|
1829
1870
|
}
|
|
1830
1871
|
|
|
1872
|
+
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d_dw(ggml_metal_library_t lib, const ggml_tensor * op, bool tiled) {
|
|
1873
|
+
assert(op->op == GGML_OP_CONV_2D_DW);
|
|
1874
|
+
|
|
1875
|
+
GGML_ASSERT(op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_F32);
|
|
1876
|
+
GGML_ASSERT(op->src[1]->type == GGML_TYPE_F32);
|
|
1877
|
+
GGML_ASSERT(op->type == GGML_TYPE_F32);
|
|
1878
|
+
|
|
1879
|
+
char base[256];
|
|
1880
|
+
char name[256];
|
|
1881
|
+
|
|
1882
|
+
snprintf(base, 256, "kernel_conv_2d_dw%s_%s_%s",
|
|
1883
|
+
tiled ? "_tiled" : "",
|
|
1884
|
+
ggml_type_name(op->src[0]->type), ggml_type_name(op->src[1]->type));
|
|
1885
|
+
snprintf(name, 256, "%s", base);
|
|
1886
|
+
|
|
1887
|
+
ggml_metal_pipeline_with_params res = ggml_metal_library_get_pipeline(lib, name);
|
|
1888
|
+
if (!res.pipeline) {
|
|
1889
|
+
res = ggml_metal_library_compile_pipeline(lib, base, name, nullptr);
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
return res;
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1831
1895
|
ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_3d(ggml_metal_library_t lib, const ggml_tensor * op) {
|
|
1832
1896
|
assert(op->op == GGML_OP_CONV_3D);
|
|
1833
1897
|
|
|
@@ -112,9 +112,10 @@ struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_cpy
|
|
|
112
112
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pool_1d (ggml_metal_library_t lib, const struct ggml_tensor * op, enum ggml_op_pool op_pool);
|
|
113
113
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pool_2d (ggml_metal_library_t lib, const struct ggml_tensor * op, enum ggml_op_pool op_pool);
|
|
114
114
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_get_rows (ggml_metal_library_t lib, enum ggml_type tsrc);
|
|
115
|
-
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_set_rows (ggml_metal_library_t lib,
|
|
115
|
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_set_rows (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
116
116
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_diag (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
117
117
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_repeat (ggml_metal_library_t lib, enum ggml_type tsrc);
|
|
118
|
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_concat (ggml_metal_library_t lib, enum ggml_type tsrc);
|
|
118
119
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_unary (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
119
120
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_glu (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
120
121
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_sum (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
@@ -149,7 +150,9 @@ struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_rope
|
|
|
149
150
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_im2col (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
150
151
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_1d (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
151
152
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_transpose_2d (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
153
|
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_col2im_1d (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
152
154
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
155
|
+
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_2d_dw (ggml_metal_library_t lib, const struct ggml_tensor * op, bool tiled);
|
|
153
156
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_conv_3d (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
154
157
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_upscale (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
155
158
|
struct ggml_metal_pipeline_with_params ggml_metal_library_get_pipeline_pad (ggml_metal_library_t lib, const struct ggml_tensor * op);
|
|
@@ -1123,13 +1123,24 @@ bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_te
|
|
|
1123
1123
|
return true;
|
|
1124
1124
|
case GGML_OP_CONCAT:
|
|
1125
1125
|
{
|
|
1126
|
-
// kernel_concat copies one float-sized value per element.
|
|
1127
|
-
// Other scalar types need a type-generic copy kernel first.
|
|
1128
1126
|
const enum ggml_type src0_type = op->src[0]->type;
|
|
1129
1127
|
const enum ggml_type src1_type = op->src[1]->type;
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1128
|
+
if (src0_type != src1_type || src0_type != op->type) {
|
|
1129
|
+
return false;
|
|
1130
|
+
}
|
|
1131
|
+
switch (src0_type) {
|
|
1132
|
+
case GGML_TYPE_F32:
|
|
1133
|
+
case GGML_TYPE_F16:
|
|
1134
|
+
case GGML_TYPE_I8:
|
|
1135
|
+
case GGML_TYPE_I16:
|
|
1136
|
+
case GGML_TYPE_I32:
|
|
1137
|
+
case GGML_TYPE_I64:
|
|
1138
|
+
return true;
|
|
1139
|
+
case GGML_TYPE_BF16:
|
|
1140
|
+
return has_bfloat;
|
|
1141
|
+
default:
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1133
1144
|
}
|
|
1134
1145
|
case GGML_OP_ADD:
|
|
1135
1146
|
case GGML_OP_SUB:
|
|
@@ -1146,6 +1157,11 @@ bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_te
|
|
|
1146
1157
|
(op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_F32) &&
|
|
1147
1158
|
op->src[1]->type == GGML_TYPE_F32 &&
|
|
1148
1159
|
op->type == GGML_TYPE_F32;
|
|
1160
|
+
case GGML_OP_COL2IM_1D:
|
|
1161
|
+
return (op->src[0]->type == GGML_TYPE_F32 || op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_BF16) &&
|
|
1162
|
+
op->type == op->src[0]->type &&
|
|
1163
|
+
ggml_is_contiguous(op->src[0]) &&
|
|
1164
|
+
ggml_is_contiguous(op);
|
|
1149
1165
|
case GGML_OP_CONV_3D:
|
|
1150
1166
|
return ggml_is_contiguous(op->src[0]) &&
|
|
1151
1167
|
ggml_is_contiguous(op->src[1]) &&
|
|
@@ -1173,6 +1189,7 @@ bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_te
|
|
|
1173
1189
|
case GGML_OP_RMS_NORM:
|
|
1174
1190
|
return has_simdgroup_reduction && (ggml_is_contiguous_rows(op->src[0]));
|
|
1175
1191
|
case GGML_OP_ROPE:
|
|
1192
|
+
case GGML_OP_ROPE_BACK:
|
|
1176
1193
|
return true;
|
|
1177
1194
|
case GGML_OP_IM2COL:
|
|
1178
1195
|
return ggml_is_contiguous(op->src[1]) && op->src[1]->type == GGML_TYPE_F32 && (op->type == GGML_TYPE_F16 || op->type == GGML_TYPE_F32);
|
|
@@ -1181,6 +1198,10 @@ bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_te
|
|
|
1181
1198
|
op->src[1]->type == GGML_TYPE_F32 &&
|
|
1182
1199
|
op->type == GGML_TYPE_F32 &&
|
|
1183
1200
|
(op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_F32);
|
|
1201
|
+
case GGML_OP_CONV_2D_DW:
|
|
1202
|
+
return op->src[1]->type == GGML_TYPE_F32 &&
|
|
1203
|
+
op->type == GGML_TYPE_F32 &&
|
|
1204
|
+
(op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_F32);
|
|
1184
1205
|
case GGML_OP_UPSCALE:
|
|
1185
1206
|
return op->src[0]->type == GGML_TYPE_F32;
|
|
1186
1207
|
case GGML_OP_POOL_1D:
|
|
@@ -1317,7 +1338,7 @@ bool ggml_metal_device_supports_op(ggml_metal_device_t dev, const struct ggml_te
|
|
|
1317
1338
|
return op->src[0]->type != GGML_TYPE_NVFP4;
|
|
1318
1339
|
case GGML_OP_SET_ROWS:
|
|
1319
1340
|
{
|
|
1320
|
-
if (op->src[0]->type != GGML_TYPE_F32) {
|
|
1341
|
+
if (op->src[0]->type != GGML_TYPE_F32 && op->src[0]->type != GGML_TYPE_F16) {
|
|
1321
1342
|
return false;
|
|
1322
1343
|
}
|
|
1323
1344
|
|
|
@@ -603,6 +603,16 @@ typedef struct {
|
|
|
603
603
|
uint64_t nb1;
|
|
604
604
|
} ggml_metal_kargs_conv_transpose_1d;
|
|
605
605
|
|
|
606
|
+
typedef struct {
|
|
607
|
+
int32_t T_in;
|
|
608
|
+
int32_t T_out;
|
|
609
|
+
int32_t OC;
|
|
610
|
+
int32_t K;
|
|
611
|
+
int32_t K_OC;
|
|
612
|
+
int32_t s0;
|
|
613
|
+
int32_t p0;
|
|
614
|
+
} ggml_metal_kargs_col2im_1d;
|
|
615
|
+
|
|
606
616
|
typedef struct {
|
|
607
617
|
int32_t IC;
|
|
608
618
|
int32_t IH;
|
|
@@ -646,6 +656,34 @@ typedef struct {
|
|
|
646
656
|
int32_t d1;
|
|
647
657
|
} ggml_metal_kargs_conv_2d;
|
|
648
658
|
|
|
659
|
+
typedef struct {
|
|
660
|
+
uint64_t nb00; // kernel strides
|
|
661
|
+
uint64_t nb01;
|
|
662
|
+
uint64_t nb02;
|
|
663
|
+
uint64_t nb10; // input strides
|
|
664
|
+
uint64_t nb11;
|
|
665
|
+
uint64_t nb12;
|
|
666
|
+
uint64_t nb13;
|
|
667
|
+
uint64_t nb0; // output strides
|
|
668
|
+
uint64_t nb1;
|
|
669
|
+
uint64_t nb2;
|
|
670
|
+
uint64_t nb3;
|
|
671
|
+
int32_t IW; // input width
|
|
672
|
+
int32_t IH; // input height
|
|
673
|
+
int32_t KW; // kernel width
|
|
674
|
+
int32_t KH; // kernel height
|
|
675
|
+
int32_t C; // channels (IC == OC for depthwise)
|
|
676
|
+
int32_t OW; // output width
|
|
677
|
+
int32_t OH; // output height
|
|
678
|
+
int32_t N; // batch size
|
|
679
|
+
int32_t s0; // stride x
|
|
680
|
+
int32_t s1; // stride y
|
|
681
|
+
int32_t p0; // padding x
|
|
682
|
+
int32_t p1; // padding y
|
|
683
|
+
int32_t d0; // dilation x
|
|
684
|
+
int32_t d1; // dilation y
|
|
685
|
+
} ggml_metal_kargs_conv_2d_dw;
|
|
686
|
+
|
|
649
687
|
typedef struct {
|
|
650
688
|
uint64_t ofs0;
|
|
651
689
|
uint64_t ofs1;
|
|
@@ -375,6 +375,7 @@ static int ggml_metal_op_encode_impl(ggml_metal_op_t ctx, int idx) {
|
|
|
375
375
|
n_fuse = ggml_metal_op_norm(ctx, idx);
|
|
376
376
|
} break;
|
|
377
377
|
case GGML_OP_ROPE:
|
|
378
|
+
case GGML_OP_ROPE_BACK:
|
|
378
379
|
{
|
|
379
380
|
n_fuse = ggml_metal_op_rope(ctx, idx);
|
|
380
381
|
} break;
|
|
@@ -386,6 +387,10 @@ static int ggml_metal_op_encode_impl(ggml_metal_op_t ctx, int idx) {
|
|
|
386
387
|
{
|
|
387
388
|
n_fuse = ggml_metal_op_conv_2d(ctx, idx);
|
|
388
389
|
} break;
|
|
390
|
+
case GGML_OP_CONV_2D_DW:
|
|
391
|
+
{
|
|
392
|
+
n_fuse = ggml_metal_op_conv_2d_dw(ctx, idx);
|
|
393
|
+
} break;
|
|
389
394
|
case GGML_OP_CONV_TRANSPOSE_1D:
|
|
390
395
|
{
|
|
391
396
|
n_fuse = ggml_metal_op_conv_transpose_1d(ctx, idx);
|
|
@@ -394,6 +399,10 @@ static int ggml_metal_op_encode_impl(ggml_metal_op_t ctx, int idx) {
|
|
|
394
399
|
{
|
|
395
400
|
n_fuse = ggml_metal_op_conv_transpose_2d(ctx, idx);
|
|
396
401
|
} break;
|
|
402
|
+
case GGML_OP_COL2IM_1D:
|
|
403
|
+
{
|
|
404
|
+
n_fuse = ggml_metal_op_col2im_1d(ctx, idx);
|
|
405
|
+
} break;
|
|
397
406
|
case GGML_OP_CONV_3D:
|
|
398
407
|
{
|
|
399
408
|
n_fuse = ggml_metal_op_conv_3d(ctx, idx);
|
|
@@ -556,7 +565,7 @@ int ggml_metal_op_concat(ggml_metal_op_t ctx, int idx) {
|
|
|
556
565
|
/*.dim =*/ dim,
|
|
557
566
|
};
|
|
558
567
|
|
|
559
|
-
auto pipeline =
|
|
568
|
+
auto pipeline = ggml_metal_library_get_pipeline_concat(lib, op->type);
|
|
560
569
|
|
|
561
570
|
ggml_metal_encoder_set_pipeline(enc, pipeline);
|
|
562
571
|
ggml_metal_encoder_set_bytes (enc, &args, sizeof(args), 0);
|
|
@@ -1197,7 +1206,7 @@ int ggml_metal_op_set_rows(ggml_metal_op_t ctx, int idx) {
|
|
|
1197
1206
|
GGML_TENSOR_LOCALS( int32_t, ne, op, ne);
|
|
1198
1207
|
GGML_TENSOR_LOCALS(uint64_t, nb, op, nb);
|
|
1199
1208
|
|
|
1200
|
-
auto pipeline = ggml_metal_library_get_pipeline_set_rows(lib, op
|
|
1209
|
+
auto pipeline = ggml_metal_library_get_pipeline_set_rows(lib, op);
|
|
1201
1210
|
|
|
1202
1211
|
const int32_t nk0 = ne0/ggml_blck_size(op->type);
|
|
1203
1212
|
|
|
@@ -3737,6 +3746,86 @@ int ggml_metal_op_conv_2d(ggml_metal_op_t ctx, int idx) {
|
|
|
3737
3746
|
return 1;
|
|
3738
3747
|
}
|
|
3739
3748
|
|
|
3749
|
+
int ggml_metal_op_conv_2d_dw(ggml_metal_op_t ctx, int idx) {
|
|
3750
|
+
ggml_tensor * op = ctx->node(idx);
|
|
3751
|
+
|
|
3752
|
+
ggml_metal_library_t lib = ctx->lib;
|
|
3753
|
+
ggml_metal_encoder_t enc = ctx->enc;
|
|
3754
|
+
|
|
3755
|
+
GGML_TENSOR_LOCALS( int32_t, ne0, op->src[0], ne);
|
|
3756
|
+
GGML_TENSOR_LOCALS(uint64_t, nb0, op->src[0], nb);
|
|
3757
|
+
GGML_TENSOR_LOCALS( int32_t, ne1, op->src[1], ne);
|
|
3758
|
+
GGML_TENSOR_LOCALS(uint64_t, nb1, op->src[1], nb);
|
|
3759
|
+
GGML_TENSOR_LOCALS( int32_t, ne, op, ne);
|
|
3760
|
+
GGML_TENSOR_LOCALS(uint64_t, nb, op, nb);
|
|
3761
|
+
|
|
3762
|
+
GGML_ASSERT(op->src[1]->type == GGML_TYPE_F32);
|
|
3763
|
+
GGML_ASSERT(op->type == GGML_TYPE_F32);
|
|
3764
|
+
GGML_ASSERT(op->src[0]->type == GGML_TYPE_F16 || op->src[0]->type == GGML_TYPE_F32);
|
|
3765
|
+
|
|
3766
|
+
const int32_t s0 = ((const int32_t *) op->op_params)[0];
|
|
3767
|
+
const int32_t s1 = ((const int32_t *) op->op_params)[1];
|
|
3768
|
+
const int32_t p0 = ((const int32_t *) op->op_params)[2];
|
|
3769
|
+
const int32_t p1 = ((const int32_t *) op->op_params)[3];
|
|
3770
|
+
const int32_t d0 = ((const int32_t *) op->op_params)[4];
|
|
3771
|
+
const int32_t d1 = ((const int32_t *) op->op_params)[5];
|
|
3772
|
+
|
|
3773
|
+
ggml_metal_kargs_conv_2d_dw args = {
|
|
3774
|
+
/*.nb00 =*/ nb00,
|
|
3775
|
+
/*.nb01 =*/ nb01,
|
|
3776
|
+
/*.nb02 =*/ nb03,
|
|
3777
|
+
/*.nb10 =*/ nb10,
|
|
3778
|
+
/*.nb11 =*/ nb11,
|
|
3779
|
+
/*.nb12 =*/ nb12,
|
|
3780
|
+
/*.nb13 =*/ nb13,
|
|
3781
|
+
/*.nb0 =*/ nb0,
|
|
3782
|
+
/*.nb1 =*/ nb1,
|
|
3783
|
+
/*.nb2 =*/ nb2,
|
|
3784
|
+
/*.nb3 =*/ nb3,
|
|
3785
|
+
/*.IW =*/ ne10,
|
|
3786
|
+
/*.IH =*/ ne11,
|
|
3787
|
+
/*.KW =*/ ne00,
|
|
3788
|
+
/*.KH =*/ ne01,
|
|
3789
|
+
/*.C =*/ ne12,
|
|
3790
|
+
/*.OW =*/ ne0,
|
|
3791
|
+
/*.OH =*/ ne1,
|
|
3792
|
+
/*.N =*/ ne13,
|
|
3793
|
+
/*.s0 =*/ s0,
|
|
3794
|
+
/*.s1 =*/ s1,
|
|
3795
|
+
/*.p0 =*/ p0,
|
|
3796
|
+
/*.p1 =*/ p1,
|
|
3797
|
+
/*.d0 =*/ d0,
|
|
3798
|
+
/*.d1 =*/ d1,
|
|
3799
|
+
};
|
|
3800
|
+
|
|
3801
|
+
const bool use_tiled = (nb12 < nb10);
|
|
3802
|
+
|
|
3803
|
+
auto pipeline = ggml_metal_library_get_pipeline_conv_2d_dw(lib, op, use_tiled);
|
|
3804
|
+
|
|
3805
|
+
int nth = ggml_metal_pipeline_max_theads_per_threadgroup(pipeline);
|
|
3806
|
+
nth = std::min(nth, 256);
|
|
3807
|
+
nth = std::max(nth, 1);
|
|
3808
|
+
|
|
3809
|
+
const int32_t OW = ne0;
|
|
3810
|
+
const int32_t OH = ne1;
|
|
3811
|
+
const int32_t C = ne12;
|
|
3812
|
+
const int32_t N = ne13;
|
|
3813
|
+
|
|
3814
|
+
const int tg_x = use_tiled ? (C + nth - 1) / nth : (OW + nth - 1) / nth;
|
|
3815
|
+
const int tg_y = OH;
|
|
3816
|
+
const int tg_z = use_tiled ? OW * N : C * N;
|
|
3817
|
+
|
|
3818
|
+
ggml_metal_encoder_set_pipeline(enc, pipeline);
|
|
3819
|
+
ggml_metal_encoder_set_bytes (enc, &args, sizeof(args), 0);
|
|
3820
|
+
ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op->src[0]), 1);
|
|
3821
|
+
ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op->src[1]), 2);
|
|
3822
|
+
ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op), 3);
|
|
3823
|
+
|
|
3824
|
+
ggml_metal_encoder_dispatch_threadgroups(enc, tg_x, tg_y, tg_z, nth, 1, 1);
|
|
3825
|
+
|
|
3826
|
+
return 1;
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3740
3829
|
int ggml_metal_op_conv_3d(ggml_metal_op_t ctx, int idx) {
|
|
3741
3830
|
ggml_tensor * op = ctx->node(idx);
|
|
3742
3831
|
|
|
@@ -3853,6 +3942,47 @@ int ggml_metal_op_conv_transpose_1d(ggml_metal_op_t ctx, int idx) {
|
|
|
3853
3942
|
return 1;
|
|
3854
3943
|
}
|
|
3855
3944
|
|
|
3945
|
+
int ggml_metal_op_col2im_1d(ggml_metal_op_t ctx, int idx) {
|
|
3946
|
+
ggml_tensor * op = ctx->node(idx);
|
|
3947
|
+
|
|
3948
|
+
ggml_metal_library_t lib = ctx->lib;
|
|
3949
|
+
ggml_metal_encoder_t enc = ctx->enc;
|
|
3950
|
+
|
|
3951
|
+
const int32_t s0 = ((const int32_t *)(op->op_params))[0];
|
|
3952
|
+
const int32_t OC = ((const int32_t *)(op->op_params))[1];
|
|
3953
|
+
const int32_t p0 = ((const int32_t *)(op->op_params))[2];
|
|
3954
|
+
|
|
3955
|
+
const int32_t K_OC = (int32_t) op->src[0]->ne[0];
|
|
3956
|
+
const int32_t T_in = (int32_t) op->src[0]->ne[1];
|
|
3957
|
+
const int32_t K = K_OC / OC;
|
|
3958
|
+
const int32_t T_out = (int32_t) op->ne[0];
|
|
3959
|
+
|
|
3960
|
+
ggml_metal_kargs_col2im_1d args = {
|
|
3961
|
+
/*.T_in =*/ T_in,
|
|
3962
|
+
/*.T_out =*/ T_out,
|
|
3963
|
+
/*.OC =*/ OC,
|
|
3964
|
+
/*.K =*/ K,
|
|
3965
|
+
/*.K_OC =*/ K_OC,
|
|
3966
|
+
/*.s0 =*/ s0,
|
|
3967
|
+
/*.p0 =*/ p0,
|
|
3968
|
+
};
|
|
3969
|
+
|
|
3970
|
+
auto pipeline = ggml_metal_library_get_pipeline_col2im_1d(lib, op);
|
|
3971
|
+
|
|
3972
|
+
const int total = T_out * OC;
|
|
3973
|
+
const int nth = 256;
|
|
3974
|
+
const int ntg = (total + nth - 1) / nth;
|
|
3975
|
+
|
|
3976
|
+
ggml_metal_encoder_set_pipeline(enc, pipeline);
|
|
3977
|
+
ggml_metal_encoder_set_bytes (enc, &args, sizeof(args), 0);
|
|
3978
|
+
ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op->src[0]), 1);
|
|
3979
|
+
ggml_metal_encoder_set_buffer (enc, ggml_metal_get_buffer_id(op), 2);
|
|
3980
|
+
|
|
3981
|
+
ggml_metal_encoder_dispatch_threadgroups(enc, ntg, 1, 1, nth, 1, 1);
|
|
3982
|
+
|
|
3983
|
+
return 1;
|
|
3984
|
+
}
|
|
3985
|
+
|
|
3856
3986
|
int ggml_metal_op_conv_transpose_2d(ggml_metal_op_t ctx, int idx) {
|
|
3857
3987
|
ggml_tensor * op = ctx->node(idx);
|
|
3858
3988
|
|
|
@@ -75,9 +75,11 @@ int ggml_metal_op_norm (ggml_metal_op_t ctx, int idx);
|
|
|
75
75
|
int ggml_metal_op_rope (ggml_metal_op_t ctx, int idx);
|
|
76
76
|
int ggml_metal_op_im2col (ggml_metal_op_t ctx, int idx);
|
|
77
77
|
int ggml_metal_op_conv_2d (ggml_metal_op_t ctx, int idx);
|
|
78
|
+
int ggml_metal_op_conv_2d_dw (ggml_metal_op_t ctx, int idx);
|
|
78
79
|
int ggml_metal_op_conv_3d (ggml_metal_op_t ctx, int idx);
|
|
79
80
|
int ggml_metal_op_conv_transpose_1d (ggml_metal_op_t ctx, int idx);
|
|
80
81
|
int ggml_metal_op_conv_transpose_2d (ggml_metal_op_t ctx, int idx);
|
|
82
|
+
int ggml_metal_op_col2im_1d (ggml_metal_op_t ctx, int idx);
|
|
81
83
|
int ggml_metal_op_upscale (ggml_metal_op_t ctx, int idx);
|
|
82
84
|
int ggml_metal_op_pad (ggml_metal_op_t ctx, int idx);
|
|
83
85
|
int ggml_metal_op_pad_reflect_1d (ggml_metal_op_t ctx, int idx);
|