whispercpp 1.3.7 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/ext/options.rb +1 -1
- data/ext/ruby_whisper.c +0 -1
- data/ext/ruby_whisper.h +7 -1
- data/ext/ruby_whisper_context.c +50 -1
- data/ext/ruby_whisper_log_settable.h +1 -2
- data/ext/ruby_whisper_params.c +9 -8
- data/ext/ruby_whisper_transcribe.cpp +0 -19
- data/ext/ruby_whisper_vad_context.c +30 -10
- data/ext/ruby_whisper_vad_context_detect.cpp +8 -9
- data/ext/ruby_whisper_vad_params.c +4 -4
- data/ext/ruby_whisper_vad_segment.c +2 -2
- data/ext/sources/CMakeLists.txt +2 -1
- data/ext/sources/cmake/parakeet.pc.in +2 -2
- data/ext/sources/cmake/whisper.pc.in +2 -2
- data/ext/sources/examples/cli/cli.cpp +9 -1
- data/ext/sources/examples/common-ggml.cpp +2 -0
- data/ext/sources/examples/vad-speech-segments/speech.cpp +3 -2
- data/ext/sources/ggml/CMakeLists.txt +3 -4
- data/ext/sources/ggml/include/ggml-cuda.h +0 -3
- data/ext/sources/ggml/include/ggml-sycl.h +8 -0
- data/ext/sources/ggml/include/ggml.h +3 -1
- data/ext/sources/ggml/src/CMakeLists.txt +8 -1
- data/ext/sources/ggml/src/ggml-backend-meta.cpp +7 -4
- data/ext/sources/ggml/src/ggml-common.h +13 -2
- data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +1 -1
- data/ext/sources/ggml/src/ggml-cpu/amx/mmq.cpp +5 -6
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +78 -4
- data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +142 -4
- data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +7 -2
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +14 -0
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +26 -19
- data/ext/sources/ggml/src/ggml-cpu/ops.cpp +129 -46
- data/ext/sources/ggml/src/ggml-cpu/quants.c +51 -0
- data/ext/sources/ggml/src/ggml-cpu/quants.h +3 -0
- data/ext/sources/ggml/src/ggml-cpu/simd-gemm.h +1 -1
- data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +11 -0
- data/ext/sources/ggml/src/ggml-cpu/vec.cpp +2 -2
- data/ext/sources/ggml/src/ggml-cuda/binbcast.cu +90 -46
- data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cu +81 -0
- data/ext/sources/ggml/src/ggml-cuda/col2im-1d.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/common.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/concat.cu +33 -21
- data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cu +14 -12
- data/ext/sources/ggml/src/ggml-cuda/convert.cu +86 -34
- data/ext/sources/ggml/src/ggml-cuda/cpy.cu +80 -29
- data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +9 -5
- data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile.cuh +9 -5
- data/ext/sources/ggml/src/ggml-cuda/fattn.cu +27 -21
- data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cu +40 -25
- data/ext/sources/ggml/src/ggml-cuda/gated_delta_net.cuh +10 -0
- data/ext/sources/ggml/src/ggml-cuda/getrows.cu +15 -12
- data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +718 -1248
- data/ext/sources/ggml/src/ggml-cuda/mmq.cu +7 -0
- data/ext/sources/ggml/src/ggml-cuda/mmvq.cu +77 -40
- data/ext/sources/ggml/src/ggml-cuda/out-prod.cu +55 -12
- data/ext/sources/ggml/src/ggml-cuda/set-rows.cu +64 -4
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +1 -0
- data/ext/sources/ggml/src/ggml-cuda/topk-moe.cu +7 -1
- data/ext/sources/ggml/src/ggml-cuda/vendors/hip.h +1 -0
- data/ext/sources/ggml/src/ggml-cuda/vendors/musa.h +1 -0
- data/ext/sources/ggml/src/ggml-hexagon/CMakeLists.txt +0 -5
- data/ext/sources/ggml/src/ggml-hexagon/ggml-hexagon.cpp +1634 -1293
- data/ext/sources/ggml/src/ggml-hexagon/htp/CMakeLists.txt +11 -40
- data/ext/sources/ggml/src/ggml-hexagon/htp/cmake-toolchain.cmake +13 -15
- data/ext/sources/ggml/src/ggml-hexagon/htp/concat-ops.c +1 -1
- data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.c +1749 -399
- data/ext/sources/ggml/src/ggml-hexagon/htp/flash-attn-ops.h +303 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-common.h +80 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-dma.h +26 -23
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-profile.h +64 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hex-utils.h +1 -83
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-fa-kernels.h +555 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-mm-kernels-tiled.h +1303 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.c +9 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-queue.h +27 -4
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-utils.h +59 -37
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ctx.h +11 -3
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-ops.h +52 -12
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp-vtcm.h +19 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/htp_iface.idl +2 -1
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-base.h +14 -30
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-exp.h +39 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-fa-kernels.h +232 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-flat.h +1511 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-mm-kernels-tiled.h +1200 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/hvx-sigmoid.h +39 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/main.c +127 -32
- data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.c +3023 -4425
- data/ext/sources/ggml/src/ggml-hexagon/htp/matmul-ops.h +650 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp/rope-ops.c +48 -13
- data/ext/sources/ggml/src/ggml-hexagon/htp/ssm-conv.c +10 -9
- data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.c +15 -3
- data/ext/sources/ggml/src/ggml-hexagon/htp/worker-pool.h +8 -0
- data/ext/sources/ggml/src/ggml-hexagon/htp-opnode.h +168 -50
- data/ext/sources/ggml/src/ggml-hexagon/libggml-htp.inf +0 -4
- data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +5 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.cpp +69 -5
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.h +4 -1
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-device.m +27 -6
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +38 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.cpp +132 -2
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-ops.h +2 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal.metal +345 -87
- data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +13 -0
- data/ext/sources/ggml/src/ggml-opencl/fa_tune.h +92 -0
- data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +4060 -357
- data/ext/sources/ggml/src/ggml-opencl/kernels/cvt.cl +198 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +81 -41
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +88 -39
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +1995 -96
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q4_0.cl +1615 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_f32_q8_0.cl +1486 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/flash_attn_pre_f16.cl +156 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_mxfp4_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_0_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_1_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q4_k_f32_ns.cl +71 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_0_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_1_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q5_k_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_moe_q6_k_f32_ns.cl +74 -6
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemm_noshuffle_q1_0_f32.cl +94 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q1_0_f32.cl +121 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_q8_0_f32.cl +1 -1
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mm_q1_0_f32_l4_lm.cl +156 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +1149 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32.cl +141 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q1_0_f32_flat.cl +190 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/norm.cl +5 -2
- data/ext/sources/ggml/src/ggml-opencl/kernels/set_rows.cl +500 -0
- data/ext/sources/ggml/src/ggml-opencl/libdl.h +79 -0
- data/ext/sources/ggml/src/ggml-openvino/.clang-format +0 -5
- data/ext/sources/ggml/src/ggml-openvino/CMakeLists.txt +2 -4
- data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.cpp +733 -130
- data/ext/sources/ggml/src/ggml-openvino/ggml-decoder.h +76 -23
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.cpp +57 -3
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino-extra.h +29 -8
- data/ext/sources/ggml/src/ggml-openvino/ggml-openvino.cpp +307 -59
- data/ext/sources/ggml/src/ggml-openvino/ggml-quants.cpp +66 -0
- data/ext/sources/ggml/src/ggml-openvino/ggml-quants.h +10 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/decoder.h +56 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/frontend.h +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/input_model.h +4 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/node_context.h +94 -37
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/add_id.cpp +76 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/argsort.cpp +47 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/clamp.cpp +33 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/concat.cpp +48 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/cont.cpp +8 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/cpy.cpp +14 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/div.cpp +146 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/flash_attn_ext.cpp +108 -21
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.cpp +282 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/gated_delta_net.hpp +65 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/get_rows.cpp +2 -9
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_geglu.cpp +21 -7
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/glu_swiglu.cpp +41 -8
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/im2col.cpp +120 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/l2_norm.cpp +44 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/mul_mat_id.cpp +226 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/mulmat.cpp +19 -9
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/norm.cpp +58 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/pad.cpp +95 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/permute.cpp +58 -13
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/repeat.cpp +74 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/reshape.cpp +13 -6
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/rms_norm.cpp +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/rope.cpp +134 -38
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/set_rows.cpp +3 -3
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/softmax.cpp +126 -49
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/ssm_conv.cpp +59 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/sum_rows.cpp +27 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/transpose.cpp +32 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_silu.cpp +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_softplus.cpp +38 -0
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/view.cpp +90 -25
- data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.cpp +41 -23
- data/ext/sources/ggml/src/ggml-openvino/openvino/op_table.h +18 -5
- data/ext/sources/ggml/src/ggml-openvino/openvino/pass/mark_decompression_convert_constant_folding.h +1 -1
- data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.cpp +43 -40
- data/ext/sources/ggml/src/ggml-openvino/openvino/translate_session.h +5 -4
- data/ext/sources/ggml/src/ggml-openvino/openvino/utils.cpp +548 -3
- data/ext/sources/ggml/src/ggml-openvino/openvino/utils.h +28 -26
- data/ext/sources/ggml/src/ggml-openvino/utils.cpp +383 -94
- data/ext/sources/ggml/src/ggml-openvino/utils.h +11 -8
- data/ext/sources/ggml/src/ggml-quants.c +76 -0
- data/ext/sources/ggml/src/ggml-quants.h +3 -0
- data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +5 -5
- data/ext/sources/ggml/src/ggml-sycl/backend.hpp +2 -0
- data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +12 -0
- data/ext/sources/ggml/src/ggml-sycl/col2im-1d.cpp +102 -0
- data/ext/sources/ggml/src/ggml-sycl/col2im-1d.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/common.cpp +6 -8
- data/ext/sources/ggml/src/ggml-sycl/common.hpp +19 -2
- data/ext/sources/ggml/src/ggml-sycl/concat.cpp +21 -1
- data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.cpp +158 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-dw.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.cpp +125 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d-transpose.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d.cpp +150 -0
- data/ext/sources/ggml/src/ggml-sycl/conv2d.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/conv3d.cpp +224 -0
- data/ext/sources/ggml/src/ggml-sycl/conv3d.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/convert.cpp +6 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +706 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.hpp +281 -0
- data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.cpp +255 -0
- data/ext/sources/ggml/src/ggml-sycl/cross_entropy_loss.hpp +7 -0
- data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +15 -0
- data/ext/sources/ggml/src/ggml-sycl/dmmv.cpp +492 -319
- data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +15 -7
- data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +215 -115
- data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +2 -0
- data/ext/sources/ggml/src/ggml-sycl/ggml-sycl.cpp +1006 -336
- data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +252 -67
- data/ext/sources/ggml/src/ggml-sycl/mmvq.hpp +17 -0
- data/ext/sources/ggml/src/ggml-sycl/norm.cpp +103 -49
- data/ext/sources/ggml/src/ggml-sycl/outprod.cpp +45 -9
- data/ext/sources/ggml/src/ggml-sycl/pool.cpp +185 -0
- data/ext/sources/ggml/src/ggml-sycl/pool.hpp +22 -0
- data/ext/sources/ggml/src/ggml-sycl/presets.hpp +3 -1
- data/ext/sources/ggml/src/ggml-sycl/set_rows.cpp +10 -2
- data/ext/sources/ggml/src/ggml-sycl/softmax.cpp +9 -10
- data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +35 -0
- data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +5 -0
- data/ext/sources/ggml/src/ggml-vulkan/ggml-vulkan.cpp +833 -215
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/col2im_1d.comp +61 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +1 -1
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv3d_mm.comp +431 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/diag.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +1 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +1 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl +21 -19
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_back.comp +25 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl +23 -4
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl +14 -18
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +4 -7
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vecq.comp +21 -24
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +31 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +6 -5
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_funcs.glsl +84 -67
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +10 -10
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tri.comp +3 -3
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/unary.comp +168 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +121 -74
- data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu-shader-lib.hpp +26 -19
- data/ext/sources/ggml/src/ggml-webgpu/ggml-webgpu.cpp +31 -36
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/common_decls.tmpl +16 -2
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/flash_attn_vec_split.wgsl +7 -7
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/get_rows.wgsl +21 -0
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_decls.tmpl +439 -320
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_id_vec.wgsl +2 -2
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec.wgsl +45 -39
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_acc.tmpl +586 -465
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat_vec_q_acc.tmpl +63 -69
- data/ext/sources/ggml/src/ggml-webgpu/wgsl-shaders/quantize_q8.wgsl +14 -9
- data/ext/sources/ggml/src/ggml.c +36 -14
- data/ext/sources/include/whisper.h +21 -0
- data/ext/sources/src/whisper.cpp +164 -14
- data/lib/whisper/log_settable.rb +5 -8
- data/lib/whisper/model/uri.rb +0 -7
- data/sig/whisper.rbs +6 -0
- data/test/test_vad.rb +9 -0
- data/test/test_vad_context.rb +2 -2
- data/whispercpp.gemspec +1 -1
- metadata +62 -37
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-flash-attn-ops.c +0 -1878
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-matmul-ops.c +0 -2066
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.c +0 -6
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-ops.h +0 -88
- data/ext/sources/ggml/src/ggml-hexagon/htp/hmx-profile.h +0 -34
- data/ext/sources/ggml/src/ggml-hexagon/htp/vtcm-utils.h +0 -16
- data/ext/sources/ggml/src/ggml-openvino/openvino/op/unary_gelu.cpp +0 -25
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/abs.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/ceil.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/elu.comp +0 -27
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/exp.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/floor.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +0 -25
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp +0 -39
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +0 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardsigmoid.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/hardswish.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/neg.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/round.comp +0 -29
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sgn.comp +0 -21
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/softplus.comp +0 -23
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sqrt.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +0 -17
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/step.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +0 -20
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/trunc.comp +0 -22
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/xielu.comp +0 -35
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include "openvino/op/op.hpp"
|
|
4
|
+
|
|
5
|
+
namespace ov::op::internal {
|
|
6
|
+
/// \note GatedDeltaNet op class is under development and subject to change
|
|
7
|
+
///
|
|
8
|
+
/// \brief Operator performing Gated Delta Net computation
|
|
9
|
+
/// \ingroup ov_ops_cpp_api
|
|
10
|
+
class OPENVINO_API GatedDeltaNet : public ov::op::Op {
|
|
11
|
+
public:
|
|
12
|
+
OPENVINO_OP("GatedDeltaNet")
|
|
13
|
+
|
|
14
|
+
GatedDeltaNet() = default;
|
|
15
|
+
/// \brief Constructs a GatedDeltaNet operation.
|
|
16
|
+
///
|
|
17
|
+
/// \param query Query tensor input.
|
|
18
|
+
/// \param key Key tensor input.
|
|
19
|
+
/// \param value Value tensor input.
|
|
20
|
+
/// \param recurrent_state Initial recurrent state tensor.
|
|
21
|
+
/// \param gate Gate tensor controlling state decay/update.
|
|
22
|
+
/// \param beta Beta tensor scaling the delta update.
|
|
23
|
+
/// \param fuse_qk_l2norm Enables fusing q/k L2-normalization into this op.
|
|
24
|
+
/// \param q_l2_norm_eps Epsilon used for query L2-normalization when fusion is enabled.
|
|
25
|
+
/// \param k_l2_norm_eps Epsilon used for key L2-normalization when fusion is enabled.
|
|
26
|
+
GatedDeltaNet(const Output<Node>& query,
|
|
27
|
+
const Output<Node>& key,
|
|
28
|
+
const Output<Node>& value,
|
|
29
|
+
const Output<Node>& recurrent_state,
|
|
30
|
+
const Output<Node>& gate,
|
|
31
|
+
const Output<Node>& beta,
|
|
32
|
+
const bool fuse_qk_l2norm = false,
|
|
33
|
+
const float q_l2_norm_eps = 1e-6F,
|
|
34
|
+
const float k_l2_norm_eps = 1e-6F);
|
|
35
|
+
|
|
36
|
+
/// \brief Constructs a GatedDeltaNet operation from input vector.
|
|
37
|
+
///
|
|
38
|
+
/// \param args Input tensor vector in order: query, key, value, recurrent_state, gate, beta.
|
|
39
|
+
/// \param fuse_qk_l2norm Enables fusing q/k L2-normalization into this op.
|
|
40
|
+
/// \param q_l2_norm_eps Epsilon used for query L2-normalization when fusion is enabled.
|
|
41
|
+
/// \param k_l2_norm_eps Epsilon used for key L2-normalization when fusion is enabled.
|
|
42
|
+
GatedDeltaNet(const ov::OutputVector& args,
|
|
43
|
+
const bool fuse_qk_l2norm = false,
|
|
44
|
+
const float q_l2_norm_eps = 1e-6F,
|
|
45
|
+
const float k_l2_norm_eps = 1e-6F);
|
|
46
|
+
void validate_and_infer_types() override;
|
|
47
|
+
bool visit_attributes(AttributeVisitor& visitor) override;
|
|
48
|
+
std::shared_ptr<ov::Node> clone_with_new_inputs(const ov::OutputVector& new_args) const override;
|
|
49
|
+
bool get_fuse_qk_l2norm() const {
|
|
50
|
+
return m_fuse_qk_l2norm;
|
|
51
|
+
}
|
|
52
|
+
float get_q_l2_norm_eps() const {
|
|
53
|
+
return m_q_l2_norm_eps;
|
|
54
|
+
}
|
|
55
|
+
float get_k_l2_norm_eps() const {
|
|
56
|
+
return m_k_l2_norm_eps;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private:
|
|
60
|
+
bool m_fuse_qk_l2norm = false;
|
|
61
|
+
float m_q_l2_norm_eps = 1e-6F;
|
|
62
|
+
float m_k_l2_norm_eps = 1e-6F;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace ov::op::internal
|
|
@@ -18,16 +18,9 @@ namespace op {
|
|
|
18
18
|
OutputVector translate_get_rows(const NodeContext & context) {
|
|
19
19
|
num_inputs_check(context, 2, 2);
|
|
20
20
|
|
|
21
|
-
int op_case = context.get_op_case();
|
|
22
|
-
|
|
23
21
|
Output<Node> res;
|
|
24
|
-
auto data = context
|
|
25
|
-
auto indices = context
|
|
26
|
-
|
|
27
|
-
if (op_case == 2) {
|
|
28
|
-
// The input comes from a VIEW
|
|
29
|
-
indices = process_view_input(context, 1);
|
|
30
|
-
}
|
|
22
|
+
auto data = process_view_input_new(context, 0);
|
|
23
|
+
auto indices = process_view_input_new(context, 1);
|
|
31
24
|
|
|
32
25
|
// data[1,b,x,y] ind[1,1,b,x'] test-backend-ops case
|
|
33
26
|
// data[x,y] ind[1,1,1,x'] normal case
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
#include <memory>
|
|
6
6
|
#include <openvino/core/node_output.hpp>
|
|
7
|
+
#include <openvino/op/clamp.hpp>
|
|
7
8
|
#include <openvino/op/constant.hpp>
|
|
8
9
|
#include <openvino/op/gelu.hpp>
|
|
9
10
|
#include <openvino/op/multiply.hpp>
|
|
@@ -21,23 +22,26 @@ OutputVector translate_glu_geglu(const NodeContext & context) {
|
|
|
21
22
|
ov::Output<ov::Node> src0;
|
|
22
23
|
ov::Output<ov::Node> src1;
|
|
23
24
|
if (context.get_input_size() == 2) {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
// Inputs may be VIEW slices of a combined gate_up tensor (MoE experts):
|
|
26
|
+
// resolve them so each half has its real sliced shape, not the base tensor.
|
|
27
|
+
src0 = process_view_input_new(context, 0);
|
|
28
|
+
src1 = process_view_input_new(context, 1);
|
|
26
29
|
} else {
|
|
27
30
|
// GGML splits along ne[0] (OV last axis) using floor division: nc = ne[0] / 2.
|
|
28
31
|
// Both halves are nc elements; if the dimension is odd, the last element is dropped.
|
|
29
32
|
// Use Slice instead of Split to handle odd dimensions correctly.
|
|
30
|
-
|
|
33
|
+
// Resolve a VIEW input (e.g. non-contiguous slice) to its real shape first.
|
|
34
|
+
auto combined = process_view_input_new(context, 0);
|
|
31
35
|
auto combined_shape = combined.get_partial_shape();
|
|
32
36
|
int64_t last_dim_val = combined_shape[combined_shape.rank().get_length() - 1].get_length();
|
|
33
37
|
int64_t nc = last_dim_val / 2;
|
|
34
38
|
|
|
35
|
-
auto axis
|
|
36
|
-
auto step
|
|
39
|
+
auto axis = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});
|
|
40
|
+
auto step = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
37
41
|
auto start0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});
|
|
38
|
-
auto stop0
|
|
42
|
+
auto stop0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {nc});
|
|
39
43
|
auto start1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {nc});
|
|
40
|
-
auto stop1
|
|
44
|
+
auto stop1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {2 * nc});
|
|
41
45
|
|
|
42
46
|
src0 = std::make_shared<ov::op::v8::Slice>(combined, start0, stop0, step, axis);
|
|
43
47
|
src1 = std::make_shared<ov::op::v8::Slice>(combined, start1, stop1, step, axis);
|
|
@@ -49,6 +53,16 @@ OutputVector translate_glu_geglu(const NodeContext & context) {
|
|
|
49
53
|
std::swap(src0, src1);
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
if (context.is_static()) {
|
|
57
|
+
// TODO: Temporary solution for NPU accuracy issue due to fp16 overflow
|
|
58
|
+
// To be removed once permanent solution is implemented
|
|
59
|
+
// Justification:
|
|
60
|
+
// For |x| > 5, GELU(x) ≈ max(x, 0) (behaves like ReLU)
|
|
61
|
+
// So Clamp(-10, 10) only affects values where GELU would return ≈ x anyway.
|
|
62
|
+
// The only loss: values > 10 get mapped to 10 instead of x.
|
|
63
|
+
// In practice, FFN intermediates rarely exceed 10 after GEGLU gating.
|
|
64
|
+
src0 = std::make_shared<ov::op::v0::Clamp>(src0, -10.0, 10.0);
|
|
65
|
+
}
|
|
52
66
|
auto gelu = std::make_shared<ov::op::v7::Gelu>(src0);
|
|
53
67
|
auto res = std::make_shared<ov::op::v1::Multiply>(gelu, src1);
|
|
54
68
|
|
|
@@ -3,8 +3,11 @@
|
|
|
3
3
|
#include "../utils.h"
|
|
4
4
|
|
|
5
5
|
#include <cstdint>
|
|
6
|
+
#include <limits>
|
|
6
7
|
#include <memory>
|
|
7
8
|
#include <openvino/core/node_output.hpp>
|
|
9
|
+
#include <openvino/op/add.hpp>
|
|
10
|
+
#include <openvino/op/clamp.hpp>
|
|
8
11
|
#include <openvino/op/constant.hpp>
|
|
9
12
|
#include <openvino/op/multiply.hpp>
|
|
10
13
|
#include <openvino/op/sigmoid.hpp>
|
|
@@ -15,29 +18,32 @@ namespace frontend {
|
|
|
15
18
|
namespace ggml {
|
|
16
19
|
namespace op {
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
static std::pair<ov::Output<ov::Node>, ov::Output<ov::Node>> get_glu_inputs(const NodeContext & context) {
|
|
19
22
|
num_inputs_check(context, 1, 2);
|
|
20
23
|
|
|
21
24
|
ov::Output<ov::Node> src0;
|
|
22
25
|
ov::Output<ov::Node> src1;
|
|
23
26
|
if (context.get_input_size() == 2) {
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
// Inputs may be VIEW slices of a combined gate_up tensor (MoE experts):
|
|
28
|
+
// resolve them so each half has its real sliced shape, not the base tensor.
|
|
29
|
+
src0 = process_view_input_new(context, 0);
|
|
30
|
+
src1 = process_view_input_new(context, 1);
|
|
26
31
|
} else {
|
|
27
32
|
// GGML splits along ne[0] (OV last axis) using floor division: nc = ne[0] / 2.
|
|
28
33
|
// Both halves are nc elements; if the dimension is odd, the last element is dropped.
|
|
29
34
|
// Use Slice instead of Split to handle odd dimensions correctly.
|
|
30
|
-
|
|
35
|
+
// Resolve a VIEW input (e.g. non-contiguous slice) to its real shape first.
|
|
36
|
+
auto combined = process_view_input_new(context, 0);
|
|
31
37
|
auto combined_shape = combined.get_partial_shape();
|
|
32
38
|
int64_t last_dim_val = combined_shape[combined_shape.rank().get_length() - 1].get_length();
|
|
33
39
|
int64_t nc = last_dim_val / 2;
|
|
34
40
|
|
|
35
|
-
auto axis
|
|
36
|
-
auto step
|
|
41
|
+
auto axis = ov::op::v0::Constant::create(ov::element::i64, {1}, {-1});
|
|
42
|
+
auto step = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
37
43
|
auto start0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {0});
|
|
38
|
-
auto stop0
|
|
44
|
+
auto stop0 = ov::op::v0::Constant::create(ov::element::i64, {1}, {nc});
|
|
39
45
|
auto start1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {nc});
|
|
40
|
-
auto stop1
|
|
46
|
+
auto stop1 = ov::op::v0::Constant::create(ov::element::i64, {1}, {2 * nc});
|
|
41
47
|
|
|
42
48
|
src0 = std::make_shared<ov::op::v8::Slice>(combined, start0, stop0, step, axis);
|
|
43
49
|
src1 = std::make_shared<ov::op::v8::Slice>(combined, start1, stop1, step, axis);
|
|
@@ -49,6 +55,12 @@ OutputVector translate_glu_swiglu(const NodeContext & context) {
|
|
|
49
55
|
std::swap(src0, src1);
|
|
50
56
|
}
|
|
51
57
|
|
|
58
|
+
return {src0, src1};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
OutputVector translate_glu_swiglu(const NodeContext & context) {
|
|
62
|
+
auto [src0, src1] = get_glu_inputs(context);
|
|
63
|
+
|
|
52
64
|
auto sigmoid = std::make_shared<ov::op::v0::Sigmoid>(src0);
|
|
53
65
|
auto silu = std::make_shared<ov::op::v1::Multiply>(src0, sigmoid);
|
|
54
66
|
auto res = std::make_shared<ov::op::v1::Multiply>(silu, src1);
|
|
@@ -56,6 +68,27 @@ OutputVector translate_glu_swiglu(const NodeContext & context) {
|
|
|
56
68
|
return rename_outputs_with_suffix({res}, context.get_name());
|
|
57
69
|
}
|
|
58
70
|
|
|
71
|
+
OutputVector translate_glu_swiglu_oai(const NodeContext & context) {
|
|
72
|
+
auto [src0, src1] = get_glu_inputs(context);
|
|
73
|
+
|
|
74
|
+
const int32_t * params = context.get_output_op_params();
|
|
75
|
+
const float alpha = reinterpret_cast<const float *>(params)[2];
|
|
76
|
+
const float limit = reinterpret_cast<const float *>(params)[3];
|
|
77
|
+
|
|
78
|
+
auto gate = std::make_shared<ov::op::v0::Clamp>(src0, -std::numeric_limits<float>::infinity(), limit);
|
|
79
|
+
auto alpha_const = ov::op::v0::Constant::create(ov::element::f32, {}, {alpha});
|
|
80
|
+
auto scaled_gate = std::make_shared<ov::op::v1::Multiply>(gate, alpha_const);
|
|
81
|
+
auto sigmoid = std::make_shared<ov::op::v0::Sigmoid>(scaled_gate);
|
|
82
|
+
auto out_glu = std::make_shared<ov::op::v1::Multiply>(gate, sigmoid);
|
|
83
|
+
|
|
84
|
+
auto up = std::make_shared<ov::op::v0::Clamp>(src1, -limit, limit);
|
|
85
|
+
auto one = ov::op::v0::Constant::create(ov::element::f32, {}, {1.0f});
|
|
86
|
+
auto up_plus_one = std::make_shared<ov::op::v1::Add>(up, one);
|
|
87
|
+
auto res = std::make_shared<ov::op::v1::Multiply>(out_glu, up_plus_one);
|
|
88
|
+
|
|
89
|
+
return rename_outputs_with_suffix({res}, context.get_name());
|
|
90
|
+
}
|
|
91
|
+
|
|
59
92
|
} // namespace op
|
|
60
93
|
} // namespace ggml
|
|
61
94
|
} // namespace frontend
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
#include "ggml-impl.h"
|
|
5
|
+
|
|
6
|
+
#include <cstddef>
|
|
7
|
+
#include <memory>
|
|
8
|
+
#include <openvino/core/shape.hpp>
|
|
9
|
+
#include <openvino/core/strides.hpp>
|
|
10
|
+
#include <openvino/op/constant.hpp>
|
|
11
|
+
#include <openvino/op/convert.hpp>
|
|
12
|
+
#include <openvino/op/extractimagepatches.hpp>
|
|
13
|
+
#include <openvino/op/pad.hpp>
|
|
14
|
+
#include <openvino/op/reshape.hpp>
|
|
15
|
+
#include <openvino/op/transpose.hpp>
|
|
16
|
+
#include <openvino/op/util/attr_types.hpp>
|
|
17
|
+
|
|
18
|
+
namespace ov {
|
|
19
|
+
namespace frontend {
|
|
20
|
+
namespace ggml {
|
|
21
|
+
namespace op {
|
|
22
|
+
|
|
23
|
+
OutputVector translate_im2col(const NodeContext & context) {
|
|
24
|
+
num_inputs_check(context, 2, 2);
|
|
25
|
+
const int32_t * params = context.get_output_op_params();
|
|
26
|
+
int32_t s0 = params[0];
|
|
27
|
+
int32_t s1 = params[1];
|
|
28
|
+
int32_t p0 = params[2];
|
|
29
|
+
int32_t p1 = params[3];
|
|
30
|
+
int32_t d0 = params[4];
|
|
31
|
+
int32_t d1 = params[5];
|
|
32
|
+
bool is_2D = params[6] == 1;
|
|
33
|
+
ov::Output<Node> res;
|
|
34
|
+
|
|
35
|
+
ov::Output<Node> image = context.get_input(1);
|
|
36
|
+
const ov::Shape kernel_shape = context.get_input(0).get_shape();
|
|
37
|
+
|
|
38
|
+
const size_t IC = is_2D ? kernel_shape[1] : kernel_shape[2];
|
|
39
|
+
const size_t KH = is_2D ? kernel_shape[2] : 1;
|
|
40
|
+
const size_t KW = kernel_shape[3];
|
|
41
|
+
|
|
42
|
+
int32_t stride_w = s0;
|
|
43
|
+
int32_t stride_h = is_2D ? s1 : 1;
|
|
44
|
+
int32_t pad_w = p0;
|
|
45
|
+
int32_t pad_h = is_2D ? p1 : 0;
|
|
46
|
+
int32_t dil_w = d0;
|
|
47
|
+
int32_t dil_h = is_2D ? d1 : 1;
|
|
48
|
+
|
|
49
|
+
if (!is_2D) {
|
|
50
|
+
// GGML input shape: [IW, IC, N, 1]
|
|
51
|
+
// OpenVINO input shape: [1, N, IC, IW]
|
|
52
|
+
// Reshape image to: [N, IC, 1, IW]
|
|
53
|
+
const ov::Shape image_shape = image.get_shape();
|
|
54
|
+
const size_t N = image_shape[1];
|
|
55
|
+
const size_t IW = image_shape[3];
|
|
56
|
+
auto image_reshape_shape = ov::op::v0::Constant::create(
|
|
57
|
+
ov::element::i64, ov::Shape{4},
|
|
58
|
+
std::vector<int64_t>{static_cast<int64_t>(N), static_cast<int64_t>(IC), 1, static_cast<int64_t>(IW)});
|
|
59
|
+
image = std::make_shared<ov::op::v1::Reshape>(image, image_reshape_shape, false);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const ov::Shape patch_sizes = {KH, KW};
|
|
63
|
+
const ov::Strides strides = {static_cast<size_t>(stride_h), static_cast<size_t>(stride_w)};
|
|
64
|
+
const ov::Shape rates = {static_cast<size_t>(dil_h), static_cast<size_t>(dil_w)};
|
|
65
|
+
|
|
66
|
+
auto pads_begin =
|
|
67
|
+
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, std::vector<int64_t>{0, 0, pad_h, pad_w});
|
|
68
|
+
auto pads_end =
|
|
69
|
+
ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, std::vector<int64_t>{0, 0, pad_h, pad_w});
|
|
70
|
+
|
|
71
|
+
auto pad = std::make_shared<ov::op::v1::Pad>(image, pads_begin, pads_end, ov::op::PadMode::CONSTANT);
|
|
72
|
+
auto patches =
|
|
73
|
+
std::make_shared<ov::op::v3::ExtractImagePatches>(pad, patch_sizes, strides, rates, ov::op::PadType::VALID);
|
|
74
|
+
|
|
75
|
+
// [N, KH*KW*IC, OH, OW] → [N, OH, OW, KH*KW*IC]
|
|
76
|
+
auto perm1 = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{4}, std::vector<int64_t>{0, 2, 3, 1});
|
|
77
|
+
auto t1 = std::make_shared<ov::op::v1::Transpose>(patches, perm1);
|
|
78
|
+
|
|
79
|
+
// [N, OH, OW, KH*KW*IC] → [N, OH, OW, KH*KW, IC]
|
|
80
|
+
const ov::Shape out_shape = t1->get_output_shape(0);
|
|
81
|
+
const size_t N = out_shape[0];
|
|
82
|
+
const size_t OH = out_shape[1];
|
|
83
|
+
const size_t OW = out_shape[2];
|
|
84
|
+
auto reshape1_shape = ov::op::v0::Constant::create(
|
|
85
|
+
ov::element::i64, ov::Shape{5},
|
|
86
|
+
std::vector<int64_t>{static_cast<int64_t>(N), static_cast<int64_t>(OH), static_cast<int64_t>(OW),
|
|
87
|
+
static_cast<int64_t>(KH * KW), static_cast<int64_t>(IC)});
|
|
88
|
+
auto r1 = std::make_shared<ov::op::v1::Reshape>(t1, reshape1_shape, false);
|
|
89
|
+
|
|
90
|
+
// [N, OH, OW, KH*KW, IC] → [N, OH, OW, IC, KH*KW]
|
|
91
|
+
auto perm2 = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{5}, std::vector<int64_t>{0, 1, 2, 4, 3});
|
|
92
|
+
auto t2 = std::make_shared<ov::op::v1::Transpose>(r1, perm2);
|
|
93
|
+
|
|
94
|
+
// flatten back to [N, OH, OW, IC*KH*KW]
|
|
95
|
+
auto r2_shape = ov::op::v0::Constant::create(
|
|
96
|
+
ov::element::i64, ov::Shape{4},
|
|
97
|
+
std::vector<int64_t>{static_cast<int64_t>(N), static_cast<int64_t>(OH), static_cast<int64_t>(OW),
|
|
98
|
+
static_cast<int64_t>(IC * KH * KW)});
|
|
99
|
+
res = std::make_shared<ov::op::v1::Reshape>(t2, r2_shape, false);
|
|
100
|
+
|
|
101
|
+
if (!is_2D) {
|
|
102
|
+
// [N, 1, OW, IC * KW] -> [1, N, OW, IC * KW]
|
|
103
|
+
auto final_reshape_shape = ov::op::v0::Constant::create(
|
|
104
|
+
ov::element::i64, ov::Shape{4},
|
|
105
|
+
std::vector<int64_t>{1, static_cast<int64_t>(N), static_cast<int64_t>(OW), static_cast<int64_t>(IC * KW)});
|
|
106
|
+
res = std::make_shared<ov::op::v1::Reshape>(res, final_reshape_shape, false);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
auto output_type = context.get_output_type();
|
|
110
|
+
if (res.get_element_type() != output_type) {
|
|
111
|
+
res = std::make_shared<ov::op::v0::Convert>(res, output_type);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return rename_outputs_with_suffix({res}, context.get_name());
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
} // namespace op
|
|
118
|
+
} // namespace ggml
|
|
119
|
+
} // namespace frontend
|
|
120
|
+
} // namespace ov
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <openvino/op/constant.hpp>
|
|
7
|
+
#include <openvino/op/divide.hpp>
|
|
8
|
+
#include <openvino/op/maximum.hpp>
|
|
9
|
+
#include <openvino/op/multiply.hpp>
|
|
10
|
+
#include <openvino/op/reduce_sum.hpp>
|
|
11
|
+
#include <openvino/op/sqrt.hpp>
|
|
12
|
+
|
|
13
|
+
namespace ov {
|
|
14
|
+
namespace frontend {
|
|
15
|
+
namespace ggml {
|
|
16
|
+
namespace op {
|
|
17
|
+
|
|
18
|
+
OutputVector translate_l2_norm(const NodeContext & context) {
|
|
19
|
+
num_inputs_check(context, 1, 1);
|
|
20
|
+
|
|
21
|
+
auto input_node = process_view_input_new(context, 0);
|
|
22
|
+
|
|
23
|
+
auto squared = std::make_shared<ov::op::v1::Multiply>(input_node, input_node);
|
|
24
|
+
|
|
25
|
+
auto sum_squared = std::make_shared<ov::op::v1::ReduceSum>(
|
|
26
|
+
squared, ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1}), true);
|
|
27
|
+
|
|
28
|
+
auto l2_norm = std::make_shared<ov::op::v0::Sqrt>(sum_squared);
|
|
29
|
+
|
|
30
|
+
float eps;
|
|
31
|
+
memcpy(&eps, context.get_output_op_params(), sizeof(float));
|
|
32
|
+
|
|
33
|
+
auto eps_const = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{1}, {eps});
|
|
34
|
+
auto clamped_norm = std::make_shared<ov::op::v1::Maximum>(l2_norm, eps_const);
|
|
35
|
+
|
|
36
|
+
auto res = std::make_shared<ov::op::v1::Divide>(input_node, clamped_norm);
|
|
37
|
+
|
|
38
|
+
return rename_outputs_with_suffix({res}, context.get_name());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
} // namespace op
|
|
42
|
+
} // namespace ggml
|
|
43
|
+
} // namespace frontend
|
|
44
|
+
} // namespace ov
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
#include "../node_context.h"
|
|
2
|
+
#include "../op_table.h"
|
|
3
|
+
#include "../utils.h"
|
|
4
|
+
|
|
5
|
+
#include <cstdint>
|
|
6
|
+
#include <cstring>
|
|
7
|
+
#include <limits>
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <openvino/op/bitwise_and.hpp>
|
|
10
|
+
#include <openvino/op/bitwise_right_shift.hpp>
|
|
11
|
+
#include <openvino/op/broadcast.hpp>
|
|
12
|
+
#include <openvino/op/concat.hpp>
|
|
13
|
+
#include <openvino/op/constant.hpp>
|
|
14
|
+
#include <openvino/op/convert.hpp>
|
|
15
|
+
#include <openvino/op/gather.hpp>
|
|
16
|
+
#include <openvino/op/matmul.hpp>
|
|
17
|
+
#include <openvino/op/multiply.hpp>
|
|
18
|
+
#include <openvino/op/reshape.hpp>
|
|
19
|
+
#include <openvino/op/shape_of.hpp>
|
|
20
|
+
#include <openvino/op/slice.hpp>
|
|
21
|
+
#include <openvino/op/unsqueeze.hpp>
|
|
22
|
+
#include <vector>
|
|
23
|
+
|
|
24
|
+
namespace ov {
|
|
25
|
+
namespace frontend {
|
|
26
|
+
namespace ggml {
|
|
27
|
+
namespace op {
|
|
28
|
+
|
|
29
|
+
namespace {
|
|
30
|
+
|
|
31
|
+
std::shared_ptr<ov::op::v0::Constant> const_i64(const std::vector<int64_t> & values) {
|
|
32
|
+
return ov::op::v0::Constant::create(ov::element::i64, ov::Shape{values.size()}, values);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
ov::Output<ov::Node> slice_axis(const ov::Output<ov::Node> & input, int64_t axis, int64_t begin, int64_t end) {
|
|
36
|
+
return std::make_shared<ov::op::v8::Slice>(input, const_i64({begin}), const_i64({end}), const_i64({1}),
|
|
37
|
+
const_i64({axis}));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
ov::Output<ov::Node> translate_mul_mat_id_mxfp4_packed(const NodeContext & context,
|
|
41
|
+
ov::Output<ov::Node> expert_weights,
|
|
42
|
+
ov::Output<ov::Node> activations,
|
|
43
|
+
ov::Output<ov::Node> ids) {
|
|
44
|
+
auto packed_shape = expert_weights.get_partial_shape().to_shape();
|
|
45
|
+
FRONT_END_OP_CONVERSION_CHECK(packed_shape.size() == 5 && packed_shape[4] == 17,
|
|
46
|
+
"Expected packed MXFP4 expert weights with shape [1, n_expert, m, k_blocks, 17]");
|
|
47
|
+
|
|
48
|
+
const int64_t n_expert = static_cast<int64_t>(packed_shape[1]);
|
|
49
|
+
const int64_t rows = static_cast<int64_t>(packed_shape[2]);
|
|
50
|
+
const int64_t k_blocks = static_cast<int64_t>(packed_shape[3]);
|
|
51
|
+
const int64_t qk = 32;
|
|
52
|
+
const int64_t cols = k_blocks * qk;
|
|
53
|
+
|
|
54
|
+
auto packed_shape_4d = const_i64({n_expert, rows, k_blocks, 17});
|
|
55
|
+
expert_weights = std::make_shared<ov::op::v1::Reshape>(expert_weights, packed_shape_4d, false);
|
|
56
|
+
|
|
57
|
+
auto activations_shape_4d = std::make_shared<ov::op::v3::ShapeOf>(activations, ov::element::i64);
|
|
58
|
+
auto ids_shape_4d = std::make_shared<ov::op::v3::ShapeOf>(ids, ov::element::i64);
|
|
59
|
+
auto activations_shape_3d = get_dimensions(activations_shape_4d, {1, 2, 3});
|
|
60
|
+
auto ids_shape_2d = get_dimensions(ids_shape_4d, {2, 3});
|
|
61
|
+
|
|
62
|
+
activations = std::make_shared<ov::op::v1::Reshape>(activations, activations_shape_3d, false);
|
|
63
|
+
ids = std::make_shared<ov::op::v1::Reshape>(ids, ids_shape_2d, false);
|
|
64
|
+
if (ids.get_element_type() != ov::element::i32 && ids.get_element_type() != ov::element::i64) {
|
|
65
|
+
ids = std::make_shared<ov::op::v0::Convert>(ids, ov::element::i32);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
auto gather_axis = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0});
|
|
69
|
+
|
|
70
|
+
static const std::vector<float> f4e2m1_lut = {0.0f, 0.5f, 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f,
|
|
71
|
+
-0.0f, -0.5f, -1.0f, -1.5f, -2.0f, -3.0f, -4.0f, -6.0f};
|
|
72
|
+
std::vector<float> e8m0_lut(256);
|
|
73
|
+
for (size_t i = 0; i < e8m0_lut.size(); ++i) {
|
|
74
|
+
uint32_t bits = static_cast<uint32_t>(i) << 23;
|
|
75
|
+
memcpy(&e8m0_lut[i], &bits, sizeof(float));
|
|
76
|
+
}
|
|
77
|
+
e8m0_lut[0] = std::numeric_limits<float>::min() / 2.0f;
|
|
78
|
+
e8m0_lut[255] = std::numeric_limits<float>::quiet_NaN();
|
|
79
|
+
|
|
80
|
+
auto f4_lut = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{f4e2m1_lut.size()}, f4e2m1_lut);
|
|
81
|
+
auto scale_lut = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{e8m0_lut.size()}, e8m0_lut);
|
|
82
|
+
|
|
83
|
+
auto selected_packed_weights = std::make_shared<ov::op::v8::Gather>(expert_weights, ids, gather_axis);
|
|
84
|
+
auto scale_byte = slice_axis(selected_packed_weights, 4, 0, 1);
|
|
85
|
+
auto qs = slice_axis(selected_packed_weights, 4, 1, 17);
|
|
86
|
+
auto low = std::make_shared<ov::op::v13::BitwiseAnd>(
|
|
87
|
+
qs, ov::op::v0::Constant::create(ov::element::u8, ov::Shape{}, {0x0F}), ov::op::AutoBroadcastType::NUMPY);
|
|
88
|
+
auto high_shift = std::make_shared<ov::op::v15::BitwiseRightShift>(
|
|
89
|
+
qs, ov::op::v0::Constant::create(ov::element::u8, ov::Shape{}, {4}), ov::op::AutoBroadcastType::NUMPY);
|
|
90
|
+
auto nibbles = std::make_shared<ov::op::v0::Concat>(ov::OutputVector{low, high_shift}, 4);
|
|
91
|
+
auto nibble_indices = std::make_shared<ov::op::v0::Convert>(nibbles, ov::element::i32);
|
|
92
|
+
auto weights_f32 = std::make_shared<ov::op::v8::Gather>(f4_lut, nibble_indices, gather_axis);
|
|
93
|
+
|
|
94
|
+
auto scale_indices = std::make_shared<ov::op::v0::Convert>(scale_byte, ov::element::i32);
|
|
95
|
+
auto scales_f32 = std::make_shared<ov::op::v8::Gather>(scale_lut, scale_indices, gather_axis);
|
|
96
|
+
ov::Output<ov::Node> selected_weights = std::make_shared<ov::op::v1::Multiply>(weights_f32, scales_f32,
|
|
97
|
+
ov::op::AutoBroadcastType::NUMPY);
|
|
98
|
+
|
|
99
|
+
auto ids_shape = std::make_shared<ov::op::v3::ShapeOf>(ids, ov::element::i64);
|
|
100
|
+
auto selected_weights_target_dims = std::make_shared<ov::op::v0::Concat>(
|
|
101
|
+
ov::OutputVector{get_dimensions(ids_shape, {0, 1}), const_i64({rows, cols})}, 0);
|
|
102
|
+
selected_weights = std::make_shared<ov::op::v1::Reshape>(selected_weights, selected_weights_target_dims, false);
|
|
103
|
+
|
|
104
|
+
auto activations_shape = std::make_shared<ov::op::v3::ShapeOf>(activations, ov::element::i64);
|
|
105
|
+
ov::Output<ov::Node> acts_target_dims = std::make_shared<ov::op::v0::Concat>(
|
|
106
|
+
ov::OutputVector{
|
|
107
|
+
get_dimensions(activations_shape, {0}),
|
|
108
|
+
get_dimensions(ids_shape, {1}),
|
|
109
|
+
get_dimensions(activations_shape, {2}),
|
|
110
|
+
},
|
|
111
|
+
0);
|
|
112
|
+
ov::Output<ov::Node> acts_broadcasted =
|
|
113
|
+
std::make_shared<ov::op::v3::Broadcast>(activations, acts_target_dims, ov::op::BroadcastType::BIDIRECTIONAL);
|
|
114
|
+
|
|
115
|
+
auto activations_expanded = std::make_shared<ov::op::v0::Unsqueeze>(acts_broadcasted, const_i64({2}));
|
|
116
|
+
ov::Output<ov::Node> result =
|
|
117
|
+
std::make_shared<ov::op::v0::MatMul>(activations_expanded, selected_weights, false, true);
|
|
118
|
+
|
|
119
|
+
auto batch_dim = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
120
|
+
auto row_dim = ov::op::v0::Constant::create(ov::element::i64, {1}, {rows});
|
|
121
|
+
auto result_target_dims = std::make_shared<ov::op::v0::Concat>(
|
|
122
|
+
ov::OutputVector{batch_dim, get_dimensions(ids_shape, {0, 1}), row_dim}, 0);
|
|
123
|
+
result = std::make_shared<ov::op::v1::Reshape>(result, result_target_dims, false);
|
|
124
|
+
|
|
125
|
+
const auto output_type = context.get_output_type();
|
|
126
|
+
if (result.get_element_type() != output_type) {
|
|
127
|
+
result = std::make_shared<ov::op::v0::Convert>(result, output_type);
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
} // namespace
|
|
133
|
+
|
|
134
|
+
OutputVector translate_mul_mat_id(const NodeContext & context) {
|
|
135
|
+
num_inputs_check(context, 3, 3);
|
|
136
|
+
|
|
137
|
+
auto expert_weights = process_view_input_new(context, 0);
|
|
138
|
+
auto activations = process_view_input_new(context, 1);
|
|
139
|
+
auto ids = process_view_input_new(context, 2);
|
|
140
|
+
|
|
141
|
+
if (expert_weights.get_element_type() == ov::element::u8 && expert_weights.get_partial_shape().rank().is_static() &&
|
|
142
|
+
expert_weights.get_partial_shape().rank().get_length() == 5) {
|
|
143
|
+
return rename_outputs_with_suffix({translate_mul_mat_id_mxfp4_packed(context, expert_weights, activations, ids)},
|
|
144
|
+
context.get_name());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// OpenVINO sees GGML tensors in reversed dimension order:
|
|
148
|
+
// weights: [1, n_expert, m, k]
|
|
149
|
+
// activations: [1, n_tokens, n_used_or_1, k]
|
|
150
|
+
// ids: [1, 1, n_tokens, n_used]
|
|
151
|
+
// Rebuild the logical ranks explicitly from the 4D inputs instead of relying
|
|
152
|
+
// on fixed squeeze axes: real graphs can arrive through VIEW/RESHAPE chains
|
|
153
|
+
// where singleton axes are still represented differently at this point.
|
|
154
|
+
auto expert_weights_shape_4d = std::make_shared<ov::op::v3::ShapeOf>(expert_weights, ov::element::i64);
|
|
155
|
+
auto activations_shape_4d = std::make_shared<ov::op::v3::ShapeOf>(activations, ov::element::i64);
|
|
156
|
+
auto ids_shape_4d = std::make_shared<ov::op::v3::ShapeOf>(ids, ov::element::i64);
|
|
157
|
+
|
|
158
|
+
auto expert_weights_shape_3d = get_dimensions(expert_weights_shape_4d, {1, 2, 3});
|
|
159
|
+
auto activations_shape_3d = get_dimensions(activations_shape_4d, {1, 2, 3});
|
|
160
|
+
auto ids_shape_2d = get_dimensions(ids_shape_4d, {2, 3});
|
|
161
|
+
|
|
162
|
+
expert_weights = std::make_shared<ov::op::v1::Reshape>(expert_weights, expert_weights_shape_3d, false);
|
|
163
|
+
activations = std::make_shared<ov::op::v1::Reshape>(activations, activations_shape_3d, false);
|
|
164
|
+
ids = std::make_shared<ov::op::v1::Reshape>(ids, ids_shape_2d, false);
|
|
165
|
+
|
|
166
|
+
if (ids.get_element_type() != ov::element::i32 && ids.get_element_type() != ov::element::i64) {
|
|
167
|
+
ids = std::make_shared<ov::op::v0::Convert>(ids, ov::element::i32);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
auto gather_axis = ov::op::v0::Constant::create(ov::element::i32, ov::Shape{}, {0});
|
|
171
|
+
ov::Output<ov::Node> selected_weights = std::make_shared<ov::op::v8::Gather>(expert_weights, ids, gather_axis);
|
|
172
|
+
|
|
173
|
+
const auto output_type = context.get_output_type();
|
|
174
|
+
if (selected_weights.get_element_type() != ov::element::f32) {
|
|
175
|
+
selected_weights = std::make_shared<ov::op::v0::Convert>(selected_weights, ov::element::f32);
|
|
176
|
+
}
|
|
177
|
+
if (activations.get_element_type() != ov::element::f32) {
|
|
178
|
+
activations = std::make_shared<ov::op::v0::Convert>(activations, ov::element::f32);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
auto activations_shape = std::make_shared<ov::op::v3::ShapeOf>(activations, ov::element::i64);
|
|
182
|
+
auto ids_shape = std::make_shared<ov::op::v3::ShapeOf>(ids, ov::element::i64);
|
|
183
|
+
ov::Output<ov::Node> acts_target_dims = std::make_shared<ov::op::v0::Concat>(
|
|
184
|
+
ov::OutputVector{
|
|
185
|
+
get_dimensions(activations_shape, {0}),
|
|
186
|
+
get_dimensions(ids_shape, {1}),
|
|
187
|
+
get_dimensions(activations_shape, {2}),
|
|
188
|
+
},
|
|
189
|
+
0);
|
|
190
|
+
ov::Output<ov::Node> acts_broadcasted =
|
|
191
|
+
std::make_shared<ov::op::v3::Broadcast>(activations, acts_target_dims, ov::op::BroadcastType::BIDIRECTIONAL);
|
|
192
|
+
|
|
193
|
+
auto unsqueeze_axes = ov::op::v0::Constant::create(ov::element::i64, {1}, {2});
|
|
194
|
+
auto activations_expanded = std::make_shared<ov::op::v0::Unsqueeze>(acts_broadcasted, unsqueeze_axes);
|
|
195
|
+
|
|
196
|
+
auto batch_dim = ov::op::v0::Constant::create(ov::element::i64, {1}, {1});
|
|
197
|
+
auto output_shape = context.get_output_shape();
|
|
198
|
+
FRONT_END_OP_CONVERSION_CHECK(output_shape.rank().is_static() && output_shape.rank().get_length() == 4,
|
|
199
|
+
"Unexpected MUL_MAT_ID output rank");
|
|
200
|
+
FRONT_END_OP_CONVERSION_CHECK(output_shape[3].is_static(), "Expected static row dimension for MUL_MAT_ID output");
|
|
201
|
+
const auto row_dim_value = output_shape[3].get_length();
|
|
202
|
+
auto row_dim = ov::op::v0::Constant::create(ov::element::i64, {1}, {row_dim_value});
|
|
203
|
+
|
|
204
|
+
ov::Output<ov::Node> result =
|
|
205
|
+
std::make_shared<ov::op::v0::MatMul>(activations_expanded, selected_weights, false, true);
|
|
206
|
+
|
|
207
|
+
auto result_target_dims = std::make_shared<ov::op::v0::Concat>(
|
|
208
|
+
ov::OutputVector{
|
|
209
|
+
batch_dim,
|
|
210
|
+
get_dimensions(ids_shape, {0, 1}),
|
|
211
|
+
row_dim,
|
|
212
|
+
},
|
|
213
|
+
0);
|
|
214
|
+
result = std::make_shared<ov::op::v1::Reshape>(result, result_target_dims, false);
|
|
215
|
+
|
|
216
|
+
if (result.get_element_type() != output_type) {
|
|
217
|
+
result = std::make_shared<ov::op::v0::Convert>(result, output_type);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return rename_outputs_with_suffix({result}, context.get_name());
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
} // namespace op
|
|
224
|
+
} // namespace ggml
|
|
225
|
+
} // namespace frontend
|
|
226
|
+
} // namespace ov
|