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
|
@@ -1144,6 +1144,11 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor_impl(ggml_backend_m
|
|
|
1144
1144
|
ggml_context * simple_ctx = stc.ctxs[j].get();
|
|
1145
1145
|
ggml_backend_buffer_t simple_buf = buf_ctx->bufs[j].get();
|
|
1146
1146
|
|
|
1147
|
+
if ((simple_buf != nullptr) && ggml_backend_buffer_is_multi_buffer(simple_buf)) {
|
|
1148
|
+
// see https://github.com/ggml-org/llama.cpp/issues/22197
|
|
1149
|
+
GGML_ABORT("multi buffers are not supported by the meta backend");
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1147
1152
|
if (split_dim >= 0 && split_dim < GGML_MAX_DIMS) {
|
|
1148
1153
|
// TODO: the following assert fails for llama-parallel even though the results are correct:
|
|
1149
1154
|
// GGML_ASSERT(ggml_is_contiguously_allocated(tensor));
|
|
@@ -1245,9 +1250,8 @@ static enum ggml_status ggml_backend_meta_buffer_init_tensor(ggml_backend_buffer
|
|
|
1245
1250
|
|
|
1246
1251
|
static void ggml_backend_meta_buffer_set_tensor(ggml_backend_buffer_t buffer, ggml_tensor * tensor, const void * data, size_t offset, size_t size) {
|
|
1247
1252
|
const size_t n_bufs = ggml_backend_meta_buffer_n_bufs(buffer);
|
|
1248
|
-
GGML_ASSERT(ggml_is_contiguous(tensor));
|
|
1249
|
-
|
|
1250
1253
|
const ggml_backend_meta_split_state split_state = ggml_backend_meta_get_split_state(tensor, /*assume_sync =*/ false);
|
|
1254
|
+
GGML_ASSERT(ggml_is_contiguous(tensor) || split_state.axis == GGML_BACKEND_SPLIT_AXIS_MIRRORED);
|
|
1251
1255
|
|
|
1252
1256
|
if (split_state.n_segments != 1 || split_state.nr[0] != 1) {
|
|
1253
1257
|
GGML_ASSERT(split_state.axis >= 0 && split_state.axis < GGML_MAX_DIMS);
|
|
@@ -1360,9 +1364,8 @@ static void ggml_backend_meta_buffer_set_tensor(ggml_backend_buffer_t buffer, gg
|
|
|
1360
1364
|
|
|
1361
1365
|
static void ggml_backend_meta_buffer_get_tensor(ggml_backend_buffer_t buffer, const ggml_tensor * tensor, void * data, size_t offset, size_t size) {
|
|
1362
1366
|
const size_t n_bufs = ggml_backend_meta_buffer_n_bufs(buffer);
|
|
1363
|
-
GGML_ASSERT(ggml_is_contiguous(tensor));
|
|
1364
|
-
|
|
1365
1367
|
const ggml_backend_meta_split_state split_state = ggml_backend_meta_get_split_state(tensor, /*assume_sync =*/ false);
|
|
1368
|
+
GGML_ASSERT(ggml_is_contiguous(tensor) || split_state.axis == GGML_BACKEND_SPLIT_AXIS_MIRRORED);
|
|
1366
1369
|
|
|
1367
1370
|
if (split_state.n_segments != 1 || split_state.nr[0] != 1) {
|
|
1368
1371
|
GGML_ASSERT(split_state.axis >= 0 && split_state.axis < GGML_MAX_DIMS);
|
|
@@ -96,6 +96,9 @@ typedef sycl::half2 ggml_half2;
|
|
|
96
96
|
#define QI1_0 (QK1_0 / 32)
|
|
97
97
|
#define QR1_0 1
|
|
98
98
|
|
|
99
|
+
#define QI2_0 (QK2_0 / 32)
|
|
100
|
+
#define QR2_0 1
|
|
101
|
+
|
|
99
102
|
|
|
100
103
|
#define QI4_0 (QK4_0 / (4 * QR4_0))
|
|
101
104
|
#define QR4_0 2
|
|
@@ -181,6 +184,13 @@ typedef struct {
|
|
|
181
184
|
} block_q1_0;
|
|
182
185
|
static_assert(sizeof(block_q1_0) == sizeof(ggml_half) + QK1_0 / 8, "wrong q1_0 block size/padding");
|
|
183
186
|
|
|
187
|
+
#define QK2_0 64
|
|
188
|
+
typedef struct {
|
|
189
|
+
ggml_half d; // delta (scale)
|
|
190
|
+
uint8_t qs[QK2_0 / 4]; // 2 bits per element
|
|
191
|
+
} block_q2_0;
|
|
192
|
+
static_assert(sizeof(block_q2_0) == sizeof(ggml_half) + QK2_0 / 4, "wrong q2_0 block size/padding");
|
|
193
|
+
|
|
184
194
|
#define QK4_0 32
|
|
185
195
|
typedef struct {
|
|
186
196
|
ggml_half d; // delta
|
|
@@ -1111,11 +1121,12 @@ GGML_TABLE_BEGIN(int8_t, kvalues_iq4nl, 16)
|
|
|
1111
1121
|
-127, -104, -83, -65, -49, -35, -22, -10, 1, 13, 25, 38, 53, 69, 89, 113,
|
|
1112
1122
|
GGML_TABLE_END()
|
|
1113
1123
|
|
|
1114
|
-
// e2m1 values (doubled)
|
|
1124
|
+
// e2m1 values (doubled), shared by MXFP4 and NVFP4
|
|
1115
1125
|
// ref: https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
|
|
1116
|
-
GGML_TABLE_BEGIN(int8_t,
|
|
1126
|
+
GGML_TABLE_BEGIN(int8_t, kvalues_fp4, 16)
|
|
1117
1127
|
0, 1, 2, 3, 4, 6, 8, 12, 0, -1, -2, -3, -4, -6, -8, -12,
|
|
1118
1128
|
GGML_TABLE_END()
|
|
1129
|
+
#define kvalues_mxfp4 kvalues_fp4
|
|
1119
1130
|
|
|
1120
1131
|
#define NGRID_IQ1S 2048
|
|
1121
1132
|
#define IQ1S_DELTA 0.125f
|
|
@@ -389,7 +389,7 @@ function(ggml_add_cpu_backend_variant_impl tag_name)
|
|
|
389
389
|
string(REGEX MATCHALL "POWER *([0-9]+)" MATCHED_STRING "${POWER10_M_UPPER}")
|
|
390
390
|
string(REGEX REPLACE "POWER *([0-9]+)" "\\1" EXTRACTED_NUMBER "${MATCHED_STRING}")
|
|
391
391
|
|
|
392
|
-
if (EXTRACTED_NUMBER
|
|
392
|
+
if (EXTRACTED_NUMBER EQUAL 10 OR EXTRACTED_NUMBER EQUAL 11)
|
|
393
393
|
list(APPEND ARCH_FLAGS -mcpu=power10)
|
|
394
394
|
elseif (EXTRACTED_NUMBER EQUAL 9)
|
|
395
395
|
list(APPEND ARCH_FLAGS -mcpu=power9)
|
|
@@ -2417,15 +2417,14 @@ void ggml_backend_amx_mul_mat(const ggml_compute_params * params, struct ggml_te
|
|
|
2417
2417
|
// Q4_K, Q5_K, Q6_K, IQ4_XS handles 8 TILE_K per blck_size
|
|
2418
2418
|
GGML_ASSERT(TILE_K == blck_size || TILE_K * 8 == blck_size);
|
|
2419
2419
|
|
|
2420
|
-
parallel_for_ggml(params, n_batch, [&](int begin, int end) {
|
|
2421
|
-
for (int
|
|
2420
|
+
parallel_for_ggml(params, n_batch * M, [&](int begin, int end) {
|
|
2421
|
+
for (int idx = begin; idx < end; ++idx) {
|
|
2422
|
+
int batch_idx = idx / M;
|
|
2423
|
+
int m = idx % M;
|
|
2422
2424
|
int64_t src1_offset = ggml_batch_offset(src1, batch_idx, ne2);
|
|
2423
2425
|
const float * A_data = (const float *)((const char *)src1->data + src1_offset);
|
|
2424
2426
|
char * wdata_batch = (char *)wdata + batch_idx * M * row_size_A;
|
|
2425
|
-
|
|
2426
|
-
for (int m = 0; m < M; ++m) {
|
|
2427
|
-
from_float<vec_dot_type>(A_data + m * K, wdata_batch + m * row_size_A, K);
|
|
2428
|
-
}
|
|
2427
|
+
from_float<vec_dot_type>(A_data + m * K, wdata_batch + m * row_size_A, K);
|
|
2429
2428
|
}
|
|
2430
2429
|
});
|
|
2431
2430
|
});
|
|
@@ -219,6 +219,80 @@ void ggml_vec_dot_q1_0_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const voi
|
|
|
219
219
|
#endif
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
void ggml_vec_dot_q2_0_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, size_t bx, const void * GGML_RESTRICT vy, size_t by, int nrc) {
|
|
223
|
+
const int qk = QK2_0;
|
|
224
|
+
const int nb = n / qk;
|
|
225
|
+
|
|
226
|
+
assert(n % qk == 0);
|
|
227
|
+
assert(nrc == 1);
|
|
228
|
+
UNUSED(nrc);
|
|
229
|
+
UNUSED(bx);
|
|
230
|
+
UNUSED(by);
|
|
231
|
+
UNUSED(bs);
|
|
232
|
+
|
|
233
|
+
const block_q2_0 * GGML_RESTRICT x = vx;
|
|
234
|
+
const block_q8_0 * GGML_RESTRICT y = vy;
|
|
235
|
+
|
|
236
|
+
float sumf = 0.0f;
|
|
237
|
+
|
|
238
|
+
#if defined(__ARM_NEON)
|
|
239
|
+
// Replicate pattern: each byte repeated 4 times
|
|
240
|
+
static const uint8_t tbl_idx_lo[16] = {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3};
|
|
241
|
+
static const uint8_t tbl_idx_hi[16] = {4,4,4,4, 5,5,5,5, 6,6,6,6, 7,7,7,7};
|
|
242
|
+
// Right-shift amounts: 0,2,4,6 repeated for each group of 4
|
|
243
|
+
static const int8_t shift_vals[16] = {0,-2,-4,-6, 0,-2,-4,-6, 0,-2,-4,-6, 0,-2,-4,-6};
|
|
244
|
+
|
|
245
|
+
const uint8x16_t idx_lo = vld1q_u8(tbl_idx_lo);
|
|
246
|
+
const uint8x16_t idx_hi = vld1q_u8(tbl_idx_hi);
|
|
247
|
+
const int8x16_t shifts = vld1q_s8(shift_vals);
|
|
248
|
+
const uint8x16_t mask2 = vdupq_n_u8(0x03);
|
|
249
|
+
const int8x16_t one = vdupq_n_s8(1);
|
|
250
|
+
|
|
251
|
+
float32x4_t sumv = vdupq_n_f32(0.0f);
|
|
252
|
+
|
|
253
|
+
for (int i = 0; i < nb; i++) {
|
|
254
|
+
const float d0 = GGML_CPU_FP16_TO_FP32(x[i].d);
|
|
255
|
+
|
|
256
|
+
// group 64: one Q2_0 block (64 weights) maps to two Q8_0 blocks (2 * 32 = 64)
|
|
257
|
+
for (int k = 0; k < 2; k++) {
|
|
258
|
+
const block_q8_0 * GGML_RESTRICT yb = &y[i * 2 + k];
|
|
259
|
+
const float d1 = GGML_CPU_FP16_TO_FP32(yb->d);
|
|
260
|
+
|
|
261
|
+
// Load 8 bytes of packed 2-bit values
|
|
262
|
+
const uint8x8_t raw = vld1_u8(&x[i].qs[k * 8]);
|
|
263
|
+
const uint8x16_t raw16 = vcombine_u8(raw, raw);
|
|
264
|
+
|
|
265
|
+
// First 16 elements: replicate bytes 0-3, shift, mask, subtract 1
|
|
266
|
+
uint8x16_t bytes0 = ggml_vqtbl1q_u8(raw16, idx_lo);
|
|
267
|
+
int8x16_t qv0 = vsubq_s8(
|
|
268
|
+
vreinterpretq_s8_u8(vandq_u8(vshlq_u8(bytes0, shifts), mask2)),
|
|
269
|
+
one);
|
|
270
|
+
|
|
271
|
+
// Second 16 elements: replicate bytes 4-7, shift, mask, subtract 1
|
|
272
|
+
uint8x16_t bytes1 = ggml_vqtbl1q_u8(raw16, idx_hi);
|
|
273
|
+
int8x16_t qv1 = vsubq_s8(
|
|
274
|
+
vreinterpretq_s8_u8(vandq_u8(vshlq_u8(bytes1, shifts), mask2)),
|
|
275
|
+
one);
|
|
276
|
+
|
|
277
|
+
// Load Q8_0 values and dot product
|
|
278
|
+
const int8x16_t y0 = vld1q_s8(yb->qs);
|
|
279
|
+
const int8x16_t y1 = vld1q_s8(yb->qs + 16);
|
|
280
|
+
|
|
281
|
+
int32x4_t p0 = ggml_vdotq_s32(vdupq_n_s32(0), qv0, y0);
|
|
282
|
+
int32x4_t p1 = ggml_vdotq_s32(p0, qv1, y1);
|
|
283
|
+
|
|
284
|
+
sumv = vmlaq_n_f32(sumv, vcvtq_f32_s32(p1), d0 * d1);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
sumf = vaddvq_f32(sumv);
|
|
289
|
+
#else
|
|
290
|
+
ggml_vec_dot_q2_0_q8_0_generic(n, s, bs, vx, bx, vy, by, nrc);
|
|
291
|
+
return;
|
|
292
|
+
#endif
|
|
293
|
+
|
|
294
|
+
*s = sumf;
|
|
295
|
+
}
|
|
222
296
|
|
|
223
297
|
void ggml_vec_dot_q4_0_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, size_t bx, const void * GGML_RESTRICT vy, size_t by, int nrc) {
|
|
224
298
|
const int qk = QK8_0;
|
|
@@ -812,10 +886,10 @@ void ggml_vec_dot_nvfp4_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const vo
|
|
|
812
886
|
const float dy0 = GGML_CPU_FP16_TO_FP32(y[2*ib].d);
|
|
813
887
|
const float dy1 = GGML_CPU_FP16_TO_FP32(y[2*ib+1].d);
|
|
814
888
|
const float32x4_t nvsc = {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
889
|
+
GGML_CPU_UE4M3_TO_FP32(x[ib].d[0]),
|
|
890
|
+
GGML_CPU_UE4M3_TO_FP32(x[ib].d[1]),
|
|
891
|
+
GGML_CPU_UE4M3_TO_FP32(x[ib].d[2]),
|
|
892
|
+
GGML_CPU_UE4M3_TO_FP32(x[ib].d[3])
|
|
819
893
|
};
|
|
820
894
|
const float32x4_t scales = vmulq_f32(nvsc, (float32x4_t){dy0, dy0, dy1, dy1});
|
|
821
895
|
|
|
@@ -934,7 +934,7 @@ void ggml_vec_dot_mxfp4_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const vo
|
|
|
934
934
|
|
|
935
935
|
#if defined __AVX2__
|
|
936
936
|
|
|
937
|
-
const __m128i values128 = _mm_loadu_si128((const __m128i*)
|
|
937
|
+
const __m128i values128 = _mm_loadu_si128((const __m128i*)kvalues_fp4);
|
|
938
938
|
const __m128i m4b = _mm_set1_epi8(0x0f);
|
|
939
939
|
const __m256i mone = _mm256_set1_epi16(1);
|
|
940
940
|
|
|
@@ -963,7 +963,7 @@ void ggml_vec_dot_mxfp4_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const vo
|
|
|
963
963
|
sumf = hsum_float_8(_mm256_add_ps(accum1, accum2));
|
|
964
964
|
|
|
965
965
|
#elif defined __AVX__
|
|
966
|
-
const __m128i values128 = _mm_loadu_si128((const __m128i*)
|
|
966
|
+
const __m128i values128 = _mm_loadu_si128((const __m128i*)kvalues_fp4);
|
|
967
967
|
const __m128i m4b = _mm_set1_epi8(0x0f);
|
|
968
968
|
|
|
969
969
|
__m256 accum = _mm256_setzero_ps();
|
|
@@ -993,14 +993,152 @@ void ggml_vec_dot_mxfp4_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const vo
|
|
|
993
993
|
int sumi1 = 0;
|
|
994
994
|
int sumi2 = 0;
|
|
995
995
|
for (int j = 0; j < QK_MXFP4/2; ++j) {
|
|
996
|
-
sumi1 += y[ib].qs[j + 0] *
|
|
997
|
-
sumi2 += y[ib].qs[j + QK_MXFP4/2] *
|
|
996
|
+
sumi1 += y[ib].qs[j + 0] * kvalues_fp4[x[ib].qs[j] & 0xf];
|
|
997
|
+
sumi2 += y[ib].qs[j + QK_MXFP4/2] * kvalues_fp4[x[ib].qs[j] >> 4];
|
|
998
998
|
}
|
|
999
999
|
sumf += d * (sumi1 + sumi2);
|
|
1000
1000
|
}
|
|
1001
1001
|
*s = sumf;
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
1004
|
+
void ggml_vec_dot_nvfp4_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, size_t bx, const void * GGML_RESTRICT vy, size_t by, int nrc) {
|
|
1005
|
+
assert(nrc == 1);
|
|
1006
|
+
UNUSED(nrc);
|
|
1007
|
+
UNUSED(bx);
|
|
1008
|
+
UNUSED(by);
|
|
1009
|
+
UNUSED(bs);
|
|
1010
|
+
assert(n % QK_NVFP4 == 0);
|
|
1011
|
+
|
|
1012
|
+
const block_nvfp4 * GGML_RESTRICT x = vx;
|
|
1013
|
+
const block_q8_0 * GGML_RESTRICT y = vy;
|
|
1014
|
+
|
|
1015
|
+
const int nb = n / QK_NVFP4;
|
|
1016
|
+
int ib = 0;
|
|
1017
|
+
float sumf = 0;
|
|
1018
|
+
|
|
1019
|
+
#if defined(__AVX2__)
|
|
1020
|
+
|
|
1021
|
+
const __m128i values128 = _mm_loadu_si128((const __m128i*)kvalues_fp4);
|
|
1022
|
+
const __m128i m4b = _mm_set1_epi8(0x0f);
|
|
1023
|
+
const __m256i mone = _mm256_set1_epi16(1);
|
|
1024
|
+
|
|
1025
|
+
__m256 accum = _mm256_setzero_ps();
|
|
1026
|
+
for(; ib < nb; ib++){
|
|
1027
|
+
|
|
1028
|
+
const __m128i q4bits_01 = _mm_loadu_si128((const __m128i *)(x[ib].qs + 0));
|
|
1029
|
+
const __m128i q4bits_23 = _mm_loadu_si128((const __m128i *)(x[ib].qs + 16));
|
|
1030
|
+
|
|
1031
|
+
const __m256i q8_01 = _mm256_loadu_si256((const __m256i *)y[2*ib + 0].qs);
|
|
1032
|
+
const __m256i q8_23 = _mm256_loadu_si256((const __m256i *)y[2*ib + 1].qs);
|
|
1033
|
+
|
|
1034
|
+
const __m128i q4_01_lo = _mm_shuffle_epi8(values128, _mm_and_si128(q4bits_01, m4b));
|
|
1035
|
+
const __m128i q4_01_hi = _mm_shuffle_epi8(values128, _mm_and_si128(_mm_srli_epi16(q4bits_01, 4), m4b));
|
|
1036
|
+
const __m128i q4_23_lo = _mm_shuffle_epi8(values128, _mm_and_si128(q4bits_23, m4b));
|
|
1037
|
+
const __m128i q4_23_hi = _mm_shuffle_epi8(values128, _mm_and_si128(_mm_srli_epi16(q4bits_23, 4), m4b));
|
|
1038
|
+
|
|
1039
|
+
//reordering
|
|
1040
|
+
const __m256i q4_01 = MM256_SET_M128I(_mm_unpackhi_epi64(q4_01_lo,q4_01_hi), _mm_unpacklo_epi64(q4_01_lo,q4_01_hi));
|
|
1041
|
+
const __m256i q4_23 = MM256_SET_M128I(_mm_unpackhi_epi64(q4_23_lo,q4_23_hi),_mm_unpacklo_epi64(q4_23_lo,q4_23_hi));
|
|
1042
|
+
|
|
1043
|
+
const __m256i p01 = mul_add_epi8(q4_01,q8_01);
|
|
1044
|
+
const __m256i p_1 = _mm256_madd_epi16(p01, mone);
|
|
1045
|
+
|
|
1046
|
+
const __m256i p23 = mul_add_epi8(q4_23,q8_23);
|
|
1047
|
+
const __m256i p_2 = _mm256_madd_epi16(p23, mone);
|
|
1048
|
+
|
|
1049
|
+
const float dy0 = GGML_CPU_FP16_TO_FP32(y[2*ib].d);
|
|
1050
|
+
const float dy1 = GGML_CPU_FP16_TO_FP32(y[2*ib+1].d);
|
|
1051
|
+
|
|
1052
|
+
const float s0 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[0]) * dy0;
|
|
1053
|
+
const float s1 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[1]) * dy0;
|
|
1054
|
+
const float s2 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[2]) * dy1;
|
|
1055
|
+
const float s3 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[3]) * dy1;
|
|
1056
|
+
|
|
1057
|
+
const __m256 scales01 = _mm256_set_m128(_mm_set1_ps(s1), _mm_set1_ps(s0));
|
|
1058
|
+
const __m256 scales23 = _mm256_set_m128(_mm_set1_ps(s3), _mm_set1_ps(s2));
|
|
1059
|
+
|
|
1060
|
+
accum = _mm256_fmadd_ps(scales01, _mm256_cvtepi32_ps(p_1), accum);
|
|
1061
|
+
accum = _mm256_fmadd_ps(scales23, _mm256_cvtepi32_ps(p_2), accum);
|
|
1062
|
+
}
|
|
1063
|
+
sumf = hsum_float_8(accum);
|
|
1064
|
+
|
|
1065
|
+
#elif defined(__AVX__)
|
|
1066
|
+
|
|
1067
|
+
const __m128i values128 = _mm_loadu_si128((const __m128i*)kvalues_fp4);
|
|
1068
|
+
const __m128i m4b = _mm_set1_epi8(0x0f);
|
|
1069
|
+
|
|
1070
|
+
__m256 accum = _mm256_setzero_ps();
|
|
1071
|
+
for(; ib < nb; ib++){
|
|
1072
|
+
|
|
1073
|
+
const __m128i q4bits_01 = _mm_loadu_si128((const __m128i *)(x[ib].qs + 0));
|
|
1074
|
+
const __m128i q4bits_23 = _mm_loadu_si128((const __m128i *)(x[ib].qs + 16));
|
|
1075
|
+
|
|
1076
|
+
const __m128i q8_0 = _mm_loadu_si128((const __m128i *)(y[2*ib + 0].qs + 0));
|
|
1077
|
+
const __m128i q8_1 = _mm_loadu_si128((const __m128i *)(y[2*ib + 0].qs + 16));
|
|
1078
|
+
const __m128i q8_2 = _mm_loadu_si128((const __m128i *)(y[2*ib + 1].qs + 0));
|
|
1079
|
+
const __m128i q8_3 = _mm_loadu_si128((const __m128i *)(y[2*ib + 1].qs + 16));
|
|
1080
|
+
|
|
1081
|
+
const __m128i q4_01_lo = _mm_shuffle_epi8(values128, _mm_and_si128(q4bits_01, m4b));
|
|
1082
|
+
const __m128i q4_01_hi = _mm_shuffle_epi8(values128, _mm_and_si128(_mm_srli_epi16(q4bits_01, 4), m4b));
|
|
1083
|
+
const __m128i q4_23_lo = _mm_shuffle_epi8(values128, _mm_and_si128(q4bits_23, m4b));
|
|
1084
|
+
const __m128i q4_23_hi = _mm_shuffle_epi8(values128, _mm_and_si128(_mm_srli_epi16(q4bits_23, 4), m4b));
|
|
1085
|
+
|
|
1086
|
+
const __m128i q4_0 = _mm_unpacklo_epi64(q4_01_lo, q4_01_hi);
|
|
1087
|
+
const __m128i q4_1 = _mm_unpackhi_epi64(q4_01_lo, q4_01_hi);
|
|
1088
|
+
const __m128i q4_2 = _mm_unpacklo_epi64(q4_23_lo, q4_23_hi);
|
|
1089
|
+
const __m128i q4_3 = _mm_unpackhi_epi64(q4_23_lo, q4_23_hi);
|
|
1090
|
+
|
|
1091
|
+
const __m128i p0_i32 = mul_sum_i8_pairs(q4_0, q8_0);
|
|
1092
|
+
const __m128i p1_i32 = mul_sum_i8_pairs(q4_1, q8_1);
|
|
1093
|
+
const __m128i p2_i32 = mul_sum_i8_pairs(q4_2, q8_2);
|
|
1094
|
+
const __m128i p3_i32 = mul_sum_i8_pairs(q4_3, q8_3);
|
|
1095
|
+
|
|
1096
|
+
const __m128 p0 = _mm_cvtepi32_ps(p0_i32);
|
|
1097
|
+
const __m128 p1 = _mm_cvtepi32_ps(p1_i32);
|
|
1098
|
+
const __m128 p2 = _mm_cvtepi32_ps(p2_i32);
|
|
1099
|
+
const __m128 p3 = _mm_cvtepi32_ps(p3_i32);
|
|
1100
|
+
|
|
1101
|
+
const __m256 p01 = _mm256_set_m128(p1, p0);
|
|
1102
|
+
const __m256 p23 = _mm256_set_m128(p3, p2);
|
|
1103
|
+
|
|
1104
|
+
const float dy0 = GGML_CPU_FP16_TO_FP32(y[2*ib].d);
|
|
1105
|
+
const float dy1 = GGML_CPU_FP16_TO_FP32(y[2*ib+1].d);
|
|
1106
|
+
|
|
1107
|
+
const float s0 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[0]) * dy0;
|
|
1108
|
+
const float s1 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[1]) * dy0;
|
|
1109
|
+
const float s2 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[2]) * dy1;
|
|
1110
|
+
const float s3 = GGML_CPU_UE4M3_TO_FP32(x[ib].d[3]) * dy1;
|
|
1111
|
+
|
|
1112
|
+
const __m256 scales01 = _mm256_set_m128(_mm_set1_ps(s1), _mm_set1_ps(s0));
|
|
1113
|
+
const __m256 scales23 = _mm256_set_m128(_mm_set1_ps(s3), _mm_set1_ps(s2));
|
|
1114
|
+
|
|
1115
|
+
accum = _mm256_add_ps(accum, _mm256_mul_ps(p01, scales01));
|
|
1116
|
+
accum = _mm256_add_ps(accum, _mm256_mul_ps(p23, scales23));
|
|
1117
|
+
}
|
|
1118
|
+
sumf = hsum_float_8(accum);
|
|
1119
|
+
|
|
1120
|
+
#endif
|
|
1121
|
+
|
|
1122
|
+
for (;ib < nb; ++ib) {
|
|
1123
|
+
for (int s_idx = 0; s_idx < 4; ++s_idx) {
|
|
1124
|
+
const float d = GGML_CPU_UE4M3_TO_FP32(x[ib].d[s_idx]);
|
|
1125
|
+
const int q8_block = s_idx / 2;
|
|
1126
|
+
const int q8_off = (s_idx % 2) * QK_NVFP4_SUB;
|
|
1127
|
+
const float dy = GGML_CPU_FP16_TO_FP32(y[2*ib + q8_block].d);
|
|
1128
|
+
|
|
1129
|
+
int sumi_lo = 0, sumi_hi = 0;
|
|
1130
|
+
for (int j = 0; j < QK_NVFP4_SUB/2; ++j) {
|
|
1131
|
+
const uint8_t qv = x[ib].qs[s_idx*(QK_NVFP4_SUB/2) + j];
|
|
1132
|
+
sumi_lo += y[2*ib + q8_block].qs[q8_off + j + 0] * kvalues_fp4[qv & 0xf];
|
|
1133
|
+
sumi_hi += y[2*ib + q8_block].qs[q8_off + j + QK_NVFP4_SUB/2] * kvalues_fp4[qv >> 4];
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
sumf += dy * d * (sumi_lo + sumi_hi);
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
*s = sumf;
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1004
1142
|
void ggml_vec_dot_q5_0_q8_0(int n, float * GGML_RESTRICT s, size_t bs, const void * GGML_RESTRICT vx, size_t bx, const void * GGML_RESTRICT vy, size_t by, int nrc) {
|
|
1005
1143
|
const int qk = QK8_0;
|
|
1006
1144
|
const int nb = n / qk;
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#define ggml_vec_dot_mxfp4_q8_0_generic ggml_vec_dot_mxfp4_q8_0
|
|
18
18
|
#define ggml_vec_dot_nvfp4_q8_0_generic ggml_vec_dot_nvfp4_q8_0
|
|
19
19
|
#define ggml_vec_dot_q1_0_q8_0_generic ggml_vec_dot_q1_0_q8_0
|
|
20
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
20
21
|
#define ggml_vec_dot_tq1_0_q8_K_generic ggml_vec_dot_tq1_0_q8_K
|
|
21
22
|
#define ggml_vec_dot_tq2_0_q8_K_generic ggml_vec_dot_tq2_0_q8_K
|
|
22
23
|
#define ggml_vec_dot_q2_K_q8_K_generic ggml_vec_dot_q2_K_q8_K
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
#define ggml_gemm_q2_K_8x8_q8_K_generic ggml_gemm_q2_K_8x8_q8_K
|
|
83
84
|
#elif defined(__x86_64__) || defined(__i386__) || defined(_M_IX86) || defined(_M_X64)
|
|
84
85
|
// quants.c
|
|
85
|
-
#define
|
|
86
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
86
87
|
// repack.cpp
|
|
87
88
|
#define ggml_quantize_mat_q8_0_4x4_generic ggml_quantize_mat_q8_0_4x4
|
|
88
89
|
#define ggml_quantize_mat_q8_K_4x4_generic ggml_quantize_mat_q8_K_4x4
|
|
@@ -114,6 +115,7 @@
|
|
|
114
115
|
#define quantize_row_q8_K_generic quantize_row_q8_K
|
|
115
116
|
#define ggml_vec_dot_nvfp4_q8_0_generic ggml_vec_dot_nvfp4_q8_0
|
|
116
117
|
#define ggml_vec_dot_q1_0_q8_0_generic ggml_vec_dot_q1_0_q8_0
|
|
118
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
117
119
|
#define ggml_vec_dot_tq1_0_q8_K_generic ggml_vec_dot_tq1_0_q8_K
|
|
118
120
|
#define ggml_vec_dot_tq2_0_q8_K_generic ggml_vec_dot_tq2_0_q8_K
|
|
119
121
|
#define ggml_vec_dot_iq1_m_q8_K_generic ggml_vec_dot_iq1_m_q8_K
|
|
@@ -163,6 +165,7 @@
|
|
|
163
165
|
#define ggml_vec_dot_mxfp4_q8_0_generic ggml_vec_dot_mxfp4_q8_0
|
|
164
166
|
#define ggml_vec_dot_nvfp4_q8_0_generic ggml_vec_dot_nvfp4_q8_0
|
|
165
167
|
#define ggml_vec_dot_q1_0_q8_0_generic ggml_vec_dot_q1_0_q8_0
|
|
168
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
166
169
|
// repack.cpp
|
|
167
170
|
#define ggml_quantize_mat_q8_0_4x4_generic ggml_quantize_mat_q8_0_4x4
|
|
168
171
|
#define ggml_quantize_mat_q8_0_4x8_generic ggml_quantize_mat_q8_0_4x8
|
|
@@ -203,6 +206,7 @@
|
|
|
203
206
|
#elif defined(__riscv)
|
|
204
207
|
// quants.c
|
|
205
208
|
#define ggml_vec_dot_nvfp4_q8_0_generic ggml_vec_dot_nvfp4_q8_0
|
|
209
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
206
210
|
// repack.cpp
|
|
207
211
|
#define ggml_quantize_mat_q8_0_4x1_generic ggml_quantize_mat_q8_0_4x1
|
|
208
212
|
#define ggml_quantize_mat_q8_0_4x4_generic ggml_quantize_mat_q8_0_4x4
|
|
@@ -244,6 +248,7 @@
|
|
|
244
248
|
#define quantize_row_q8_K_generic quantize_row_q8_K
|
|
245
249
|
#define ggml_vec_dot_nvfp4_q8_0_generic ggml_vec_dot_nvfp4_q8_0
|
|
246
250
|
#define ggml_vec_dot_q1_0_q8_0_generic ggml_vec_dot_q1_0_q8_0
|
|
251
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
247
252
|
#define ggml_vec_dot_tq1_0_q8_K_generic ggml_vec_dot_tq1_0_q8_K
|
|
248
253
|
#define ggml_vec_dot_tq2_0_q8_K_generic ggml_vec_dot_tq2_0_q8_K
|
|
249
254
|
#define ggml_vec_dot_q2_K_q8_K_generic ggml_vec_dot_q2_K_q8_K
|
|
@@ -293,7 +298,6 @@
|
|
|
293
298
|
#define ggml_gemm_q8_0_4x8_q8_0_generic ggml_gemm_q8_0_4x8_q8_0
|
|
294
299
|
#elif defined(__wasm__)
|
|
295
300
|
// quants.c
|
|
296
|
-
#define ggml_vec_dot_q4_1_q8_1_generic ggml_vec_dot_q4_1_q8_1
|
|
297
301
|
#define ggml_vec_dot_tq1_0_q8_K_generic ggml_vec_dot_tq1_0_q8_K
|
|
298
302
|
#define ggml_vec_dot_tq2_0_q8_K_generic ggml_vec_dot_tq2_0_q8_K
|
|
299
303
|
#define ggml_vec_dot_iq2_xxs_q8_K_generic ggml_vec_dot_iq2_xxs_q8_K
|
|
@@ -308,6 +312,7 @@
|
|
|
308
312
|
#define ggml_vec_dot_mxfp4_q8_0_generic ggml_vec_dot_mxfp4_q8_0
|
|
309
313
|
#define ggml_vec_dot_nvfp4_q8_0_generic ggml_vec_dot_nvfp4_q8_0
|
|
310
314
|
#define ggml_vec_dot_q1_0_q8_0_generic ggml_vec_dot_q1_0_q8_0
|
|
315
|
+
#define ggml_vec_dot_q2_0_q8_0_generic ggml_vec_dot_q2_0_q8_0
|
|
311
316
|
// repack.cpp
|
|
312
317
|
#define ggml_quantize_mat_q8_0_4x4_generic ggml_quantize_mat_q8_0_4x4
|
|
313
318
|
#define ggml_quantize_mat_q8_0_4x8_generic ggml_quantize_mat_q8_0_4x8
|
|
@@ -82,6 +82,9 @@ float ggml_table_f32_f16[1 << 16];
|
|
|
82
82
|
// precomputed f32 table for e8m0 half (1 KB) (simd-mappings.h)
|
|
83
83
|
float ggml_table_f32_e8m0_half[1 << 8];
|
|
84
84
|
|
|
85
|
+
// precomputed f32 table for ue4m3 (1 KB) (simd-mappings.h)
|
|
86
|
+
float ggml_table_f32_ue4m3[1 << 8];
|
|
87
|
+
|
|
85
88
|
#if defined(__ARM_ARCH)
|
|
86
89
|
struct ggml_arm_arch_features_type {
|
|
87
90
|
int sve_cnt;
|
|
@@ -227,6 +230,12 @@ static const struct ggml_type_traits_cpu type_traits_cpu[GGML_TYPE_COUNT] = {
|
|
|
227
230
|
.vec_dot_type = GGML_TYPE_Q8_0,
|
|
228
231
|
.nrows = 1,
|
|
229
232
|
},
|
|
233
|
+
[GGML_TYPE_Q2_0] = {
|
|
234
|
+
.from_float = quantize_row_q2_0,
|
|
235
|
+
.vec_dot = ggml_vec_dot_q2_0_q8_0,
|
|
236
|
+
.vec_dot_type = GGML_TYPE_Q8_0,
|
|
237
|
+
.nrows = 1,
|
|
238
|
+
},
|
|
230
239
|
[GGML_TYPE_Q4_0] = {
|
|
231
240
|
.from_float = quantize_row_q4_0,
|
|
232
241
|
.vec_dot = ggml_vec_dot_q4_0_q8_0,
|
|
@@ -3798,6 +3807,11 @@ void ggml_cpu_init(void) {
|
|
|
3798
3807
|
ggml_table_f32_e8m0_half[i] = GGML_E8M0_TO_FP32_HALF(i);
|
|
3799
3808
|
}
|
|
3800
3809
|
|
|
3810
|
+
// initialize UE4M3 table (256 entries)
|
|
3811
|
+
for (int i = 0; i < (1 << 8); ++i) {
|
|
3812
|
+
ggml_table_f32_ue4m3[i] = ggml_ue4m3_to_fp32(i);
|
|
3813
|
+
}
|
|
3814
|
+
|
|
3801
3815
|
const uint64_t t_end = ggml_time_us(); UNUSED(t_end);
|
|
3802
3816
|
|
|
3803
3817
|
GGML_PRINT_DEBUG("%s: GELU, Quick GELU, SILU and EXP tables initialized in %f ms\n", __func__, (t_end - t_start)/1000.0);
|
|
@@ -2321,31 +2321,35 @@ class tinyBLAS_Q0_PPC {
|
|
|
2321
2321
|
}
|
|
2322
2322
|
|
|
2323
2323
|
void matmul(int64_t m, int64_t n) {
|
|
2324
|
-
|
|
2325
|
-
mnpack(0, m, 0, n);
|
|
2326
|
-
#else
|
|
2327
|
-
const int64_t mc = 64;
|
|
2328
|
-
const int64_t kc = 64;
|
|
2324
|
+
int64_t mc = 64;
|
|
2329
2325
|
int64_t nc = 64;
|
|
2326
|
+
int64_t kc = 64;
|
|
2327
|
+
int64_t n_chunk = 64;
|
|
2328
|
+
#if defined(_AIX) || defined(__BIG_ENDIAN__)
|
|
2329
|
+
mc = 32;
|
|
2330
|
+
nc = 32;
|
|
2331
|
+
kc = 32;
|
|
2332
|
+
n_chunk = 32
|
|
2333
|
+
#endif
|
|
2330
2334
|
int64_t n_aligned = 0;
|
|
2331
|
-
if (n %
|
|
2335
|
+
if (n % n_chunk == 0) {
|
|
2332
2336
|
n_aligned = n;
|
|
2333
2337
|
} else if (n == 4) {
|
|
2334
2338
|
n_aligned = 4;
|
|
2335
|
-
} else if (n <
|
|
2339
|
+
} else if (n < n_chunk) {
|
|
2336
2340
|
n_aligned = (n / 8) * 8;
|
|
2337
2341
|
} else {
|
|
2338
|
-
n_aligned = (n /
|
|
2342
|
+
n_aligned = (n / n_chunk) * n_chunk;
|
|
2339
2343
|
}
|
|
2340
2344
|
if (n_aligned > 0) {
|
|
2341
|
-
if (n_aligned %
|
|
2345
|
+
if (n_aligned % n_chunk == 0) nc = n_chunk;
|
|
2342
2346
|
else if (n_aligned == n) nc = n;
|
|
2343
2347
|
else if (n_aligned % 32 == 0) nc = 32;
|
|
2344
2348
|
else if (n_aligned % 24 == 0) nc = 24;
|
|
2345
2349
|
else if (n_aligned % 16 == 0) nc = 16;
|
|
2346
2350
|
else nc = 8;
|
|
2347
2351
|
}
|
|
2348
|
-
bool can_use_tiled = n_aligned > 0 && (m % mc == 0)
|
|
2352
|
+
bool can_use_tiled = n_aligned > 0 && (m % mc == 0);
|
|
2349
2353
|
if (can_use_tiled) {
|
|
2350
2354
|
matmul_tiled(m, n_aligned, mc, nc, kc);
|
|
2351
2355
|
if (n > n_aligned) {
|
|
@@ -2354,7 +2358,6 @@ class tinyBLAS_Q0_PPC {
|
|
|
2354
2358
|
} else {
|
|
2355
2359
|
mnpack(0, m, 0, n);
|
|
2356
2360
|
}
|
|
2357
|
-
#endif
|
|
2358
2361
|
}
|
|
2359
2362
|
|
|
2360
2363
|
private:
|
|
@@ -3063,13 +3066,14 @@ class tinyBLAS_Q0_PPC {
|
|
|
3063
3066
|
int64_t ii = (job / xtiles) * mc;
|
|
3064
3067
|
int64_t jj = (job % xtiles) * nc;
|
|
3065
3068
|
for (int64_t kk = 0; kk < k; kk += kc) {
|
|
3069
|
+
int64_t k_cur = MIN(kc, k - kk);
|
|
3066
3070
|
if constexpr(is_Ablock_q4) {
|
|
3067
|
-
packNormal_q4_fp16(A + ii * lda + kk, lda, mc,
|
|
3071
|
+
packNormal_q4_fp16(A + ii * lda + kk, lda, mc, k_cur, (uint8_t *)A_pack);
|
|
3068
3072
|
} else {
|
|
3069
|
-
packNormal_q8_fp16(A + ii * lda + kk, lda, mc,
|
|
3073
|
+
packNormal_q8_fp16(A + ii * lda + kk, lda, mc, k_cur, (uint8_t *)A_pack);
|
|
3070
3074
|
}
|
|
3071
|
-
packNormal_q8_fp16(B + jj * ldb + kk, ldb, nc,
|
|
3072
|
-
KERNEL_Q0(ii, jj, mc, nc,
|
|
3075
|
+
packNormal_q8_fp16(B + jj * ldb + kk, ldb, nc, k_cur, (uint8_t *)B_pack);
|
|
3076
|
+
KERNEL_Q0(ii, jj, mc, nc, k_cur, kk, A_pack, B_pack);
|
|
3073
3077
|
}
|
|
3074
3078
|
}
|
|
3075
3079
|
}
|
|
@@ -3194,16 +3198,19 @@ class tinyBLAS_PPC {
|
|
|
3194
3198
|
}
|
|
3195
3199
|
|
|
3196
3200
|
void matmul(int64_t m, int64_t n) {
|
|
3201
|
+
int64_t mc = 256;
|
|
3202
|
+
int64_t nc = 256;
|
|
3203
|
+
int64_t kc = 256;
|
|
3197
3204
|
#if defined(_AIX) || defined(__BIG_ENDIAN__)
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3205
|
+
mc = 128;
|
|
3206
|
+
nc = 128;
|
|
3207
|
+
kc = 128;
|
|
3208
|
+
#endif
|
|
3201
3209
|
if (m % mc == 0 && n % nc == 0 && k % kc == 0) {
|
|
3202
3210
|
matmul_tiled(m, n, mc, nc, kc);
|
|
3203
3211
|
} else {
|
|
3204
3212
|
mnpack(0, m, 0, n);
|
|
3205
3213
|
}
|
|
3206
|
-
#endif
|
|
3207
3214
|
}
|
|
3208
3215
|
|
|
3209
3216
|
private:
|