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
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
#include <cstdint>
|
|
4
4
|
#include <map>
|
|
5
5
|
#include <openvino/core/node.hpp>
|
|
6
|
+
#include <openvino/core/partial_shape.hpp>
|
|
7
|
+
#include <openvino/core/shape.hpp>
|
|
6
8
|
#include <openvino/frontend/decoder.hpp>
|
|
7
9
|
#include <string>
|
|
8
10
|
|
|
@@ -12,22 +14,50 @@ namespace ggml {
|
|
|
12
14
|
|
|
13
15
|
class GgmlDecoder : public DecoderBase {
|
|
14
16
|
public:
|
|
15
|
-
virtual ov::Any get_attribute(const std::string& name) const = 0;
|
|
17
|
+
virtual ov::Any get_attribute(const std::string & name) const = 0;
|
|
16
18
|
|
|
17
|
-
virtual PartialShape get_input_shape(int node_idx, const std::string& name) const = 0;
|
|
19
|
+
virtual PartialShape get_input_shape(int node_idx, const std::string & name) const = 0;
|
|
18
20
|
|
|
19
|
-
virtual std::vector<size_t> get_input_stride(int node_idx, const std::string& name) const = 0;
|
|
21
|
+
virtual std::vector<size_t> get_input_stride(int node_idx, const std::string & name) const = 0;
|
|
20
22
|
|
|
21
|
-
virtual
|
|
23
|
+
virtual size_t get_view_input_size(int node_idx, const std::string & name) const = 0;
|
|
24
|
+
|
|
25
|
+
virtual size_t get_view_input_offset(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
26
|
+
|
|
27
|
+
virtual size_t get_view_input_src_offset(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
28
|
+
|
|
29
|
+
virtual std::vector<size_t> get_view_input_stride(int node_idx,
|
|
30
|
+
const std::string & name,
|
|
31
|
+
size_t view_index) const = 0;
|
|
32
|
+
|
|
33
|
+
virtual std::vector<size_t> get_view_input_src_stride(int node_idx,
|
|
34
|
+
const std::string & name,
|
|
35
|
+
size_t view_index) const = 0;
|
|
36
|
+
|
|
37
|
+
virtual Shape get_view_input_ggml_shape(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
38
|
+
|
|
39
|
+
virtual Shape get_view_input_src_ggml_shape(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
40
|
+
|
|
41
|
+
virtual PartialShape get_view_input_ov_shape(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
42
|
+
|
|
43
|
+
virtual PartialShape get_view_input_src_ov_shape(int node_idx,
|
|
44
|
+
const std::string & name,
|
|
45
|
+
size_t view_index) const = 0;
|
|
46
|
+
|
|
47
|
+
virtual std::string get_view_input_name(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
48
|
+
|
|
49
|
+
virtual std::string get_view_input_src_name(int node_idx, const std::string & name, size_t view_index) const = 0;
|
|
50
|
+
|
|
51
|
+
virtual element::Type get_input_type(int node_idx, const std::string & name) const = 0;
|
|
22
52
|
|
|
23
53
|
virtual size_t get_input_size() const = 0;
|
|
24
54
|
|
|
25
55
|
virtual size_t get_input_size(int node_idx) const = 0;
|
|
26
56
|
|
|
27
57
|
virtual void get_input_node(size_t input_port_idx,
|
|
28
|
-
std::string& producer_name,
|
|
29
|
-
std::string& producer_output_port_name,
|
|
30
|
-
size_t& producer_output_port_index) const = 0;
|
|
58
|
+
std::string & producer_name,
|
|
59
|
+
std::string & producer_output_port_name,
|
|
60
|
+
size_t & producer_output_port_index) const = 0;
|
|
31
61
|
|
|
32
62
|
virtual std::vector<std::string> get_input_names(int node_idx) const = 0;
|
|
33
63
|
|
|
@@ -35,30 +65,36 @@ public:
|
|
|
35
65
|
|
|
36
66
|
virtual element::Type get_output_type(const int node_idx) const = 0;
|
|
37
67
|
|
|
38
|
-
virtual
|
|
68
|
+
virtual std::vector<size_t> get_output_stride(int node_idx) const = 0;
|
|
69
|
+
|
|
70
|
+
virtual int32_t * get_input_op_params(int node_idx, const std::string & name) const = 0;
|
|
39
71
|
|
|
40
72
|
virtual int32_t * get_output_op_params(int node_idx) const = 0;
|
|
41
73
|
|
|
74
|
+
virtual size_t get_output_op_offset(int node_idx) const = 0;
|
|
75
|
+
|
|
42
76
|
virtual std::vector<std::string> get_output_names(int node_idx) const = 0;
|
|
43
77
|
|
|
44
|
-
virtual const std::string& get_op_type() const = 0;
|
|
78
|
+
virtual const std::string & get_op_type() const = 0;
|
|
45
79
|
|
|
46
|
-
virtual const std::string& get_op_type(int node_idx) const = 0;
|
|
80
|
+
virtual const std::string & get_op_type(int node_idx) const = 0;
|
|
47
81
|
|
|
48
|
-
virtual const std::string& get_op_name() const = 0;
|
|
82
|
+
virtual const std::string & get_op_name() const = 0;
|
|
49
83
|
|
|
50
|
-
virtual const std::string& get_op_name(int node_idx) const = 0;
|
|
84
|
+
virtual const std::string & get_op_name(int node_idx) const = 0;
|
|
51
85
|
|
|
52
86
|
virtual void visit_subgraph(std::function<void(std::shared_ptr<GgmlDecoder>, int node_idx)> node_visitor) const = 0;
|
|
53
87
|
|
|
54
88
|
virtual int get_op_case(int node_idx) const = 0;
|
|
55
89
|
|
|
56
|
-
virtual const std::map<std::string, std::shared_ptr<ov::Node
|
|
57
|
-
virtual const std::map<std::string, std::shared_ptr<ov::Node
|
|
58
|
-
virtual const std::map<std::string, std::shared_ptr<ov::Node
|
|
90
|
+
virtual const std::map<std::string, std::shared_ptr<ov::Node>> & get_model_inputs() const = 0;
|
|
91
|
+
virtual const std::map<std::string, std::shared_ptr<ov::Node>> & get_model_extra_inputs() const = 0;
|
|
92
|
+
virtual const std::map<std::string, std::shared_ptr<ov::Node>> & get_model_weights() const = 0;
|
|
59
93
|
virtual std::vector<std::string> get_model_output_names() const = 0;
|
|
60
94
|
|
|
61
|
-
virtual int32_t* get_rope_params() const = 0;
|
|
95
|
+
virtual int32_t * get_rope_params() const = 0;
|
|
96
|
+
|
|
97
|
+
virtual bool has_mixed_rope_params() const = 0;
|
|
62
98
|
|
|
63
99
|
virtual std::map<std::string, std::string> get_kv_param_res_names() const = 0;
|
|
64
100
|
|
|
@@ -66,7 +102,11 @@ public:
|
|
|
66
102
|
|
|
67
103
|
virtual bool is_stateful() const = 0;
|
|
68
104
|
|
|
105
|
+
virtual bool is_splited_model() const = 0;
|
|
106
|
+
|
|
69
107
|
virtual int is_swa_layer(int layer) const = 0;
|
|
108
|
+
|
|
109
|
+
virtual int32_t get_op_dynamic_dim(int node_idx) const = 0;
|
|
70
110
|
};
|
|
71
111
|
|
|
72
112
|
} // namespace ggml
|
|
@@ -15,7 +15,7 @@ public:
|
|
|
15
15
|
using Ptr = std::shared_ptr<FrontEnd>;
|
|
16
16
|
FrontEnd();
|
|
17
17
|
|
|
18
|
-
static std::shared_ptr<Model> convert(const InputModel::Ptr& model, bool naive = false);
|
|
18
|
+
static std::shared_ptr<Model> convert(const InputModel::Ptr & model, bool naive = false);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
} // namespace ggml
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <openvino/frontend/input_model.hpp>
|
|
4
|
-
|
|
5
3
|
#include "decoder.h"
|
|
6
4
|
|
|
5
|
+
#include <openvino/frontend/input_model.hpp>
|
|
6
|
+
|
|
7
7
|
namespace ov {
|
|
8
8
|
namespace frontend {
|
|
9
9
|
namespace ggml {
|
|
@@ -16,9 +16,9 @@ class InputModel : public ov::frontend::InputModel {
|
|
|
16
16
|
friend class ::ov::frontend::ggml::FrontEnd;
|
|
17
17
|
|
|
18
18
|
public:
|
|
19
|
-
explicit InputModel(const std::shared_ptr<GgmlDecoder
|
|
19
|
+
explicit InputModel(const std::shared_ptr<GgmlDecoder> & gdecoder);
|
|
20
20
|
|
|
21
|
-
const std::shared_ptr<GgmlDecoder
|
|
21
|
+
const std::shared_ptr<GgmlDecoder> & get_model_decoder() const;
|
|
22
22
|
|
|
23
23
|
private:
|
|
24
24
|
std::shared_ptr<GgmlDecoder> m_decoder;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include "decoder.h"
|
|
4
|
+
|
|
3
5
|
#include <cstdint>
|
|
4
6
|
#include <openvino/frontend/node_context.hpp>
|
|
5
7
|
#include <string>
|
|
6
8
|
|
|
7
|
-
#include "decoder.h"
|
|
8
|
-
|
|
9
9
|
namespace ov {
|
|
10
10
|
namespace frontend {
|
|
11
11
|
namespace ggml {
|
|
@@ -16,28 +16,24 @@ typedef std::map<std::string, Output<Node>> TensorMap;
|
|
|
16
16
|
|
|
17
17
|
class NodeContext : public frontend::NodeContext {
|
|
18
18
|
public:
|
|
19
|
-
NodeContext(const std::shared_ptr<GgmlDecoder
|
|
20
|
-
std::shared_ptr<TensorMap
|
|
19
|
+
NodeContext(const std::shared_ptr<GgmlDecoder> & decoder,
|
|
20
|
+
std::shared_ptr<TensorMap> & tensor_map,
|
|
21
21
|
int node_idx,
|
|
22
|
-
TranslateSession* translate_session = nullptr)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
TranslateSession * translate_session = nullptr) :
|
|
23
|
+
ov::frontend::NodeContext(decoder->get_op_type(node_idx)),
|
|
24
|
+
m_decoder(decoder),
|
|
25
|
+
m_tensor_map(tensor_map),
|
|
26
|
+
m_node_idx(node_idx),
|
|
27
|
+
m_translate_session(translate_session) {
|
|
28
28
|
m_input_names = decoder->get_input_names(m_node_idx);
|
|
29
29
|
m_output_names = decoder->get_output_names(m_node_idx);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
TranslateSession* get_translate_session() const {
|
|
33
|
-
return m_translate_session;
|
|
34
|
-
}
|
|
32
|
+
TranslateSession * get_translate_session() const { return m_translate_session; }
|
|
35
33
|
|
|
36
|
-
const std::vector<std::string
|
|
34
|
+
const std::vector<std::string> & get_input_names() const { return m_input_names; }
|
|
37
35
|
|
|
38
|
-
size_t get_input_size() const override {
|
|
39
|
-
return m_decoder->get_input_size(m_node_idx);
|
|
40
|
-
}
|
|
36
|
+
size_t get_input_size() const override { return m_decoder->get_input_size(m_node_idx); }
|
|
41
37
|
|
|
42
38
|
ov::element::Type get_input_type(size_t index) const {
|
|
43
39
|
return m_decoder->get_input_type(m_node_idx, m_input_names[index]);
|
|
@@ -55,42 +51,103 @@ public:
|
|
|
55
51
|
|
|
56
52
|
PartialShape get_output_shape() const { return m_decoder->get_output_shape(m_node_idx); }
|
|
57
53
|
|
|
58
|
-
int32_t* get_input_op_params(size_t index) const {
|
|
54
|
+
int32_t * get_input_op_params(size_t index) const {
|
|
59
55
|
return m_decoder->get_input_op_params(m_node_idx, m_input_names[index]);
|
|
60
56
|
}
|
|
61
57
|
|
|
62
|
-
|
|
58
|
+
size_t get_view_input_size(size_t index) const {
|
|
59
|
+
return m_decoder->get_view_input_size(m_node_idx, m_input_names[index]);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
size_t get_view_input_offset(size_t index, size_t view_index) const {
|
|
63
|
+
return m_decoder->get_view_input_offset(m_node_idx, m_input_names[index], view_index);
|
|
64
|
+
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
return m_decoder->
|
|
66
|
+
size_t get_view_input_src_offset(size_t index, size_t view_index) const {
|
|
67
|
+
return m_decoder->get_view_input_src_offset(m_node_idx, m_input_names[index], view_index);
|
|
66
68
|
}
|
|
67
69
|
|
|
70
|
+
std::vector<size_t> get_view_input_stride(size_t index, size_t view_index) const {
|
|
71
|
+
return m_decoder->get_view_input_stride(m_node_idx, m_input_names[index], view_index);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
std::vector<size_t> get_view_input_src_stride(size_t index, size_t view_index) const {
|
|
75
|
+
return m_decoder->get_view_input_src_stride(m_node_idx, m_input_names[index], view_index);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ov::Shape get_view_input_ggml_shape(size_t index, size_t view_index) const {
|
|
79
|
+
return m_decoder->get_view_input_ggml_shape(m_node_idx, m_input_names[index], view_index);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
ov::Shape get_view_input_src_ggml_shape(size_t index, size_t view_index) const {
|
|
83
|
+
return m_decoder->get_view_input_src_ggml_shape(m_node_idx, m_input_names[index], view_index);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
ov::PartialShape get_view_input_ov_shape(size_t index, size_t view_index) const {
|
|
87
|
+
return m_decoder->get_view_input_ov_shape(m_node_idx, m_input_names[index], view_index);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ov::PartialShape get_view_input_src_ov_shape(size_t index, size_t view_index) const {
|
|
91
|
+
return m_decoder->get_view_input_src_ov_shape(m_node_idx, m_input_names[index], view_index);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
std::string get_view_input_name(size_t index, size_t view_index) const {
|
|
95
|
+
return m_decoder->get_view_input_name(m_node_idx, m_input_names[index], view_index);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
std::string get_view_input_src_name(size_t index, size_t view_index) const {
|
|
99
|
+
return m_decoder->get_view_input_src_name(m_node_idx, m_input_names[index], view_index);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
int32_t get_op_dynamic_dim() const { return m_decoder->get_op_dynamic_dim(m_node_idx); }
|
|
103
|
+
|
|
104
|
+
int32_t * get_output_op_params() const { return m_decoder->get_output_op_params(m_node_idx); }
|
|
105
|
+
|
|
106
|
+
size_t get_output_op_offset() const { return m_decoder->get_output_op_offset(m_node_idx); }
|
|
107
|
+
|
|
108
|
+
ov::element::Type get_output_type() const { return m_decoder->get_output_type(m_node_idx); }
|
|
109
|
+
|
|
110
|
+
std::vector<size_t> get_output_stride() const { return m_decoder->get_output_stride(m_node_idx); }
|
|
111
|
+
|
|
68
112
|
Output<Node> get_input(int idx) const override {
|
|
113
|
+
// Check if this input is a VIEW
|
|
114
|
+
size_t view_input_size = m_decoder->get_view_input_size(m_node_idx, m_input_names[idx]);
|
|
115
|
+
if (view_input_size > 0) {
|
|
116
|
+
// This is a VIEW input, get the base tensor name (last element in the chain)
|
|
117
|
+
std::string base_name =
|
|
118
|
+
m_decoder->get_view_input_src_name(m_node_idx, m_input_names[idx], view_input_size - 1);
|
|
119
|
+
// Check if the VIEW has been resolved (translate_view produced a Slice)
|
|
120
|
+
auto view_it = m_tensor_map->find(m_input_names[idx]);
|
|
121
|
+
if (!base_name.empty() && view_it != m_tensor_map->end()) {
|
|
122
|
+
auto base_it = m_tensor_map->find(base_name);
|
|
123
|
+
if (base_it != m_tensor_map->end() &&
|
|
124
|
+
view_it->second.get_node_shared_ptr() != base_it->second.get_node_shared_ptr()) {
|
|
125
|
+
return view_it->second;
|
|
126
|
+
}
|
|
127
|
+
return base_it->second;
|
|
128
|
+
}
|
|
129
|
+
if (!base_name.empty()) {
|
|
130
|
+
return m_tensor_map->at(base_name);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Not a VIEW or failed to get base name, use the original logic
|
|
69
134
|
return m_tensor_map->at(m_input_names[idx]);
|
|
70
135
|
}
|
|
71
136
|
|
|
72
|
-
Output<Node> get_input(const std::string& name) const override {
|
|
137
|
+
Output<Node> get_input(const std::string & name) const override {
|
|
73
138
|
if (m_tensor_map->find(name) == m_tensor_map->end()) {
|
|
74
139
|
throw std::runtime_error("'" + name + "' not found in tensor map.");
|
|
75
140
|
}
|
|
76
141
|
return m_tensor_map->at(name);
|
|
77
142
|
}
|
|
78
143
|
|
|
79
|
-
bool has_input(const std::string& name) const {
|
|
80
|
-
return m_tensor_map->find(name) != m_tensor_map->end();
|
|
81
|
-
}
|
|
144
|
+
bool has_input(const std::string & name) const { return m_tensor_map->find(name) != m_tensor_map->end(); }
|
|
82
145
|
|
|
83
|
-
const std::string& get_name() const override {
|
|
84
|
-
return m_decoder->get_op_name(m_node_idx);
|
|
85
|
-
}
|
|
146
|
+
const std::string & get_name() const override { return m_decoder->get_op_name(m_node_idx); }
|
|
86
147
|
|
|
87
|
-
ov::Any get_attribute_as_any(const std::string& name) const override {
|
|
88
|
-
return m_decoder->get_attribute(name);
|
|
89
|
-
}
|
|
148
|
+
ov::Any get_attribute_as_any(const std::string & name) const override { return m_decoder->get_attribute(name); }
|
|
90
149
|
|
|
91
|
-
int get_op_case() const {
|
|
92
|
-
return m_decoder->get_op_case(m_node_idx);
|
|
93
|
-
}
|
|
150
|
+
int get_op_case() const { return m_decoder->get_op_case(m_node_idx); }
|
|
94
151
|
|
|
95
152
|
bool is_static() const { return m_decoder->is_static(); }
|
|
96
153
|
|
|
@@ -98,14 +155,14 @@ public:
|
|
|
98
155
|
|
|
99
156
|
private:
|
|
100
157
|
std::shared_ptr<GgmlDecoder> m_decoder;
|
|
101
|
-
std::shared_ptr<TensorMap
|
|
158
|
+
std::shared_ptr<TensorMap> & m_tensor_map;
|
|
102
159
|
int m_node_idx;
|
|
103
|
-
TranslateSession* m_translate_session;
|
|
160
|
+
TranslateSession * m_translate_session;
|
|
104
161
|
std::vector<std::string> m_input_names;
|
|
105
162
|
std::vector<std::string> m_output_names;
|
|
106
163
|
};
|
|
107
164
|
|
|
108
|
-
using CreatorFunction = std::function<ov::OutputVector(const ov::frontend::ggml::NodeContext&)>;
|
|
165
|
+
using CreatorFunction = std::function<ov::OutputVector(const ov::frontend::ggml::NodeContext &)>;
|
|
109
166
|
|
|
110
167
|
} // namespace ggml
|
|
111
168
|
} // namespace frontend
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <openvino/core/node.hpp>
|
|
7
|
+
#include <openvino/core/node_output.hpp>
|
|
8
|
+
#include <openvino/op/add.hpp>
|
|
9
|
+
#include <openvino/op/constant.hpp>
|
|
10
|
+
#include <openvino/op/convert.hpp>
|
|
11
|
+
#include <openvino/op/gather.hpp>
|
|
12
|
+
#include <openvino/op/reshape.hpp>
|
|
13
|
+
#include <openvino/op/shape_of.hpp>
|
|
14
|
+
|
|
15
|
+
namespace ov {
|
|
16
|
+
namespace frontend {
|
|
17
|
+
namespace ggml {
|
|
18
|
+
namespace op {
|
|
19
|
+
|
|
20
|
+
static ov::Output<ov::Node> reshape_add_id_input_to_2d(const ov::Output<ov::Node> & input,
|
|
21
|
+
const ov::PartialShape & input_shape,
|
|
22
|
+
const std::vector<int> & dims) {
|
|
23
|
+
const auto actual_shape = input.get_partial_shape();
|
|
24
|
+
if (actual_shape.rank().is_static() && actual_shape.rank().get_length() == 2) {
|
|
25
|
+
return input;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (input_shape.rank().is_static() && input_shape.rank().get_length() == 2) {
|
|
29
|
+
return input;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
auto shape = std::make_shared<ov::op::v3::ShapeOf>(input, ov::element::i64);
|
|
33
|
+
return std::make_shared<ov::op::v1::Reshape>(input, get_dimensions(shape, dims), false);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
OutputVector translate_add_id(const NodeContext & context) {
|
|
37
|
+
num_inputs_check(context, 3, 3);
|
|
38
|
+
|
|
39
|
+
auto input = process_view_input_new(context, 0);
|
|
40
|
+
auto bias = process_view_input_new(context, 1);
|
|
41
|
+
auto ids = process_view_input_new(context, 2);
|
|
42
|
+
|
|
43
|
+
// OpenVINO uses reversed GGML dimensions:
|
|
44
|
+
// input: [1, n_token, n_used, n_embd]
|
|
45
|
+
// bias: [1, 1, n_expert, n_embd]
|
|
46
|
+
// ids: [1, 1, n_token, n_used]
|
|
47
|
+
// Model bias constants may already be stored as [n_expert, n_embd].
|
|
48
|
+
bias = reshape_add_id_input_to_2d(bias, context.get_input_shape(1), {2, 3});
|
|
49
|
+
ids = reshape_add_id_input_to_2d(ids, context.get_input_shape(2), {2, 3});
|
|
50
|
+
|
|
51
|
+
if (ids.get_element_type() != ov::element::i32 && ids.get_element_type() != ov::element::i64) {
|
|
52
|
+
ids = std::make_shared<ov::op::v0::Convert>(ids, ov::element::i32);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
auto gather_axis = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0});
|
|
56
|
+
ov::Output<ov::Node> selected_bias = std::make_shared<ov::op::v8::Gather>(bias, ids, gather_axis);
|
|
57
|
+
selected_bias = std::make_shared<ov::op::v1::Reshape>(
|
|
58
|
+
selected_bias, std::make_shared<ov::op::v3::ShapeOf>(input, ov::element::i64), false);
|
|
59
|
+
|
|
60
|
+
if (selected_bias.get_element_type() != input.get_element_type()) {
|
|
61
|
+
selected_bias = std::make_shared<ov::op::v0::Convert>(selected_bias, input.get_element_type());
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ov::Output<ov::Node> res = std::make_shared<ov::op::v1::Add>(input, selected_bias);
|
|
65
|
+
const auto output_type = context.get_output_type();
|
|
66
|
+
if (res.get_element_type() != output_type) {
|
|
67
|
+
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return rename_outputs_with_suffix({res}, context.get_name());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} // namespace op
|
|
74
|
+
} // namespace ggml
|
|
75
|
+
} // namespace frontend
|
|
76
|
+
} // namespace ov
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
#include "ggml.h"
|
|
5
|
+
|
|
6
|
+
#include <openvino/frontend/exception.hpp>
|
|
7
|
+
#include <openvino/op/constant.hpp>
|
|
8
|
+
#include <openvino/op/squeeze.hpp>
|
|
9
|
+
#include <openvino/op/topk.hpp>
|
|
10
|
+
|
|
11
|
+
namespace ov {
|
|
12
|
+
namespace frontend {
|
|
13
|
+
namespace ggml {
|
|
14
|
+
namespace op {
|
|
15
|
+
|
|
16
|
+
OutputVector translate_argsort(const NodeContext & context) {
|
|
17
|
+
num_inputs_check(context, 1, 1);
|
|
18
|
+
|
|
19
|
+
auto input = process_view_input_new(context, 0);
|
|
20
|
+
|
|
21
|
+
const int32_t order = context.get_output_op_params()[0];
|
|
22
|
+
|
|
23
|
+
ov::op::v11::TopK::Mode mode;
|
|
24
|
+
switch (order) {
|
|
25
|
+
case GGML_SORT_ORDER_ASC:
|
|
26
|
+
mode = ov::op::v11::TopK::Mode::MIN;
|
|
27
|
+
break;
|
|
28
|
+
case GGML_SORT_ORDER_DESC:
|
|
29
|
+
mode = ov::op::v11::TopK::Mode::MAX;
|
|
30
|
+
break;
|
|
31
|
+
default:
|
|
32
|
+
FRONT_END_OP_CONVERSION_CHECK(false, "Unsupported GGML_OP_ARGSORT order: ", order);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
auto k = std::make_shared<ov::op::v0::Squeeze>(get_dimensions(input.get_node_shared_ptr(), {3}),
|
|
36
|
+
ov::op::v0::Constant::create(ov::element::i64, {1}, {0}));
|
|
37
|
+
|
|
38
|
+
auto topk = std::make_shared<ov::op::v11::TopK>(input, k, 3, mode, ov::op::v11::TopK::SortType::SORT_VALUES,
|
|
39
|
+
context.get_output_type(), false);
|
|
40
|
+
|
|
41
|
+
return rename_outputs_with_suffix({topk->output(1)}, context.get_name());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
} // namespace op
|
|
45
|
+
} // namespace ggml
|
|
46
|
+
} // namespace frontend
|
|
47
|
+
} // namespace ov
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
|
|
5
|
+
#include <cstring>
|
|
6
|
+
#include <openvino/op/clamp.hpp>
|
|
7
|
+
|
|
8
|
+
namespace ov {
|
|
9
|
+
namespace frontend {
|
|
10
|
+
namespace ggml {
|
|
11
|
+
namespace op {
|
|
12
|
+
|
|
13
|
+
OutputVector translate_clamp(const NodeContext & context) {
|
|
14
|
+
num_inputs_check(context, 1, 1);
|
|
15
|
+
|
|
16
|
+
auto input = process_view_input_new(context, 0);
|
|
17
|
+
|
|
18
|
+
const int32_t * op_params = context.get_output_op_params();
|
|
19
|
+
FRONT_END_CHECK_IMPLEMENTED(op_params != nullptr, "CLAMP requires output op params");
|
|
20
|
+
|
|
21
|
+
float min;
|
|
22
|
+
float max;
|
|
23
|
+
std::memcpy(&min, reinterpret_cast<const float *>(op_params) + 0, sizeof(float));
|
|
24
|
+
std::memcpy(&max, reinterpret_cast<const float *>(op_params) + 1, sizeof(float));
|
|
25
|
+
|
|
26
|
+
auto res = std::make_shared<ov::op::v0::Clamp>(input, min, max);
|
|
27
|
+
return rename_outputs_with_suffix({res}, context.get_name());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
} // namespace op
|
|
31
|
+
} // namespace ggml
|
|
32
|
+
} // namespace frontend
|
|
33
|
+
} // namespace ov
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <openvino/frontend/exception.hpp>
|
|
7
|
+
#include <openvino/op/concat.hpp>
|
|
8
|
+
#include <openvino/op/convert.hpp>
|
|
9
|
+
|
|
10
|
+
namespace ov {
|
|
11
|
+
namespace frontend {
|
|
12
|
+
namespace ggml {
|
|
13
|
+
namespace op {
|
|
14
|
+
|
|
15
|
+
OutputVector translate_concat(const NodeContext & context) {
|
|
16
|
+
num_inputs_check(context, 2, 2);
|
|
17
|
+
|
|
18
|
+
const int32_t * op_params = context.get_output_op_params();
|
|
19
|
+
FRONT_END_CHECK_IMPLEMENTED(op_params != nullptr, "CONCAT requires output op params");
|
|
20
|
+
|
|
21
|
+
const auto output_shape = context.get_output_shape();
|
|
22
|
+
FRONT_END_CHECK_IMPLEMENTED(output_shape.rank().is_static(), "CONCAT requires static output rank");
|
|
23
|
+
|
|
24
|
+
const auto rank = output_shape.rank().get_length();
|
|
25
|
+
const int32_t ggml_dim = op_params[0];
|
|
26
|
+
FRONT_END_CHECK_IMPLEMENTED(ggml_dim >= 0 && ggml_dim < rank, "CONCAT axis is out of range");
|
|
27
|
+
|
|
28
|
+
auto input_0 = process_view_input_new(context, 0);
|
|
29
|
+
auto input_1 = process_view_input_new(context, 1);
|
|
30
|
+
const auto output_type = context.get_output_type();
|
|
31
|
+
|
|
32
|
+
if (input_0.get_element_type() != output_type) {
|
|
33
|
+
input_0 = std::make_shared<ov::op::v0::Convert>(input_0, output_type);
|
|
34
|
+
}
|
|
35
|
+
if (input_1.get_element_type() != output_type) {
|
|
36
|
+
input_1 = std::make_shared<ov::op::v0::Convert>(input_1, output_type);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const auto axis = static_cast<int64_t>(rank - 1 - ggml_dim);
|
|
40
|
+
auto res = std::make_shared<ov::op::v0::Concat>(OutputVector{input_0, input_1}, axis);
|
|
41
|
+
|
|
42
|
+
return rename_outputs_with_suffix({res}, context.get_name());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
} // namespace op
|
|
46
|
+
} // namespace ggml
|
|
47
|
+
} // namespace frontend
|
|
48
|
+
} // namespace ov
|
|
@@ -18,27 +18,19 @@ namespace op {
|
|
|
18
18
|
OutputVector translate_cont(const NodeContext & context) {
|
|
19
19
|
num_inputs_check(context, 1, 1);
|
|
20
20
|
|
|
21
|
-
int op_case = context.get_op_case();
|
|
22
|
-
FRONT_END_CHECK_IMPLEMENTED(op_case == 1 || op_case == 2 || op_case == 3, "Unsupported CONT case");
|
|
23
|
-
|
|
24
21
|
auto src_shape = context.get_input_shape(0).to_shape();
|
|
25
22
|
auto dst_shape = context.get_output_shape().to_shape();
|
|
26
|
-
ov::Output<Node> res;
|
|
27
23
|
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
throw std::runtime_error("Code of this case might be outdated");
|
|
31
|
-
dst_shape[1] = -1;
|
|
32
|
-
res = std::make_shared<ov::op::v1::Reshape>(
|
|
33
|
-
context.get_input(0), ov::op::v0::Constant::create(ov::element::i64, {dst_shape.size()}, dst_shape), false);
|
|
34
|
-
} else if (op_case == 2) {
|
|
35
|
-
// The input comes from a TRANSPOSE
|
|
36
|
-
return {context.get_input(0)};
|
|
37
|
-
} else {
|
|
38
|
-
// The input comes from a VIEW
|
|
39
|
-
res = process_view_input(context, 0);
|
|
24
|
+
if (context.get_op_dynamic_dim() != -1) {
|
|
25
|
+
dst_shape[3 - context.get_op_dynamic_dim()] = -1;
|
|
40
26
|
}
|
|
41
27
|
|
|
28
|
+
auto input = process_view_input_new(context, 0);
|
|
29
|
+
|
|
30
|
+
ov::Output<Node> res;
|
|
31
|
+
res = std::make_shared<ov::op::v1::Reshape>(
|
|
32
|
+
input, ov::op::v0::Constant::create(ov::element::i64, {dst_shape.size()}, dst_shape), false);
|
|
33
|
+
|
|
42
34
|
return rename_outputs_with_suffix({res}, context.get_name());
|
|
43
35
|
}
|
|
44
36
|
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
#include "../utils.h"
|
|
4
4
|
|
|
5
5
|
#include <memory>
|
|
6
|
+
#include <openvino/op/constant.hpp>
|
|
6
7
|
#include <openvino/op/convert.hpp>
|
|
8
|
+
#include <openvino/op/reshape.hpp>
|
|
7
9
|
|
|
8
10
|
namespace ov {
|
|
9
11
|
namespace frontend {
|
|
@@ -11,7 +13,18 @@ namespace ggml {
|
|
|
11
13
|
namespace op {
|
|
12
14
|
|
|
13
15
|
OutputVector translate_cpy(const NodeContext & context) {
|
|
14
|
-
auto
|
|
16
|
+
auto input = process_view_input_new(context, 0);
|
|
17
|
+
auto input_shape = context.get_input_shape(0);
|
|
18
|
+
auto output_shape = context.get_output_shape();
|
|
19
|
+
|
|
20
|
+
// Non-cast CPY may need a reshape (e.g. [3,192,1,1] -> [576,1,1,1])
|
|
21
|
+
if (input_shape != output_shape) {
|
|
22
|
+
auto new_shape = ov::op::v0::Constant::create(
|
|
23
|
+
ov::element::i64, {static_cast<size_t>(output_shape.rank().get_length())}, output_shape.to_shape());
|
|
24
|
+
input = std::make_shared<ov::op::v1::Reshape>(input, new_shape, false);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
auto res = std::make_shared<ov::op::v0::Convert>(input, context.get_output_type());
|
|
15
28
|
return rename_outputs_with_suffix({res}, context.get_name());
|
|
16
29
|
}
|
|
17
30
|
|