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
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
#include "../op_table.h"
|
|
2
2
|
#include "../utils.h"
|
|
3
|
+
|
|
4
|
+
#include <openvino/op/constant.hpp>
|
|
3
5
|
#include <openvino/op/reshape.hpp>
|
|
6
|
+
#include <openvino/op/slice.hpp>
|
|
7
|
+
#include <set>
|
|
8
|
+
|
|
4
9
|
namespace ov {
|
|
5
10
|
namespace frontend {
|
|
6
11
|
namespace ggml {
|
|
@@ -9,42 +14,102 @@ namespace op {
|
|
|
9
14
|
OutputVector translate_view(const NodeContext & context) {
|
|
10
15
|
num_inputs_check(context, 1, 1);
|
|
11
16
|
|
|
12
|
-
if (context.
|
|
13
|
-
|
|
14
|
-
return rename_outputs_with_suffix({process_view_input(context, 0, dst_shape[2] * dst_shape[3])},
|
|
15
|
-
context.get_name());
|
|
17
|
+
if (!context.is_static()) {
|
|
18
|
+
return {context.get_input(0)};
|
|
16
19
|
}
|
|
17
|
-
// op_case 3
|
|
18
|
-
if (context.get_op_case() == 3) {
|
|
19
|
-
auto input = context.get_input(0);
|
|
20
|
-
auto input_ov_shape = input.get_partial_shape();
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
auto input = context.get_input(0);
|
|
22
|
+
auto src_shape = context.get_input_shape(0);
|
|
23
|
+
auto dst_shape = context.get_output_shape();
|
|
24
|
+
|
|
25
|
+
if (src_shape.rank().is_dynamic() || dst_shape.rank().is_dynamic()) {
|
|
26
|
+
return {input};
|
|
27
|
+
}
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
int64_t src_elems = 1, dst_elems = 1;
|
|
30
|
+
for (int64_t i = 0; i < src_shape.rank().get_length(); ++i) {
|
|
31
|
+
if (src_shape[i].is_dynamic()) {
|
|
32
|
+
return {input};
|
|
27
33
|
}
|
|
34
|
+
src_elems *= src_shape[i].get_length();
|
|
35
|
+
}
|
|
36
|
+
for (int64_t i = 0; i < dst_shape.rank().get_length(); ++i) {
|
|
37
|
+
if (dst_shape[i].is_dynamic()) {
|
|
38
|
+
return {input};
|
|
39
|
+
}
|
|
40
|
+
dst_elems *= dst_shape[i].get_length();
|
|
41
|
+
}
|
|
28
42
|
|
|
29
|
-
|
|
43
|
+
if (dst_elems >= src_elems) {
|
|
44
|
+
return {input};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
auto src_stride = context.get_input_stride(0);
|
|
48
|
+
auto dst_stride = context.get_output_stride();
|
|
49
|
+
size_t view_offset = context.get_output_op_offset();
|
|
30
50
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (size_t i = 0; i <
|
|
34
|
-
if (
|
|
35
|
-
|
|
51
|
+
bool same_stride = (src_stride.size() == dst_stride.size());
|
|
52
|
+
if (same_stride) {
|
|
53
|
+
for (size_t i = 0; i < src_stride.size(); ++i) {
|
|
54
|
+
if (src_stride[i] != dst_stride[i]) {
|
|
55
|
+
same_stride = false;
|
|
36
56
|
break;
|
|
37
57
|
}
|
|
38
58
|
}
|
|
59
|
+
}
|
|
39
60
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
auto stride = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
43
|
-
auto axes = ov::op::v0::Constant::create(ov::element::i64, {1}, {slice_dim});
|
|
44
|
-
auto sliced = std::make_shared<ov::op::v8::Slice>(input, begin, end, stride, axes);
|
|
45
|
-
return {sliced};
|
|
61
|
+
if (!same_stride) {
|
|
62
|
+
return {input};
|
|
46
63
|
}
|
|
47
|
-
|
|
64
|
+
|
|
65
|
+
auto src_ov_shape = src_shape.to_shape();
|
|
66
|
+
auto dst_ov_shape = dst_shape.to_shape();
|
|
67
|
+
size_t ndims = src_ov_shape.size();
|
|
68
|
+
if (dst_ov_shape.size() != ndims) {
|
|
69
|
+
return {input};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
std::vector<int> diff_dims;
|
|
73
|
+
for (size_t i = 0; i < ndims; ++i) {
|
|
74
|
+
if (src_ov_shape[i] != dst_ov_shape[i]) {
|
|
75
|
+
diff_dims.push_back(static_cast<int>(i));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (diff_dims.size() != 1) {
|
|
80
|
+
return {input};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
int slice_dim = diff_dims[0];
|
|
84
|
+
int64_t dim_size = static_cast<int64_t>(src_ov_shape[slice_dim]);
|
|
85
|
+
|
|
86
|
+
size_t ov_stride_for_dim = 1;
|
|
87
|
+
for (size_t i = slice_dim + 1; i < ndims; ++i) {
|
|
88
|
+
ov_stride_for_dim *= src_ov_shape[i];
|
|
89
|
+
}
|
|
90
|
+
size_t elem_size = src_stride.back();
|
|
91
|
+
if (elem_size == 0) {
|
|
92
|
+
elem_size = 1;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
int64_t begin_val = 0;
|
|
96
|
+
if (ov_stride_for_dim > 0 && elem_size > 0) {
|
|
97
|
+
begin_val = static_cast<int64_t>((view_offset / elem_size) / ov_stride_for_dim);
|
|
98
|
+
}
|
|
99
|
+
int64_t end_val = begin_val + static_cast<int64_t>(dst_ov_shape[slice_dim]);
|
|
100
|
+
|
|
101
|
+
if (begin_val < 0 || end_val > dim_size) {
|
|
102
|
+
return {input};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
auto sliced =
|
|
106
|
+
std::make_shared<ov::op::v8::Slice>(input, ov::op::v0::Constant::create(ov::element::i64, {1}, {begin_val}),
|
|
107
|
+
ov::op::v0::Constant::create(ov::element::i64, {1}, {end_val}),
|
|
108
|
+
ov::op::v0::Constant::create(ov::element::i64, {1}, {1}),
|
|
109
|
+
ov::op::v0::Constant::create(ov::element::i64, {1}, {slice_dim}));
|
|
110
|
+
|
|
111
|
+
sliced->set_friendly_name(context.get_output_name());
|
|
112
|
+
return {sliced->output(0)};
|
|
48
113
|
}
|
|
49
114
|
|
|
50
115
|
} // namespace op
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
#include <openvino/op/add.hpp>
|
|
6
6
|
#include <openvino/op/divide.hpp>
|
|
7
7
|
#include <openvino/op/gather.hpp>
|
|
8
|
+
#include <openvino/op/gelu.hpp>
|
|
8
9
|
#include <openvino/op/matmul.hpp>
|
|
9
10
|
#include <openvino/op/multiply.hpp>
|
|
10
11
|
#include <openvino/op/subtract.hpp>
|
|
12
|
+
#include <openvino/op/tanh.hpp>
|
|
11
13
|
|
|
12
14
|
namespace ov {
|
|
13
15
|
namespace frontend {
|
|
@@ -16,29 +18,45 @@ namespace ggml {
|
|
|
16
18
|
std::unordered_map<std::string, CreatorFunction> get_supported_ops() {
|
|
17
19
|
using namespace ov::op;
|
|
18
20
|
return {
|
|
19
|
-
{"GGML_OP_ADD",
|
|
20
|
-
{"GGML_OP_ADD1",
|
|
21
|
-
{"
|
|
22
|
-
{"
|
|
23
|
-
{"
|
|
24
|
-
{"
|
|
25
|
-
{"
|
|
26
|
-
{"
|
|
27
|
-
{"
|
|
28
|
-
{"
|
|
29
|
-
{"
|
|
30
|
-
{"
|
|
31
|
-
{"
|
|
32
|
-
{"
|
|
33
|
-
{"
|
|
34
|
-
{"
|
|
35
|
-
{"
|
|
36
|
-
{"
|
|
37
|
-
{"
|
|
38
|
-
{"
|
|
39
|
-
{"
|
|
40
|
-
{"
|
|
41
|
-
{"
|
|
21
|
+
{"GGML_OP_ADD", op::translate_1to1_match_2_inputs<v1::Add> },
|
|
22
|
+
{"GGML_OP_ADD1", op::translate_1to1_match_2_inputs<v1::Add> },
|
|
23
|
+
{"GGML_OP_ADD_ID", op::translate_add_id },
|
|
24
|
+
{"GGML_OP_CONCAT", op::translate_concat },
|
|
25
|
+
{"GGML_OP_CONT", op::translate_cont },
|
|
26
|
+
{"GGML_OP_DIV", op::translate_div },
|
|
27
|
+
{"GGML_OP_GET_ROWS", op::translate_get_rows },
|
|
28
|
+
{"GGML_OP_IM2COL", op::translate_im2col },
|
|
29
|
+
{"GGML_OP_MUL", op::translate_1to1_match_2_inputs<v1::Multiply>},
|
|
30
|
+
{"GGML_OP_MUL_MAT", op::translate_mulmat },
|
|
31
|
+
{"GGML_OP_MUL_MAT_ID", op::translate_mul_mat_id },
|
|
32
|
+
{"GGML_OP_PERMUTE", op::translate_permute },
|
|
33
|
+
{"GGML_OP_RESHAPE", op::translate_reshape },
|
|
34
|
+
{"GGML_OP_RMS_NORM", op::translate_rms_norm },
|
|
35
|
+
{"GGML_OP_NORM", op::translate_norm },
|
|
36
|
+
{"GGML_OP_L2_NORM", op::translate_l2_norm },
|
|
37
|
+
{"GGML_OP_SUM_ROWS", op::translate_sum_rows },
|
|
38
|
+
{"GGML_OP_ROPE", op::translate_rope },
|
|
39
|
+
{"GGML_OP_SCALE", op::translate_scale },
|
|
40
|
+
{"GGML_OP_SOFT_MAX", op::translate_soft_max },
|
|
41
|
+
{"GGML_OP_ARGSORT", op::translate_argsort },
|
|
42
|
+
{"GGML_OP_SUB", op::translate_1to1_match_2_inputs<v1::Subtract>},
|
|
43
|
+
{"GGML_OP_TRANSPOSE", op::translate_transpose },
|
|
44
|
+
{"GGML_UNARY_OP_GELU", op::translate_1to1_match_1_input<v7::Gelu> },
|
|
45
|
+
{"GGML_UNARY_OP_SILU", op::translate_unary_silu },
|
|
46
|
+
{"GGML_UNARY_OP_SOFTPLUS", op::translate_unary_softplus },
|
|
47
|
+
{"GGML_UNARY_OP_TANH", op::translate_1to1_match_1_input<v0::Tanh> },
|
|
48
|
+
{"GGML_OP_VIEW", op::translate_view },
|
|
49
|
+
{"GGML_GLU_OP_SWIGLU", op::translate_glu_swiglu },
|
|
50
|
+
{"GGML_GLU_OP_SWIGLU_OAI", op::translate_glu_swiglu_oai },
|
|
51
|
+
{"GGML_GLU_OP_GEGLU", op::translate_glu_geglu },
|
|
52
|
+
{"GGML_OP_SET_ROWS", op::translate_set_rows },
|
|
53
|
+
{"GGML_OP_CPY", op::translate_cpy },
|
|
54
|
+
{"GGML_OP_FLASH_ATTN_EXT", op::translate_flash_attn_ext },
|
|
55
|
+
{"GGML_OP_CLAMP", op::translate_clamp },
|
|
56
|
+
{"GGML_OP_PAD", op::translate_pad },
|
|
57
|
+
{"GGML_OP_SSM_CONV", op::translate_ssm_conv },
|
|
58
|
+
{"GGML_OP_GATED_DELTA_NET", op::translate_gated_delta_net },
|
|
59
|
+
{"GGML_OP_REPEAT", op::translate_repeat },
|
|
42
60
|
};
|
|
43
61
|
}
|
|
44
62
|
|
|
@@ -8,30 +8,43 @@ namespace ggml {
|
|
|
8
8
|
|
|
9
9
|
namespace op {
|
|
10
10
|
|
|
11
|
-
#define GGML_OP_CONVERTER(op) OutputVector op(const NodeContext& context)
|
|
11
|
+
#define GGML_OP_CONVERTER(op) OutputVector op(const NodeContext & context)
|
|
12
12
|
|
|
13
|
-
GGML_OP_CONVERTER(translate_add);
|
|
14
13
|
GGML_OP_CONVERTER(translate_cont);
|
|
14
|
+
GGML_OP_CONVERTER(translate_concat);
|
|
15
|
+
GGML_OP_CONVERTER(translate_add_id);
|
|
16
|
+
GGML_OP_CONVERTER(translate_div);
|
|
15
17
|
GGML_OP_CONVERTER(translate_get_rows);
|
|
16
|
-
GGML_OP_CONVERTER(
|
|
18
|
+
GGML_OP_CONVERTER(translate_im2col);
|
|
17
19
|
GGML_OP_CONVERTER(translate_mulmat);
|
|
20
|
+
GGML_OP_CONVERTER(translate_mul_mat_id);
|
|
18
21
|
GGML_OP_CONVERTER(translate_permute);
|
|
19
22
|
GGML_OP_CONVERTER(translate_reshape);
|
|
20
23
|
GGML_OP_CONVERTER(translate_rms_norm);
|
|
24
|
+
GGML_OP_CONVERTER(translate_norm);
|
|
25
|
+
GGML_OP_CONVERTER(translate_l2_norm);
|
|
26
|
+
GGML_OP_CONVERTER(translate_sum_rows);
|
|
21
27
|
GGML_OP_CONVERTER(translate_rope);
|
|
22
28
|
GGML_OP_CONVERTER(translate_scale);
|
|
23
29
|
GGML_OP_CONVERTER(translate_unary_silu);
|
|
24
|
-
GGML_OP_CONVERTER(
|
|
30
|
+
GGML_OP_CONVERTER(translate_unary_softplus);
|
|
25
31
|
GGML_OP_CONVERTER(translate_soft_max);
|
|
26
32
|
GGML_OP_CONVERTER(translate_transpose);
|
|
27
33
|
GGML_OP_CONVERTER(translate_view);
|
|
28
34
|
GGML_OP_CONVERTER(translate_glu_swiglu);
|
|
35
|
+
GGML_OP_CONVERTER(translate_glu_swiglu_oai);
|
|
29
36
|
GGML_OP_CONVERTER(translate_glu_geglu);
|
|
30
37
|
GGML_OP_CONVERTER(translate_set_rows);
|
|
31
38
|
GGML_OP_CONVERTER(translate_cpy);
|
|
39
|
+
GGML_OP_CONVERTER(translate_argsort);
|
|
32
40
|
GGML_OP_CONVERTER(translate_flash_attn_ext);
|
|
41
|
+
GGML_OP_CONVERTER(translate_clamp);
|
|
42
|
+
GGML_OP_CONVERTER(translate_pad);
|
|
43
|
+
GGML_OP_CONVERTER(translate_ssm_conv);
|
|
44
|
+
GGML_OP_CONVERTER(translate_gated_delta_net);
|
|
45
|
+
GGML_OP_CONVERTER(translate_repeat);
|
|
33
46
|
|
|
34
|
-
}
|
|
47
|
+
} // namespace op
|
|
35
48
|
|
|
36
49
|
std::unordered_map<std::string, CreatorFunction> get_supported_ops();
|
|
37
50
|
|
data/ext/sources/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include "mark_decompression_convert_constant_folding.h"
|
|
4
|
-
#include "openvino/pass/matcher_pass.hpp"
|
|
5
4
|
#include "openvino/core/visibility.hpp"
|
|
5
|
+
#include "openvino/pass/matcher_pass.hpp"
|
|
6
6
|
|
|
7
7
|
#ifdef OPENVINO_STATIC_LIBRARY
|
|
8
8
|
# define TRANSFORMATIONS_API
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#include <memory>
|
|
14
14
|
#include <openvino/core/node.hpp>
|
|
15
15
|
#include <openvino/core/preprocess/pre_post_process.hpp>
|
|
16
|
+
#include <openvino/core/type/element_type.hpp>
|
|
16
17
|
#include <openvino/op/add.hpp>
|
|
17
18
|
#include <openvino/op/broadcast.hpp>
|
|
18
19
|
#include <openvino/op/concat.hpp>
|
|
@@ -77,49 +78,48 @@ ov::pass::MakeStateful::ParamResPairs get_kv_param_res_pairs(
|
|
|
77
78
|
return pairs;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
void
|
|
81
|
-
|
|
82
|
-
auto create_sliced_mask = [&](const std::string & mask_name, const std::string & sliced_name, bool is_static) {
|
|
81
|
+
void add_sliced_mask_stateful(TensorMap & tensor_map) {
|
|
82
|
+
auto create_sliced_mask = [&](const std::string & mask_name, const std::string & sliced_name) {
|
|
83
83
|
if ((tensor_map.find(mask_name) != tensor_map.end()) &&
|
|
84
84
|
(tensor_map.find("token_len_per_seq") != tensor_map.end())) {
|
|
85
85
|
auto token_len_per_seq = tensor_map.at("token_len_per_seq").get_node_shared_ptr();
|
|
86
86
|
auto mask = tensor_map.at(mask_name).get_node_shared_ptr();
|
|
87
|
-
std::shared_ptr<ov::Node> mask_sliced;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
auto zero = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});
|
|
108
|
-
auto one = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
109
|
-
auto two = ov::op::v0::Constant::create(ov::element::i64, {1}, {2});
|
|
110
|
-
mask_sliced = std::make_shared<ov::op::v8::Slice>(mask, zero, token_len_per_seq, one, two);
|
|
111
|
-
mask_sliced = std::make_shared<ov::op::v0::Convert>(mask_sliced, ov::element::f16);
|
|
112
|
-
mask_sliced->set_friendly_name(sliced_name);
|
|
113
|
-
}
|
|
87
|
+
std::shared_ptr<ov::Node> mask_sliced = mask;
|
|
88
|
+
auto one = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
89
|
+
auto zero = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});
|
|
90
|
+
auto three = ov::op::v0::Constant::create(ov::element::i64, {1}, {3});
|
|
91
|
+
auto neg_one = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});
|
|
92
|
+
|
|
93
|
+
auto step = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
94
|
+
auto axes = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});
|
|
95
|
+
|
|
96
|
+
auto inp_pos = tensor_map.at("inp_pos").get_node_shared_ptr();
|
|
97
|
+
auto last_inp_pos = std::make_shared<ov::op::v8::Gather>(inp_pos, neg_one, three);
|
|
98
|
+
auto last_inp_pos_1d = std::make_shared<ov::op::v1::Reshape>(
|
|
99
|
+
last_inp_pos, ov::op::v0::Constant::create(ov::element::i64, {1}, {1}), false);
|
|
100
|
+
auto last_inp_pos_cvt = std::make_shared<ov::op::v0::Convert>(last_inp_pos_1d, ov::element::i64);
|
|
101
|
+
auto last_inp_pos_inc = std::make_shared<ov::op::v1::Add>(last_inp_pos_cvt, one);
|
|
102
|
+
|
|
103
|
+
mask_sliced = std::make_shared<ov::op::v8::Slice>(mask, zero, last_inp_pos_inc, step, axes);
|
|
104
|
+
mask_sliced = std::make_shared<ov::op::v0::Convert>(mask_sliced, ov::element::f16);
|
|
105
|
+
mask_sliced->set_friendly_name(sliced_name);
|
|
106
|
+
|
|
114
107
|
tensor_map.insert({sliced_name, mask_sliced->output(0)});
|
|
115
108
|
}
|
|
116
109
|
};
|
|
117
110
|
|
|
118
|
-
create_sliced_mask("self_kq_mask", "KQ_mask_sliced"
|
|
119
|
-
create_sliced_mask("self_kq_mask_swa", "KQ_mask_swa_sliced"
|
|
111
|
+
create_sliced_mask("self_kq_mask", "KQ_mask_sliced");
|
|
112
|
+
create_sliced_mask("self_kq_mask_swa", "KQ_mask_swa_sliced");
|
|
120
113
|
}
|
|
121
114
|
|
|
122
115
|
void add_rope_sin_cos(TensorMap & tensor_map, GgmlDecoder & ggml_model_decoder) {
|
|
116
|
+
// When ROPE ops in the graph have divergent op_params (e.g. gemma4's mixed
|
|
117
|
+
// SWA/non-SWA layers with different n_dims or freq_base), a shared sin/cos
|
|
118
|
+
// precompute cannot broadcast across every ROPE use. Skip it here and let
|
|
119
|
+
// translate_rope() build sin/cos per-op from its own op_params.
|
|
120
|
+
if (ggml_model_decoder.has_mixed_rope_params()) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
123
|
int32_t * rope_params = ggml_model_decoder.get_rope_params();
|
|
124
124
|
if (tensor_map.find("inp_pos") == tensor_map.end() || rope_params == nullptr) {
|
|
125
125
|
return;
|
|
@@ -142,8 +142,11 @@ void add_rope_sin_cos(TensorMap & tensor_map, GgmlDecoder & ggml_model_decoder)
|
|
|
142
142
|
|
|
143
143
|
// Create common patterns
|
|
144
144
|
void preprocess(TensorMap & tensor_map, GgmlDecoder & ggml_model_decoder) {
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
if (ggml_model_decoder.is_stateful()) {
|
|
146
|
+
add_sliced_mask_stateful(tensor_map);
|
|
147
|
+
}
|
|
148
|
+
// This optimization is error-prone
|
|
149
|
+
// add_rope_sin_cos(tensor_map, ggml_model_decoder);
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
} // namespace
|
|
@@ -288,19 +291,19 @@ std::shared_ptr<Model> TranslateSession::apply_transformations(std::shared_ptr<M
|
|
|
288
291
|
if (ggml_model_decoder->is_stateful()) {
|
|
289
292
|
auto output_names = ggml_model_decoder->get_model_output_names();
|
|
290
293
|
std::map<std::string, int> model_output_indexes;
|
|
291
|
-
for (size_t i=0; i<output_names.size(); i++) {
|
|
294
|
+
for (size_t i = 0; i < output_names.size(); i++) {
|
|
292
295
|
model_output_indexes.insert(std::make_pair(output_names[i], i));
|
|
293
296
|
}
|
|
294
297
|
ov::preprocess::PrePostProcessor ppp(model);
|
|
295
|
-
for (size_t i=0; i<model->get_output_size(); i++) {
|
|
298
|
+
for (size_t i = 0; i < model->get_output_size(); i++) {
|
|
296
299
|
auto output_friendly_name = model->output(i).get_node_shared_ptr()->get_friendly_name();
|
|
297
300
|
auto output_id = model_output_indexes[output_friendly_name];
|
|
298
301
|
auto model_output_shape = model->output(i).get_partial_shape();
|
|
299
302
|
auto decoder_output_shape = ggml_model_decoder->get_output_shape(output_id);
|
|
300
|
-
if (model_output_shape.rank().is_static() && decoder_output_shape.rank().is_static()
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
ppp.output(i).postprocess().custom([](const ov::Output<ov::Node
|
|
303
|
+
if (model_output_shape.rank().is_static() && decoder_output_shape.rank().is_static() &&
|
|
304
|
+
model_output_shape.rank().get_length() + 1 == decoder_output_shape.rank().get_length() &&
|
|
305
|
+
decoder_output_shape[0].is_static() && decoder_output_shape[0].get_length() == 1) {
|
|
306
|
+
ppp.output(i).postprocess().custom([](const ov::Output<ov::Node> & node) {
|
|
304
307
|
auto axes = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{1}, {0});
|
|
305
308
|
return std::make_shared<ov::op::v0::Unsqueeze>(node, axes);
|
|
306
309
|
});
|
|
@@ -9,16 +9,17 @@ namespace ggml {
|
|
|
9
9
|
|
|
10
10
|
class TranslateSession {
|
|
11
11
|
public:
|
|
12
|
-
TranslateSession(const frontend::InputModel::Ptr& input_model,
|
|
13
|
-
const std::unordered_map<std::string, CreatorFunction
|
|
12
|
+
TranslateSession(const frontend::InputModel::Ptr & input_model,
|
|
13
|
+
const std::unordered_map<std::string, CreatorFunction> & translator_map,
|
|
14
|
+
bool naive = false);
|
|
14
15
|
|
|
15
16
|
std::shared_ptr<Model> get_converted_model();
|
|
16
|
-
std::shared_ptr<Model> translate_graph(const frontend::InputModel::Ptr& input_model);
|
|
17
|
+
std::shared_ptr<Model> translate_graph(const frontend::InputModel::Ptr & input_model);
|
|
17
18
|
|
|
18
19
|
private:
|
|
19
20
|
std::shared_ptr<Model> apply_transformations(std::shared_ptr<Model> model);
|
|
20
21
|
const frontend::InputModel::Ptr m_input_model;
|
|
21
|
-
const std::unordered_map<std::string, CreatorFunction
|
|
22
|
+
const std::unordered_map<std::string, CreatorFunction> & m_translator_map;
|
|
22
23
|
std::shared_ptr<Model> m_ov_model;
|
|
23
24
|
bool m_naive;
|
|
24
25
|
};
|