whispercpp 1.3.1 → 1.3.3
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/.gitignore +7 -3
- data/README.md +161 -43
- data/Rakefile +45 -13
- data/ext/.gitignore +4 -8
- data/ext/dependencies.rb +73 -0
- data/ext/extconf.rb +21 -198
- data/ext/options.rb +85 -0
- data/ext/ruby_whisper.c +177 -0
- data/ext/ruby_whisper.h +17 -2
- data/ext/ruby_whisper_context.c +672 -0
- data/ext/ruby_whisper_error.c +52 -0
- data/ext/ruby_whisper_model.c +232 -0
- data/ext/ruby_whisper_params.c +1303 -0
- data/ext/ruby_whisper_segment.c +220 -0
- data/ext/ruby_whisper_transcribe.cpp +93 -0
- data/ext/ruby_whisper_vad_params.c +288 -0
- data/ext/sources/CMakeGraphVizOptions.cmake +8 -0
- data/ext/sources/CMakeLists.txt +255 -0
- data/ext/sources/bindings/javascript/CMakeLists.txt +41 -0
- data/ext/sources/bindings/javascript/emscripten.cpp +93 -0
- data/ext/sources/bindings/javascript/libwhisper.worker.js +1 -0
- data/ext/sources/bindings/javascript/package-tmpl.json +26 -0
- data/ext/sources/bindings/javascript/package.json +26 -0
- data/ext/sources/bindings/javascript/whisper.js +19 -0
- data/ext/sources/build-xcframework.sh +547 -0
- data/ext/sources/cmake/DefaultTargetOptions.cmake +16 -0
- data/ext/sources/cmake/FindFFmpeg.cmake +163 -0
- data/ext/sources/cmake/build-info.cmake +60 -0
- data/ext/sources/cmake/git-vars.cmake +22 -0
- data/ext/sources/cmake/whisper-config.cmake.in +65 -0
- data/ext/sources/cmake/whisper.pc.in +10 -0
- data/ext/sources/examples/CMakeLists.txt +124 -0
- data/ext/sources/examples/addon.node/CMakeLists.txt +31 -0
- data/ext/sources/examples/addon.node/__test__/whisper.spec.js +133 -0
- data/ext/sources/examples/addon.node/addon.cpp +557 -0
- data/ext/sources/examples/addon.node/index.js +57 -0
- data/ext/sources/examples/addon.node/package.json +16 -0
- data/ext/sources/examples/addon.node/vad-example.js +132 -0
- data/ext/sources/examples/bench/CMakeLists.txt +8 -0
- data/ext/sources/examples/bench/bench.cpp +176 -0
- data/ext/sources/examples/bench.wasm/CMakeLists.txt +49 -0
- data/ext/sources/examples/bench.wasm/emscripten.cpp +87 -0
- data/ext/sources/examples/bench.wasm/index-tmpl.html +284 -0
- data/ext/sources/examples/cli/CMakeLists.txt +8 -0
- data/ext/sources/examples/cli/cli.cpp +1295 -0
- data/ext/sources/examples/coi-serviceworker.js +146 -0
- data/ext/sources/examples/command/CMakeLists.txt +10 -0
- data/ext/sources/examples/command/command.cpp +800 -0
- data/ext/sources/examples/command/commands.txt +9 -0
- data/ext/sources/examples/command.wasm/CMakeLists.txt +50 -0
- data/ext/sources/examples/command.wasm/emscripten.cpp +327 -0
- data/ext/sources/examples/command.wasm/index-tmpl.html +414 -0
- data/ext/sources/examples/common-ggml.cpp +238 -0
- data/ext/sources/examples/common-ggml.h +18 -0
- data/ext/sources/examples/common-sdl.cpp +227 -0
- data/ext/sources/examples/common-sdl.h +49 -0
- data/ext/sources/examples/common-whisper.cpp +175 -0
- data/ext/sources/examples/common-whisper.h +24 -0
- data/ext/sources/examples/common.cpp +675 -0
- data/ext/sources/examples/common.h +322 -0
- data/ext/sources/examples/deprecation-warning/CMakeLists.txt +6 -0
- data/ext/sources/examples/deprecation-warning/deprecation-warning.cpp +38 -0
- data/ext/sources/examples/ffmpeg-transcode.cpp +368 -0
- data/ext/sources/examples/generate-karaoke.sh +57 -0
- data/ext/sources/examples/grammar-parser.cpp +423 -0
- data/ext/sources/examples/grammar-parser.h +29 -0
- data/ext/sources/examples/helpers.js +191 -0
- data/ext/sources/examples/json.hpp +24596 -0
- data/ext/sources/examples/livestream.sh +112 -0
- data/ext/sources/examples/lsp/CMakeLists.txt +9 -0
- data/ext/sources/examples/lsp/lsp.cpp +469 -0
- data/ext/sources/examples/lsp/whisper.vim +362 -0
- data/ext/sources/examples/miniaudio.h +93468 -0
- data/ext/sources/examples/python/test_whisper_processor.py +7 -0
- data/ext/sources/examples/python/whisper_processor.py +54 -0
- data/ext/sources/examples/quantize/CMakeLists.txt +6 -0
- data/ext/sources/examples/quantize/quantize.cpp +226 -0
- data/ext/sources/examples/server/CMakeLists.txt +15 -0
- data/ext/sources/examples/server/bench.js +29 -0
- data/ext/sources/examples/server/httplib.h +10497 -0
- data/ext/sources/examples/server/server.cpp +1238 -0
- data/ext/sources/examples/server.py +115 -0
- data/ext/sources/examples/stb_vorbis.c +5584 -0
- data/ext/sources/examples/stream/CMakeLists.txt +10 -0
- data/ext/sources/examples/stream/stream.cpp +435 -0
- data/ext/sources/examples/stream.wasm/CMakeLists.txt +49 -0
- data/ext/sources/examples/stream.wasm/emscripten.cpp +216 -0
- data/ext/sources/examples/stream.wasm/index-tmpl.html +414 -0
- data/ext/sources/examples/sycl/CMakeLists.txt +9 -0
- data/ext/sources/examples/sycl/build.sh +22 -0
- data/ext/sources/examples/sycl/ls-sycl-device.cpp +11 -0
- data/ext/sources/examples/sycl/run-whisper.sh +17 -0
- data/ext/sources/examples/talk-llama/CMakeLists.txt +43 -0
- data/ext/sources/examples/talk-llama/eleven-labs.py +80 -0
- data/ext/sources/examples/talk-llama/llama-adapter.cpp +388 -0
- data/ext/sources/examples/talk-llama/llama-adapter.h +76 -0
- data/ext/sources/examples/talk-llama/llama-arch.cpp +1914 -0
- data/ext/sources/examples/talk-llama/llama-arch.h +464 -0
- data/ext/sources/examples/talk-llama/llama-batch.cpp +843 -0
- data/ext/sources/examples/talk-llama/llama-batch.h +147 -0
- data/ext/sources/examples/talk-llama/llama-chat.cpp +685 -0
- data/ext/sources/examples/talk-llama/llama-chat.h +59 -0
- data/ext/sources/examples/talk-llama/llama-context.cpp +2845 -0
- data/ext/sources/examples/talk-llama/llama-context.h +297 -0
- data/ext/sources/examples/talk-llama/llama-cparams.cpp +5 -0
- data/ext/sources/examples/talk-llama/llama-cparams.h +41 -0
- data/ext/sources/examples/talk-llama/llama-grammar.cpp +1229 -0
- data/ext/sources/examples/talk-llama/llama-grammar.h +173 -0
- data/ext/sources/examples/talk-llama/llama-graph.cpp +1693 -0
- data/ext/sources/examples/talk-llama/llama-graph.h +710 -0
- data/ext/sources/examples/talk-llama/llama-hparams.cpp +103 -0
- data/ext/sources/examples/talk-llama/llama-hparams.h +207 -0
- data/ext/sources/examples/talk-llama/llama-impl.cpp +167 -0
- data/ext/sources/examples/talk-llama/llama-impl.h +61 -0
- data/ext/sources/examples/talk-llama/llama-io.cpp +15 -0
- data/ext/sources/examples/talk-llama/llama-io.h +35 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified-iswa.cpp +279 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified-iswa.h +128 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified.cpp +1841 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache-unified.h +303 -0
- data/ext/sources/examples/talk-llama/llama-kv-cache.h +44 -0
- data/ext/sources/examples/talk-llama/llama-kv-cells.h +439 -0
- data/ext/sources/examples/talk-llama/llama-memory-hybrid.cpp +246 -0
- data/ext/sources/examples/talk-llama/llama-memory-hybrid.h +138 -0
- data/ext/sources/examples/talk-llama/llama-memory-recurrent.cpp +1125 -0
- data/ext/sources/examples/talk-llama/llama-memory-recurrent.h +183 -0
- data/ext/sources/examples/talk-llama/llama-memory.cpp +59 -0
- data/ext/sources/examples/talk-llama/llama-memory.h +116 -0
- data/ext/sources/examples/talk-llama/llama-mmap.cpp +600 -0
- data/ext/sources/examples/talk-llama/llama-mmap.h +68 -0
- data/ext/sources/examples/talk-llama/llama-model-loader.cpp +1163 -0
- data/ext/sources/examples/talk-llama/llama-model-loader.h +169 -0
- data/ext/sources/examples/talk-llama/llama-model-saver.cpp +282 -0
- data/ext/sources/examples/talk-llama/llama-model-saver.h +37 -0
- data/ext/sources/examples/talk-llama/llama-model.cpp +15114 -0
- data/ext/sources/examples/talk-llama/llama-model.h +452 -0
- data/ext/sources/examples/talk-llama/llama-quant.cpp +1049 -0
- data/ext/sources/examples/talk-llama/llama-quant.h +1 -0
- data/ext/sources/examples/talk-llama/llama-sampling.cpp +2575 -0
- data/ext/sources/examples/talk-llama/llama-sampling.h +32 -0
- data/ext/sources/examples/talk-llama/llama-vocab.cpp +3377 -0
- data/ext/sources/examples/talk-llama/llama-vocab.h +132 -0
- data/ext/sources/examples/talk-llama/llama.cpp +358 -0
- data/ext/sources/examples/talk-llama/llama.h +1484 -0
- data/ext/sources/examples/talk-llama/prompts/talk-alpaca.txt +23 -0
- data/ext/sources/examples/talk-llama/speak +40 -0
- data/ext/sources/examples/talk-llama/speak.bat +1 -0
- data/ext/sources/examples/talk-llama/speak.ps1 +14 -0
- data/ext/sources/examples/talk-llama/talk-llama.cpp +810 -0
- data/ext/sources/examples/talk-llama/unicode-data.cpp +7034 -0
- data/ext/sources/examples/talk-llama/unicode-data.h +20 -0
- data/ext/sources/examples/talk-llama/unicode.cpp +854 -0
- data/ext/sources/examples/talk-llama/unicode.h +66 -0
- data/ext/sources/examples/vad-speech-segments/CMakeLists.txt +8 -0
- data/ext/sources/examples/vad-speech-segments/speech.cpp +149 -0
- data/ext/sources/examples/wchess/CMakeLists.txt +10 -0
- data/ext/sources/examples/wchess/libwchess/CMakeLists.txt +19 -0
- data/ext/sources/examples/wchess/libwchess/Chessboard.cpp +803 -0
- data/ext/sources/examples/wchess/libwchess/Chessboard.h +33 -0
- data/ext/sources/examples/wchess/libwchess/WChess.cpp +193 -0
- data/ext/sources/examples/wchess/libwchess/WChess.h +63 -0
- data/ext/sources/examples/wchess/libwchess/test-chessboard.cpp +117 -0
- data/ext/sources/examples/wchess/wchess.cmd/CMakeLists.txt +8 -0
- data/ext/sources/examples/wchess/wchess.cmd/wchess.cmd.cpp +251 -0
- data/ext/sources/examples/whisper.wasm/CMakeLists.txt +50 -0
- data/ext/sources/examples/whisper.wasm/emscripten.cpp +118 -0
- data/ext/sources/examples/whisper.wasm/index-tmpl.html +658 -0
- data/ext/sources/ggml/CMakeLists.txt +435 -0
- data/ext/sources/ggml/cmake/BuildTypes.cmake +54 -0
- data/ext/sources/ggml/cmake/GitVars.cmake +22 -0
- data/ext/sources/ggml/cmake/common.cmake +50 -0
- data/ext/sources/ggml/cmake/ggml-config.cmake.in +152 -0
- data/ext/{ggml → sources/ggml}/include/ggml-alloc.h +1 -1
- data/ext/{ggml → sources/ggml}/include/ggml-backend.h +10 -8
- data/ext/{ggml → sources/ggml}/include/ggml-cpp.h +2 -1
- data/ext/{ggml → sources/ggml}/include/ggml-cpu.h +11 -1
- data/ext/{ggml → sources/ggml}/include/ggml-metal.h +1 -1
- data/ext/{ggml → sources/ggml}/include/ggml-opt.h +49 -28
- data/ext/{ggml → sources/ggml}/include/ggml-rpc.h +6 -1
- data/ext/{ggml → sources/ggml}/include/ggml-vulkan.h +0 -2
- data/ext/{ggml → sources/ggml}/include/ggml.h +325 -269
- data/ext/sources/ggml/include/gguf.h +202 -0
- data/ext/sources/ggml/src/CMakeLists.txt +404 -0
- data/ext/{ggml → sources/ggml}/src/ggml-alloc.c +34 -29
- data/ext/sources/ggml/src/ggml-amx/CMakeLists.txt +107 -0
- data/ext/{ggml → sources/ggml}/src/ggml-backend-impl.h +1 -2
- data/ext/{ggml → sources/ggml}/src/ggml-backend-reg.cpp +92 -53
- data/ext/{ggml → sources/ggml}/src/ggml-backend.cpp +69 -34
- data/ext/sources/ggml/src/ggml-blas/CMakeLists.txt +87 -0
- data/ext/sources/ggml/src/ggml-cann/CMakeLists.txt +75 -0
- data/ext/sources/ggml/src/ggml-cann/Doxyfile +2579 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cann/acl_tensor.cpp +10 -4
- data/ext/{ggml → sources/ggml}/src/ggml-cann/acl_tensor.h +5 -5
- data/ext/{ggml → sources/ggml}/src/ggml-cann/aclnn_ops.cpp +1272 -1506
- data/ext/sources/ggml/src/ggml-cann/aclnn_ops.h +1125 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cann/common.h +140 -1
- data/ext/{ggml → sources/ggml}/src/ggml-cann/ggml-cann.cpp +588 -146
- data/ext/sources/ggml/src/ggml-cann/kernels/CMakeLists.txt +30 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/dup.cpp +3 -5
- data/ext/{ggml → sources/ggml}/src/ggml-common.h +16 -8
- data/ext/sources/ggml/src/ggml-cpu/CMakeLists.txt +597 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cpu/amx/amx.cpp +3 -2
- data/ext/{ggml → sources/ggml}/src/ggml-cpu/amx/mmq.cpp +11 -10
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/cpu-feats.cpp +94 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/quants.c +4114 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/arm/repack.cpp +2163 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/loongarch/quants.c +2639 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/powerpc/quants.c +2732 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/riscv/quants.c +2069 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/riscv/repack.cpp +397 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/s390/quants.c +1300 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/wasm/quants.c +1481 -0
- data/ext/{ggml/src/ggml-cpu/cpu-feats-x86.cpp → sources/ggml/src/ggml-cpu/arch/x86/cpu-feats.cpp} +5 -1
- data/ext/sources/ggml/src/ggml-cpu/arch/x86/quants.c +4311 -0
- data/ext/sources/ggml/src/ggml-cpu/arch/x86/repack.cpp +3285 -0
- data/ext/sources/ggml/src/ggml-cpu/arch-fallback.h +184 -0
- data/ext/sources/ggml/src/ggml-cpu/binary-ops.cpp +158 -0
- data/ext/sources/ggml/src/ggml-cpu/binary-ops.h +16 -0
- data/ext/sources/ggml/src/ggml-cpu/cmake/FindSIMD.cmake +100 -0
- data/ext/sources/ggml/src/ggml-cpu/common.h +73 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cpu/ggml-cpu-impl.h +172 -41
- data/ext/sources/ggml/src/ggml-cpu/ggml-cpu.c +3551 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cpu/ggml-cpu.cpp +78 -25
- data/ext/{ggml/src/ggml-cpu/ggml-cpu-hbm.cpp → sources/ggml/src/ggml-cpu/hbm.cpp} +1 -1
- data/ext/sources/ggml/src/ggml-cpu/kleidiai/kernels.cpp +337 -0
- data/ext/sources/ggml/src/ggml-cpu/kleidiai/kernels.h +95 -0
- data/ext/sources/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +482 -0
- data/ext/sources/ggml/src/ggml-cpu/kleidiai/kleidiai.h +17 -0
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.cpp +3594 -0
- data/ext/sources/ggml/src/ggml-cpu/llamafile/sgemm.h +19 -0
- data/ext/sources/ggml/src/ggml-cpu/ops.cpp +9786 -0
- data/ext/sources/ggml/src/ggml-cpu/ops.h +118 -0
- data/ext/sources/ggml/src/ggml-cpu/quants.c +1158 -0
- data/ext/{ggml/src/ggml-cpu/ggml-cpu-quants.h → sources/ggml/src/ggml-cpu/quants.h} +26 -0
- data/ext/sources/ggml/src/ggml-cpu/repack.cpp +1571 -0
- data/ext/sources/ggml/src/ggml-cpu/repack.h +98 -0
- data/ext/sources/ggml/src/ggml-cpu/simd-mappings.h +1184 -0
- data/ext/{ggml/src/ggml-cpu/ggml-cpu-traits.cpp → sources/ggml/src/ggml-cpu/traits.cpp} +1 -1
- data/ext/sources/ggml/src/ggml-cpu/unary-ops.cpp +186 -0
- data/ext/sources/ggml/src/ggml-cpu/unary-ops.h +28 -0
- data/ext/sources/ggml/src/ggml-cpu/vec.cpp +345 -0
- data/ext/sources/ggml/src/ggml-cpu/vec.h +1027 -0
- data/ext/sources/ggml/src/ggml-cuda/CMakeLists.txt +184 -0
- data/ext/sources/ggml/src/ggml-cuda/acc.cu +61 -0
- data/ext/sources/ggml/src/ggml-cuda/acc.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/arange.cu +34 -0
- data/ext/sources/ggml/src/ggml-cuda/arange.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/argmax.cu +91 -0
- data/ext/sources/ggml/src/ggml-cuda/argmax.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/argsort.cu +104 -0
- data/ext/sources/ggml/src/ggml-cuda/argsort.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/binbcast.cu +363 -0
- data/ext/sources/ggml/src/ggml-cuda/binbcast.cuh +9 -0
- data/ext/sources/ggml/src/ggml-cuda/clamp.cu +45 -0
- data/ext/sources/ggml/src/ggml-cuda/clamp.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/common.cuh +851 -0
- data/ext/sources/ggml/src/ggml-cuda/concat.cu +221 -0
- data/ext/sources/ggml/src/ggml-cuda/concat.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cu +89 -0
- data/ext/sources/ggml/src/ggml-cuda/conv-transpose-1d.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-transpose.cu +91 -0
- data/ext/sources/ggml/src/ggml-cuda/conv2d-transpose.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/convert.cu +752 -0
- data/ext/sources/ggml/src/ggml-cuda/convert.cuh +31 -0
- data/ext/sources/ggml/src/ggml-cuda/count-equal.cu +64 -0
- data/ext/sources/ggml/src/ggml-cuda/count-equal.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/cp-async.cuh +57 -0
- data/ext/sources/ggml/src/ggml-cuda/cpy.cu +705 -0
- data/ext/sources/ggml/src/ggml-cuda/cpy.cuh +11 -0
- data/ext/sources/ggml/src/ggml-cuda/cross-entropy-loss.cu +189 -0
- data/ext/sources/ggml/src/ggml-cuda/cross-entropy-loss.cuh +7 -0
- data/ext/sources/ggml/src/ggml-cuda/dequantize.cuh +103 -0
- data/ext/sources/ggml/src/ggml-cuda/diagmask.cu +40 -0
- data/ext/sources/ggml/src/ggml-cuda/diagmask.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-common.cuh +881 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-mma-f16.cuh +1474 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile-f16.cu +357 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile-f16.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile-f32.cu +365 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-tile-f32.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-vec-f16.cuh +482 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-vec-f32.cuh +472 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-wmma-f16.cu +638 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn-wmma-f16.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn.cu +346 -0
- data/ext/sources/ggml/src/ggml-cuda/fattn.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/getrows.cu +275 -0
- data/ext/sources/ggml/src/ggml-cuda/getrows.cuh +15 -0
- data/ext/sources/ggml/src/ggml-cuda/ggml-cuda.cu +3647 -0
- data/ext/sources/ggml/src/ggml-cuda/gla.cu +93 -0
- data/ext/sources/ggml/src/ggml-cuda/gla.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/im2col.cu +103 -0
- data/ext/sources/ggml/src/ggml-cuda/im2col.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/mean.cu +19 -0
- data/ext/sources/ggml/src/ggml-cuda/mean.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/mma.cuh +396 -0
- data/ext/sources/ggml/src/ggml-cuda/mmq.cu +324 -0
- data/ext/sources/ggml/src/ggml-cuda/mmq.cuh +3217 -0
- data/ext/sources/ggml/src/ggml-cuda/mmv.cu +506 -0
- data/ext/sources/ggml/src/ggml-cuda/mmv.cuh +11 -0
- data/ext/sources/ggml/src/ggml-cuda/mmvq.cu +595 -0
- data/ext/sources/ggml/src/ggml-cuda/mmvq.cuh +12 -0
- data/ext/sources/ggml/src/ggml-cuda/norm.cu +458 -0
- data/ext/sources/ggml/src/ggml-cuda/norm.cuh +11 -0
- data/ext/sources/ggml/src/ggml-cuda/opt-step-adamw.cu +78 -0
- data/ext/sources/ggml/src/ggml-cuda/opt-step-adamw.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/out-prod.cu +68 -0
- data/ext/sources/ggml/src/ggml-cuda/out-prod.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/pad.cu +49 -0
- data/ext/sources/ggml/src/ggml-cuda/pad.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/pool2d.cu +94 -0
- data/ext/sources/ggml/src/ggml-cuda/pool2d.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/quantize.cu +190 -0
- data/ext/sources/ggml/src/ggml-cuda/quantize.cuh +27 -0
- data/ext/sources/ggml/src/ggml-cuda/rope.cu +456 -0
- data/ext/sources/ggml/src/ggml-cuda/rope.cuh +7 -0
- data/ext/sources/ggml/src/ggml-cuda/scale.cu +31 -0
- data/ext/sources/ggml/src/ggml-cuda/scale.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/softmax.cu +283 -0
- data/ext/sources/ggml/src/ggml-cuda/softmax.cuh +7 -0
- data/ext/sources/ggml/src/ggml-cuda/ssm-conv.cu +148 -0
- data/ext/sources/ggml/src/ggml-cuda/ssm-conv.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/ssm-scan.cu +155 -0
- data/ext/sources/ggml/src/ggml-cuda/ssm-scan.cuh +3 -0
- data/ext/sources/ggml/src/ggml-cuda/sum.cu +45 -0
- data/ext/sources/ggml/src/ggml-cuda/sum.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/sumrows.cu +26 -0
- data/ext/sources/ggml/src/ggml-cuda/sumrows.cuh +4 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_1-ncols2_8.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_1.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_2.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_16-ncols2_4.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_4.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_2-ncols2_8.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_1.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_32-ncols2_2.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_2.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_4.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_4-ncols2_8.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_64-ncols2_1.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_1.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_2.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_4.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-mma-f16-instance-ncols1_8-ncols2_8.cu +10 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-f16-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_0-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q4_1-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_0-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q5_1-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs128-q8_0-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs256-f16-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f16-instance-hs64-f16-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-f16-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_0-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q4_1-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_0-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q5_1-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs128-q8_0-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs256-f16-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-f16.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/fattn-vec-f32-instance-hs64-f16-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/generate_cu_files.py +78 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq1_s.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_s.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xs.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq2_xxs.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_s.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq3_xxs.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_nl.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-iq4_xs.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q2_k.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q3_k.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q4_k.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_1.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q5_k.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q6_k.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/template-instances/mmq-instance-q8_0.cu +5 -0
- data/ext/sources/ggml/src/ggml-cuda/tsembd.cu +47 -0
- data/ext/sources/ggml/src/ggml-cuda/tsembd.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/unary.cu +378 -0
- data/ext/sources/ggml/src/ggml-cuda/unary.cuh +66 -0
- data/ext/sources/ggml/src/ggml-cuda/upscale.cu +51 -0
- data/ext/sources/ggml/src/ggml-cuda/upscale.cuh +5 -0
- data/ext/sources/ggml/src/ggml-cuda/vecdotq.cuh +1135 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cuda/vendors/cuda.h +1 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cuda/vendors/hip.h +57 -0
- data/ext/{ggml → sources/ggml}/src/ggml-cuda/vendors/musa.h +7 -1
- data/ext/sources/ggml/src/ggml-cuda/wkv.cu +199 -0
- data/ext/sources/ggml/src/ggml-cuda/wkv.cuh +7 -0
- data/ext/sources/ggml/src/ggml-hip/CMakeLists.txt +135 -0
- data/ext/{ggml → sources/ggml}/src/ggml-impl.h +147 -158
- data/ext/sources/ggml/src/ggml-kompute/CMakeLists.txt +166 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/common.comp +112 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_add.comp +58 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_addrow.comp +25 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f16_f16.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f16_f32.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f32_f16.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f32_f32.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_diagmask.comp +30 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_gelu.comp +22 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_getrows.comp +17 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_getrows_f16.comp +31 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_getrows_f32.comp +31 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q4_0.comp +38 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q4_1.comp +39 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q6_k.comp +44 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_f16.comp +69 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_mat_f32.comp +51 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_0.comp +33 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_1.comp +35 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_k.comp +140 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q6_k.comp +106 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q8_0.comp +73 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mv_q_n.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_mul_mv_q_n_pre.comp +28 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_norm.comp +84 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_relu.comp +21 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_rmsnorm.comp +53 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_rope_neox_f16.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_rope_neox_f32.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_rope_norm_f16.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_rope_norm_f32.comp +52 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_scale.comp +19 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_scale_8.comp +23 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_silu.comp +22 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/op_softmax.comp +72 -0
- data/ext/sources/ggml/src/ggml-kompute/kompute-shaders/rope_common.comp +71 -0
- data/ext/sources/ggml/src/ggml-metal/CMakeLists.txt +121 -0
- data/ext/sources/ggml/src/ggml-metal/ggml-metal-impl.h +649 -0
- data/ext/{ggml → sources/ggml}/src/ggml-metal/ggml-metal.m +2504 -1108
- data/ext/{ggml → sources/ggml}/src/ggml-metal/ggml-metal.metal +2102 -1463
- data/ext/sources/ggml/src/ggml-musa/CMakeLists.txt +113 -0
- data/ext/sources/ggml/src/ggml-musa/mudnn.cu +112 -0
- data/ext/sources/ggml/src/ggml-musa/mudnn.cuh +12 -0
- data/ext/sources/ggml/src/ggml-opencl/CMakeLists.txt +110 -0
- data/ext/sources/ggml/src/ggml-opencl/ggml-opencl.cpp +6494 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/add.cl +83 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/argsort.cl +86 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/clamp.cl +20 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/concat.cl +109 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/cpy.cl +184 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/cvt.cl +118 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/diag_mask_inf.cl +58 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/div.cl +72 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/embed_kernel.py +26 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gelu.cl +62 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle.cl +268 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/gemv_noshuffle_general.cl +274 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/get_rows.cl +163 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/glu.cl +201 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/group_norm.cl +72 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/im2col_f16.cl +57 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/im2col_f32.cl +57 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul.cl +79 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mat_Ab_Bi_8x4.cl +139 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f16.cl +118 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32.cl +118 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_1row.cl +94 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f16_f32_l4.cl +84 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_f32_f32.cl +118 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_id_q4_0_f32_8x_flat.cl +283 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32.cl +192 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_1d_16x_flat.cl +307 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_1d_8x_flat.cl +265 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_8x_flat.cl +272 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q4_0_f32_v.cl +254 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/mul_mv_q6_k.cl +190 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/norm.cl +81 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/pad.cl +30 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/relu.cl +16 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/repeat.cl +39 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/rms_norm.cl +96 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/rope.cl +721 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/scale.cl +16 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/sigmoid.cl +29 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/silu.cl +30 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/softmax_4_f16.cl +87 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/softmax_4_f32.cl +87 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/softmax_f16.cl +86 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/softmax_f32.cl +86 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/sub.cl +72 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/sum_rows.cl +39 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/tanh.cl +63 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/transpose.cl +84 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/tsembd.cl +48 -0
- data/ext/sources/ggml/src/ggml-opencl/kernels/upscale.cl +121 -0
- data/ext/{ggml → sources/ggml}/src/ggml-opt.cpp +373 -190
- data/ext/{ggml → sources/ggml}/src/ggml-quants.c +120 -128
- data/ext/sources/ggml/src/ggml-rpc/CMakeLists.txt +9 -0
- data/ext/{ggml → sources/ggml}/src/ggml-rpc/ggml-rpc.cpp +494 -84
- data/ext/sources/ggml/src/ggml-sycl/CMakeLists.txt +189 -0
- data/ext/sources/ggml/src/ggml-sycl/backend.hpp +37 -0
- data/ext/sources/ggml/src/ggml-sycl/binbcast.cpp +344 -0
- data/ext/sources/ggml/src/ggml-sycl/binbcast.hpp +39 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/common.cpp +20 -32
- data/ext/sources/ggml/src/ggml-sycl/common.hpp +561 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/concat.cpp +56 -70
- data/ext/sources/ggml/src/ggml-sycl/concat.hpp +20 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/conv.cpp +8 -12
- data/ext/sources/ggml/src/ggml-sycl/conv.hpp +20 -0
- data/ext/sources/ggml/src/ggml-sycl/convert.cpp +575 -0
- data/ext/sources/ggml/src/ggml-sycl/convert.hpp +34 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.cpp +839 -0
- data/ext/sources/ggml/src/ggml-sycl/cpy.hpp +11 -0
- data/ext/sources/ggml/src/ggml-sycl/dequantize.hpp +823 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/dmmv.cpp +188 -67
- data/ext/sources/ggml/src/ggml-sycl/dmmv.hpp +27 -0
- data/ext/sources/ggml/src/ggml-sycl/dpct/helper.hpp +2987 -0
- data/ext/sources/ggml/src/ggml-sycl/element_wise.cpp +1120 -0
- data/ext/sources/ggml/src/ggml-sycl/element_wise.hpp +84 -0
- data/ext/sources/ggml/src/ggml-sycl/gemm.hpp +102 -0
- data/ext/sources/ggml/src/ggml-sycl/getrows.cpp +212 -0
- data/ext/sources/ggml/src/ggml-sycl/getrows.hpp +20 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/ggml-sycl.cpp +1197 -1295
- data/ext/sources/ggml/src/ggml-sycl/gla.cpp +106 -0
- data/ext/sources/ggml/src/ggml-sycl/gla.hpp +8 -0
- data/ext/sources/ggml/src/ggml-sycl/im2col.cpp +136 -0
- data/ext/sources/ggml/src/ggml-sycl/im2col.hpp +21 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/mmq.cpp +60 -81
- data/ext/sources/ggml/src/ggml-sycl/mmq.hpp +33 -0
- data/ext/sources/ggml/src/ggml-sycl/mmvq.cpp +1065 -0
- data/ext/sources/ggml/src/ggml-sycl/mmvq.hpp +27 -0
- data/ext/sources/ggml/src/ggml-sycl/norm.cpp +482 -0
- data/ext/sources/ggml/src/ggml-sycl/norm.hpp +26 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/outprod.cpp +8 -17
- data/ext/sources/ggml/src/ggml-sycl/outprod.hpp +10 -0
- data/ext/sources/ggml/src/ggml-sycl/presets.hpp +74 -0
- data/ext/sources/ggml/src/ggml-sycl/quants.hpp +111 -0
- data/ext/sources/ggml/src/ggml-sycl/rope.cpp +472 -0
- data/ext/sources/ggml/src/ggml-sycl/rope.hpp +20 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/softmax.cpp +38 -28
- data/ext/sources/ggml/src/ggml-sycl/softmax.hpp +20 -0
- data/ext/sources/ggml/src/ggml-sycl/sycl_hw.cpp +15 -0
- data/ext/sources/ggml/src/ggml-sycl/sycl_hw.hpp +26 -0
- data/ext/{ggml → sources/ggml}/src/ggml-sycl/tsembd.cpp +6 -11
- data/ext/sources/ggml/src/ggml-sycl/tsembd.hpp +20 -0
- data/ext/sources/ggml/src/ggml-sycl/vecdotq.hpp +1307 -0
- data/ext/sources/ggml/src/ggml-sycl/wkv.cpp +289 -0
- data/ext/sources/ggml/src/ggml-sycl/wkv.hpp +10 -0
- data/ext/sources/ggml/src/ggml-vulkan/CMakeLists.txt +200 -0
- data/ext/sources/ggml/src/ggml-vulkan/cmake/host-toolchain.cmake.in +15 -0
- data/ext/{ggml → sources/ggml}/src/ggml-vulkan/ggml-vulkan.cpp +3822 -1335
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +31 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/acc.comp +29 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/add.comp +29 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/argmax.comp +51 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/argsort.comp +69 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/clamp.comp +17 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/concat.comp +41 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/contig_copy.comp +49 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_dw.comp +105 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/conv_transpose_1d.comp +98 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/copy.comp +23 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/copy_from_quant.comp +51 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/copy_to_quant.comp +242 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/cos.comp +17 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/count_equal.comp +31 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_f32.comp +20 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs.comp +462 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs_cm2.comp +699 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_head.comp +13 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq1_m.comp +42 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq1_s.comp +35 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_s.comp +44 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_xs.comp +43 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq2_xxs.comp +48 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq3_s.comp +39 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq3_xxs.comp +49 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq4_nl.comp +32 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_iq4_xs.comp +34 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q2_k.comp +34 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q3_k.comp +42 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_0.comp +30 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_1.comp +32 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q4_k.comp +68 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_0.comp +34 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_1.comp +35 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q5_k.comp +70 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q6_k.comp +33 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/dequant_q8_0.comp +31 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/diag_mask_inf.comp +34 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/div.comp +27 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +337 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_base.comp +162 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +360 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp +267 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_split_k_reduce.comp +59 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/geglu.comp +13 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp +25 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp +23 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_binary_head.comp +64 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_head.comp +9 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.comp +76 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows.comp +33 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/get_rows_quant.comp +41 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.comp +15 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.comp +29 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/group_norm.comp +66 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/im2col.comp +100 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/l2_norm.comp +41 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/leaky_relu.comp +22 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul.comp +27 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_split_k_reduce.comp +48 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec.comp +169 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_base.comp +118 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq1_m.comp +82 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq1_s.comp +79 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_s.comp +90 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_xs.comp +87 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq2_xxs.comp +87 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq3_s.comp +90 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_iq3_xxs.comp +88 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_nc.comp +118 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_p021.comp +154 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q2_k.comp +130 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q3_k.comp +132 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q4_k.comp +136 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q5_k.comp +167 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_q6_k.comp +130 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +868 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +441 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq.comp +442 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq_funcs.comp +99 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/norm.comp +44 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/opt_step_adamw.comp +42 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/pad.comp +28 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/pool2d.comp +74 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/quantize_q8_1.comp +77 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/reglu.comp +9 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/relu.comp +21 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat.comp +26 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp +37 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +61 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm_back.comp +55 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rope_head.comp +58 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rope_multi.comp +60 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rope_neox.comp +43 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp +43 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/rope_vision.comp +47 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/scale.comp +24 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp +20 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu.comp +22 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/silu_back.comp +26 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sin.comp +17 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp +173 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/soft_max_back.comp +50 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/square.comp +17 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sub.comp +29 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/sum_rows.comp +37 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/swiglu.comp +9 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp +20 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/test_bfloat16_support.comp +7 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/test_coopmat2_support.comp +7 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/test_coopmat_support.comp +7 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/test_integer_dot_support.comp +7 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/timestep_embedding.comp +41 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/types.comp +1373 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/upscale.comp +36 -0
- data/ext/{ggml → sources/ggml}/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +203 -36
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/wkv6.comp +87 -0
- data/ext/sources/ggml/src/ggml-vulkan/vulkan-shaders/wkv7.comp +91 -0
- data/ext/{ggml → sources/ggml}/src/ggml.c +918 -1782
- data/ext/sources/ggml/src/ggml.cpp +26 -0
- data/ext/sources/ggml/src/gguf.cpp +1351 -0
- data/ext/{include → sources/include}/whisper.h +70 -2
- data/ext/sources/src/CMakeLists.txt +145 -0
- data/ext/sources/src/coreml/whisper-compat.h +10 -0
- data/ext/sources/src/coreml/whisper-compat.m +35 -0
- data/ext/{src → sources/src}/coreml/whisper-decoder-impl.h +27 -15
- data/ext/{src → sources/src}/coreml/whisper-decoder-impl.m +36 -10
- data/ext/{src → sources/src}/coreml/whisper-encoder-impl.h +21 -9
- data/ext/{src → sources/src}/coreml/whisper-encoder-impl.m +29 -3
- data/ext/sources/src/coreml/whisper-encoder.mm +73 -0
- data/ext/sources/src/whisper-arch.h +197 -0
- data/ext/{src → sources/src}/whisper.cpp +1966 -386
- data/ext/sources/tests/CMakeLists.txt +105 -0
- data/ext/sources/tests/earnings21/eval.mk +58 -0
- data/ext/sources/tests/earnings21/eval.py +68 -0
- data/ext/sources/tests/earnings21/normalizers/__init__.py +2 -0
- data/ext/sources/tests/earnings21/normalizers/basic.py +80 -0
- data/ext/sources/tests/earnings21/normalizers/english.json +1741 -0
- data/ext/sources/tests/earnings21/normalizers/english.py +550 -0
- data/ext/sources/tests/earnings21/requirements.txt +6 -0
- data/ext/sources/tests/en-0-ref.txt +1 -0
- data/ext/sources/tests/en-1-ref.txt +1 -0
- data/ext/sources/tests/en-2-ref.txt +1 -0
- data/ext/sources/tests/es-0-ref.txt +1 -0
- data/ext/sources/tests/librispeech/eval.mk +39 -0
- data/ext/sources/tests/librispeech/eval.py +47 -0
- data/ext/sources/tests/librispeech/normalizers/__init__.py +2 -0
- data/ext/sources/tests/librispeech/normalizers/basic.py +80 -0
- data/ext/sources/tests/librispeech/normalizers/english.json +1741 -0
- data/ext/sources/tests/librispeech/normalizers/english.py +550 -0
- data/ext/sources/tests/librispeech/requirements.txt +6 -0
- data/ext/sources/tests/run-tests.sh +130 -0
- data/ext/sources/tests/test-c.c +3 -0
- data/ext/sources/tests/test-vad-full.cpp +54 -0
- data/ext/sources/tests/test-vad.cpp +83 -0
- data/ext/sources/tests/test-whisper.js +58 -0
- data/extsources.rb +39 -5
- data/lib/whisper/context.rb +15 -0
- data/lib/whisper/model/uri.rb +202 -126
- data/lib/whisper/segment.rb +58 -0
- data/sig/whisper.rbs +510 -0
- data/test/helper.rb +24 -0
- data/{tests → test}/test_callback.rb +45 -3
- data/{tests → test}/test_error.rb +2 -2
- data/{tests → test}/test_model.rb +47 -0
- data/test/test_package.rb +51 -0
- data/test/test_params.rb +297 -0
- data/test/test_segment.rb +146 -0
- data/test/test_vad.rb +19 -0
- data/test/test_vad_params.rb +103 -0
- data/{tests → test}/test_whisper.rb +106 -36
- data/whispercpp.gemspec +5 -5
- metadata +837 -134
- data/ext/cpu.mk +0 -9
- data/ext/examples/dr_wav.h +0 -8815
- data/ext/ggml/src/ggml-cann/aclnn_ops.h +0 -592
- data/ext/ggml/src/ggml-cpu/ggml-cpu-aarch64.cpp +0 -4262
- data/ext/ggml/src/ggml-cpu/ggml-cpu-aarch64.h +0 -8
- data/ext/ggml/src/ggml-cpu/ggml-cpu-quants.c +0 -10835
- data/ext/ggml/src/ggml-cpu/ggml-cpu.c +0 -14123
- data/ext/ggml/src/ggml-cpu/llamafile/sgemm.cpp +0 -1884
- data/ext/ggml/src/ggml-cpu/llamafile/sgemm.h +0 -14
- data/ext/ggml/src/ggml-metal/ggml-metal-impl.h +0 -288
- data/ext/ggml/src/ggml-sycl/convert.cpp +0 -547
- data/ext/ggml/src/ggml-sycl/element_wise.cpp +0 -1030
- data/ext/ggml/src/ggml-sycl/im2col.cpp +0 -126
- data/ext/ggml/src/ggml-sycl/mmvq.cpp +0 -1015
- data/ext/ggml/src/ggml-sycl/norm.cpp +0 -378
- data/ext/ggml/src/ggml-sycl/rope.cpp +0 -276
- data/ext/ggml/src/ggml-sycl/wkv6.cpp +0 -141
- data/ext/metal-embed.mk +0 -17
- data/ext/metal.mk +0 -6
- data/ext/ruby_whisper.cpp +0 -1909
- data/ext/scripts/get-flags.mk +0 -38
- data/lib/whisper.rb +0 -2
- data/tests/helper.rb +0 -7
- data/tests/test_package.rb +0 -31
- data/tests/test_params.rb +0 -160
- data/tests/test_segment.rb +0 -83
- /data/ext/{ggml → sources/ggml}/include/ggml-blas.h +0 -0
- /data/ext/{ggml → sources/ggml}/include/ggml-cann.h +0 -0
- /data/ext/{ggml → sources/ggml}/include/ggml-cuda.h +0 -0
- /data/ext/{ggml → sources/ggml}/include/ggml-kompute.h +0 -0
- /data/ext/{ggml → sources/ggml}/include/ggml-opencl.h +0 -0
- /data/ext/{ggml → sources/ggml}/include/ggml-sycl.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-amx/common.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-amx/ggml-amx.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-amx/mmq.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-amx/mmq.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-blas/ggml-blas.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/ascendc_kernels.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/get_row_f16.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/get_row_f32.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/get_row_q4_0.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/get_row_q8_0.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/quantize_f16_q8_0.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/quantize_f32_q8_0.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cann/kernels/quantize_float_to_q4_0.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cpu/amx/amx.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cpu/amx/common.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-cpu/amx/mmq.h +0 -0
- /data/ext/{ggml/src/ggml-cpu/ggml-cpu-hbm.h → sources/ggml/src/ggml-cpu/hbm.h} +0 -0
- /data/ext/{ggml/src/ggml-cpu/ggml-cpu-traits.h → sources/ggml/src/ggml-cpu/traits.h} +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-kompute/ggml-kompute.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-quants.h +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-threading.cpp +0 -0
- /data/ext/{ggml → sources/ggml}/src/ggml-threading.h +0 -0
- /data/ext/{src → sources/src}/coreml/whisper-encoder.h +0 -0
- /data/ext/{src → sources/src}/openvino/whisper-openvino-encoder.cpp +0 -0
- /data/ext/{src → sources/src}/openvino/whisper-openvino-encoder.h +0 -0
- /data/{tests → test}/jfk_reader/.gitignore +0 -0
- /data/{tests → test}/jfk_reader/extconf.rb +0 -0
- /data/{tests → test}/jfk_reader/jfk_reader.c +0 -0
@@ -0,0 +1,1158 @@
|
|
1
|
+
#define GGML_COMMON_IMPL_C
|
2
|
+
#include "ggml-common.h"
|
3
|
+
|
4
|
+
#include "ggml-cpu-impl.h"
|
5
|
+
#include "simd-mappings.h"
|
6
|
+
#include "ggml-quants.h"
|
7
|
+
#include "quants.h"
|
8
|
+
|
9
|
+
#include "arch-fallback.h"
|
10
|
+
|
11
|
+
#include <string.h>
|
12
|
+
#include <assert.h>
|
13
|
+
#include <float.h>
|
14
|
+
#include <stdlib.h> // for qsort
|
15
|
+
#include <stdio.h> // for GGML_ASSERT
|
16
|
+
|
17
|
+
#define GROUP_MAX_EPS 1e-15f
|
18
|
+
#define GROUP_MAX_EPS_IQ3_XXS 1e-8f
|
19
|
+
#define GROUP_MAX_EPS_IQ2_S 1e-8f
|
20
|
+
#define GROUP_MAX_EPS_IQ1_M 1e-7f
|
21
|
+
#define GROUP_MAX_EPS_IQ1_S 1e-12f
|
22
|
+
|
23
|
+
#define UNUSED GGML_UNUSED
|
24
|
+
|
25
|
+
void quantize_row_q4_0(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
26
|
+
quantize_row_q4_0_ref(x, y, k);
|
27
|
+
}
|
28
|
+
|
29
|
+
void quantize_row_q4_1(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
30
|
+
quantize_row_q4_1_ref(x, y, k);
|
31
|
+
}
|
32
|
+
|
33
|
+
void quantize_row_q5_0(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
34
|
+
quantize_row_q5_0_ref(x, y, k);
|
35
|
+
}
|
36
|
+
|
37
|
+
void quantize_row_q5_1(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
38
|
+
quantize_row_q5_1_ref(x, y, k);
|
39
|
+
}
|
40
|
+
|
41
|
+
void quantize_row_q8_0_generic(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
42
|
+
quantize_row_q8_0_ref(x, y, k);
|
43
|
+
}
|
44
|
+
|
45
|
+
void quantize_row_q8_1_generic(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
46
|
+
quantize_row_q8_1_ref(x, y, k);
|
47
|
+
}
|
48
|
+
|
49
|
+
//
|
50
|
+
// 2-6 bit quantization in super-blocks
|
51
|
+
//
|
52
|
+
|
53
|
+
//========================- 2-bit (de)-quantization
|
54
|
+
|
55
|
+
void quantize_row_q2_K(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
56
|
+
quantize_row_q2_K_ref(x, vy, k);
|
57
|
+
}
|
58
|
+
|
59
|
+
//========================= 3-bit (de)-quantization
|
60
|
+
|
61
|
+
void quantize_row_q3_K(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
62
|
+
quantize_row_q3_K_ref(x, vy, k);
|
63
|
+
}
|
64
|
+
|
65
|
+
// ====================== 4-bit (de)-quantization
|
66
|
+
|
67
|
+
void quantize_row_q4_K(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
68
|
+
assert(k % QK_K == 0);
|
69
|
+
block_q4_K * GGML_RESTRICT y = vy;
|
70
|
+
quantize_row_q4_K_ref(x, y, k);
|
71
|
+
}
|
72
|
+
|
73
|
+
// ====================== 5-bit (de)-quantization
|
74
|
+
|
75
|
+
void quantize_row_q5_K(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
76
|
+
assert(k % QK_K == 0);
|
77
|
+
block_q5_K * GGML_RESTRICT y = vy;
|
78
|
+
quantize_row_q5_K_ref(x, y, k);
|
79
|
+
}
|
80
|
+
|
81
|
+
// ====================== 6-bit (de)-quantization
|
82
|
+
|
83
|
+
void quantize_row_q6_K(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
84
|
+
assert(k % QK_K == 0);
|
85
|
+
block_q6_K * GGML_RESTRICT y = vy;
|
86
|
+
quantize_row_q6_K_ref(x, y, k);
|
87
|
+
}
|
88
|
+
|
89
|
+
// ====================== Ternary (de)-quantization (BitNet b1.58 and TriLMs)
|
90
|
+
|
91
|
+
void quantize_row_tq1_0(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
92
|
+
assert(k % QK_K == 0);
|
93
|
+
block_tq1_0 * GGML_RESTRICT y = vy;
|
94
|
+
quantize_row_tq1_0_ref(x, y, k);
|
95
|
+
}
|
96
|
+
|
97
|
+
void quantize_row_tq2_0(const float * GGML_RESTRICT x, void * GGML_RESTRICT vy, int64_t k) {
|
98
|
+
assert(k % QK_K == 0);
|
99
|
+
block_tq2_0 * GGML_RESTRICT y = vy;
|
100
|
+
quantize_row_tq2_0_ref(x, y, k);
|
101
|
+
}
|
102
|
+
|
103
|
+
//===================================== Q8_K ==============================================
|
104
|
+
|
105
|
+
void quantize_row_q8_K_generic(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
106
|
+
quantize_row_q8_K_ref(x, y, k);
|
107
|
+
}
|
108
|
+
|
109
|
+
//===================================== Dot products =================================
|
110
|
+
|
111
|
+
void ggml_vec_dot_q4_0_q8_0_generic(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) {
|
112
|
+
const int qk = QK8_0;
|
113
|
+
const int nb = n / qk;
|
114
|
+
|
115
|
+
assert(n % qk == 0);
|
116
|
+
assert(nrc == 1);
|
117
|
+
UNUSED(nrc);
|
118
|
+
UNUSED(bx);
|
119
|
+
UNUSED(by);
|
120
|
+
UNUSED(bs);
|
121
|
+
|
122
|
+
const block_q4_0 * GGML_RESTRICT x = vx;
|
123
|
+
const block_q8_0 * GGML_RESTRICT y = vy;
|
124
|
+
|
125
|
+
int ib = 0;
|
126
|
+
float sumf = 0;
|
127
|
+
|
128
|
+
for (; ib < nb; ++ib) {
|
129
|
+
int sumi0 = 0;
|
130
|
+
int sumi1 = 0;
|
131
|
+
|
132
|
+
for (int j = 0; j < qk/2; ++j) {
|
133
|
+
const int v0 = (x[ib].qs[j] & 0x0F) - 8;
|
134
|
+
const int v1 = (x[ib].qs[j] >> 4) - 8;
|
135
|
+
|
136
|
+
sumi0 += (v0 * y[ib].qs[j]);
|
137
|
+
sumi1 += (v1 * y[ib].qs[j + qk/2]);
|
138
|
+
}
|
139
|
+
|
140
|
+
int sumi = sumi0 + sumi1;
|
141
|
+
sumf += sumi*GGML_CPU_FP16_TO_FP32(x[ib].d)*GGML_CPU_FP16_TO_FP32(y[ib].d);
|
142
|
+
}
|
143
|
+
|
144
|
+
*s = sumf;
|
145
|
+
}
|
146
|
+
|
147
|
+
// TODO: add WASM SIMD
|
148
|
+
void ggml_vec_dot_q4_1_q8_1_generic(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) {
|
149
|
+
const int qk = QK8_1;
|
150
|
+
const int nb = n / qk;
|
151
|
+
|
152
|
+
assert(n % qk == 0);
|
153
|
+
assert(nrc == 1);
|
154
|
+
UNUSED(nrc);
|
155
|
+
UNUSED(bx);
|
156
|
+
UNUSED(by);
|
157
|
+
UNUSED(bs);
|
158
|
+
|
159
|
+
const block_q4_1 * GGML_RESTRICT x = vx;
|
160
|
+
const block_q8_1 * GGML_RESTRICT y = vy;
|
161
|
+
|
162
|
+
int ib = 0;
|
163
|
+
float sumf = 0;
|
164
|
+
|
165
|
+
for (; ib < nb; ++ib) {
|
166
|
+
int sumi0 = 0;
|
167
|
+
int sumi1 = 0;
|
168
|
+
|
169
|
+
for (int j = 0; j < qk/2; ++j) {
|
170
|
+
const int v0 = (x[ib].qs[j] & 0x0F);
|
171
|
+
const int v1 = (x[ib].qs[j] >> 4);
|
172
|
+
|
173
|
+
sumi0 += (v0 * y[ib].qs[j]);
|
174
|
+
sumi1 += (v1 * y[ib].qs[j + qk/2]);
|
175
|
+
}
|
176
|
+
|
177
|
+
int sumi = sumi0 + sumi1;
|
178
|
+
sumf += (GGML_CPU_FP16_TO_FP32(x[ib].d)*GGML_CPU_FP16_TO_FP32(y[ib].d))*sumi + GGML_CPU_FP16_TO_FP32(x[ib].m)*GGML_CPU_FP16_TO_FP32(y[ib].s);
|
179
|
+
}
|
180
|
+
|
181
|
+
*s = sumf;
|
182
|
+
}
|
183
|
+
|
184
|
+
void ggml_vec_dot_q5_0_q8_0_generic(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) {
|
185
|
+
const int qk = QK8_0;
|
186
|
+
const int nb = n / qk;
|
187
|
+
|
188
|
+
int ib = 0;
|
189
|
+
float sumf = 0;
|
190
|
+
|
191
|
+
assert(n % qk == 0);
|
192
|
+
assert(qk == QK5_0);
|
193
|
+
assert(nrc == 1);
|
194
|
+
UNUSED(nrc);
|
195
|
+
UNUSED(bx);
|
196
|
+
UNUSED(by);
|
197
|
+
UNUSED(bs);
|
198
|
+
|
199
|
+
const block_q5_0 * GGML_RESTRICT x = vx;
|
200
|
+
const block_q8_0 * GGML_RESTRICT y = vy;
|
201
|
+
|
202
|
+
for (; ib < nb; ++ib) {
|
203
|
+
uint32_t qh;
|
204
|
+
memcpy(&qh, x[ib].qh, sizeof(qh));
|
205
|
+
|
206
|
+
int sumi0 = 0;
|
207
|
+
int sumi1 = 0;
|
208
|
+
|
209
|
+
for (int j = 0; j < qk/2; ++j) {
|
210
|
+
const uint8_t xh_0 = ((qh & (1u << (j + 0 ))) >> (j + 0 )) << 4;
|
211
|
+
const uint8_t xh_1 = ((qh & (1u << (j + 16))) >> (j + 12));
|
212
|
+
|
213
|
+
const int32_t x0 = (int8_t)(((x[ib].qs[j] & 0x0F) | xh_0) - 16);
|
214
|
+
const int32_t x1 = (int8_t)(((x[ib].qs[j] >> 4) | xh_1) - 16);
|
215
|
+
|
216
|
+
sumi0 += (x0 * y[ib].qs[j]);
|
217
|
+
sumi1 += (x1 * y[ib].qs[j + qk/2]);
|
218
|
+
}
|
219
|
+
|
220
|
+
int sumi = sumi0 + sumi1;
|
221
|
+
sumf += (GGML_CPU_FP16_TO_FP32(x[ib].d)*GGML_CPU_FP16_TO_FP32(y[ib].d)) * sumi;
|
222
|
+
}
|
223
|
+
|
224
|
+
*s = sumf;
|
225
|
+
}
|
226
|
+
|
227
|
+
void ggml_vec_dot_q5_1_q8_1_generic(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) {
|
228
|
+
const int qk = QK8_1;
|
229
|
+
const int nb = n / qk;
|
230
|
+
|
231
|
+
int ib = 0;
|
232
|
+
float sumf = 0;
|
233
|
+
|
234
|
+
assert(n % qk == 0);
|
235
|
+
assert(qk == QK5_1);
|
236
|
+
assert(nrc == 1);
|
237
|
+
UNUSED(nrc);
|
238
|
+
UNUSED(bx);
|
239
|
+
UNUSED(by);
|
240
|
+
UNUSED(bs);
|
241
|
+
|
242
|
+
const block_q5_1 * GGML_RESTRICT x = vx;
|
243
|
+
const block_q8_1 * GGML_RESTRICT y = vy;
|
244
|
+
|
245
|
+
for (; ib < nb; ++ib) {
|
246
|
+
uint32_t qh;
|
247
|
+
memcpy(&qh, x[ib].qh, sizeof(qh));
|
248
|
+
|
249
|
+
int sumi0 = 0;
|
250
|
+
int sumi1 = 0;
|
251
|
+
|
252
|
+
for (int j = 0; j < qk/2; ++j) {
|
253
|
+
const uint8_t xh_0 = ((qh >> (j + 0)) << 4) & 0x10;
|
254
|
+
const uint8_t xh_1 = ((qh >> (j + 12)) ) & 0x10;
|
255
|
+
|
256
|
+
const int32_t x0 = (x[ib].qs[j] & 0xF) | xh_0;
|
257
|
+
const int32_t x1 = (x[ib].qs[j] >> 4) | xh_1;
|
258
|
+
|
259
|
+
sumi0 += (x0 * y[ib].qs[j]);
|
260
|
+
sumi1 += (x1 * y[ib].qs[j + qk/2]);
|
261
|
+
}
|
262
|
+
|
263
|
+
int sumi = sumi0 + sumi1;
|
264
|
+
sumf += (GGML_CPU_FP16_TO_FP32(x[ib].d)*GGML_CPU_FP16_TO_FP32(y[ib].d))*sumi + GGML_CPU_FP16_TO_FP32(x[ib].m)*GGML_CPU_FP16_TO_FP32(y[ib].s);
|
265
|
+
}
|
266
|
+
|
267
|
+
*s = sumf;
|
268
|
+
}
|
269
|
+
|
270
|
+
void ggml_vec_dot_q8_0_q8_0_generic(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) {
|
271
|
+
const int qk = QK8_0;
|
272
|
+
const int nb = n / qk;
|
273
|
+
|
274
|
+
assert(n % qk == 0);
|
275
|
+
assert(nrc == 1);
|
276
|
+
UNUSED(nrc);
|
277
|
+
UNUSED(bx);
|
278
|
+
UNUSED(by);
|
279
|
+
UNUSED(bs);
|
280
|
+
|
281
|
+
const block_q8_0 * GGML_RESTRICT x = vx;
|
282
|
+
const block_q8_0 * GGML_RESTRICT y = vy;
|
283
|
+
|
284
|
+
int ib = 0;
|
285
|
+
float sumf = 0;
|
286
|
+
|
287
|
+
for (; ib < nb; ++ib) {
|
288
|
+
int sumi = 0;
|
289
|
+
|
290
|
+
for (int j = 0; j < qk; j++) {
|
291
|
+
sumi += x[ib].qs[j]*y[ib].qs[j];
|
292
|
+
}
|
293
|
+
|
294
|
+
sumf += sumi*(GGML_CPU_FP16_TO_FP32(x[ib].d)*GGML_CPU_FP16_TO_FP32(y[ib].d));
|
295
|
+
}
|
296
|
+
|
297
|
+
*s = sumf;
|
298
|
+
}
|
299
|
+
|
300
|
+
void ggml_vec_dot_tq1_0_q8_K_generic(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) {
|
301
|
+
assert(nrc == 1);
|
302
|
+
UNUSED(nrc);
|
303
|
+
UNUSED(bx);
|
304
|
+
UNUSED(by);
|
305
|
+
UNUSED(bs);
|
306
|
+
|
307
|
+
const block_tq1_0 * GGML_RESTRICT x = vx;
|
308
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
309
|
+
|
310
|
+
const int nb = n / QK_K;
|
311
|
+
|
312
|
+
const uint8_t pow3[6] = {1, 3, 9, 27, 81, 243};
|
313
|
+
|
314
|
+
float sumf = 0.0f;
|
315
|
+
|
316
|
+
for (int i = 0; i < nb; ++i) {
|
317
|
+
int sum = 0;
|
318
|
+
|
319
|
+
for (size_t j = 0; j < sizeof(x->qs) - sizeof(x->qs) % 32; j += 32) {
|
320
|
+
for (size_t l = 0; l < 5; ++l) {
|
321
|
+
for (size_t m = 0; m < 32; ++m) {
|
322
|
+
uint8_t q = x[i].qs[j + m] * pow3[l];
|
323
|
+
uint16_t xi = ((uint16_t) q * 3) >> 8;
|
324
|
+
sum += (xi - 1) * y[i].qs[j*5 + l*32 + m];
|
325
|
+
}
|
326
|
+
}
|
327
|
+
}
|
328
|
+
for (size_t j = sizeof(x->qs) - sizeof(x->qs) % 32; j < sizeof(x->qs); j += 16) {
|
329
|
+
for (size_t l = 0; l < 5; ++l) {
|
330
|
+
for (size_t m = 0; m < 16; ++m) {
|
331
|
+
uint8_t q = x[i].qs[j + m] * pow3[l];
|
332
|
+
uint16_t xi = ((uint16_t) q * 3) >> 8;
|
333
|
+
sum += (xi - 1) * y[i].qs[j*5 + l*16 + m];
|
334
|
+
}
|
335
|
+
}
|
336
|
+
}
|
337
|
+
|
338
|
+
for (size_t l = 0; l < 4; ++l) {
|
339
|
+
for (size_t j = 0; j < sizeof(x->qh); ++j) {
|
340
|
+
uint8_t q = x[i].qh[j] * pow3[l];
|
341
|
+
uint16_t xi = ((uint16_t) q * 3) >> 8;
|
342
|
+
sum += (xi - 1) * y[i].qs[sizeof(x->qs)*5 + l*sizeof(x->qh) + j];
|
343
|
+
}
|
344
|
+
}
|
345
|
+
|
346
|
+
sumf += (float) sum * (GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d);
|
347
|
+
}
|
348
|
+
|
349
|
+
*s = sumf;
|
350
|
+
}
|
351
|
+
|
352
|
+
void ggml_vec_dot_tq2_0_q8_K_generic(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) {
|
353
|
+
assert(nrc == 1);
|
354
|
+
UNUSED(nrc);
|
355
|
+
UNUSED(bx);
|
356
|
+
UNUSED(by);
|
357
|
+
UNUSED(bs);
|
358
|
+
|
359
|
+
const block_tq2_0 * GGML_RESTRICT x = vx;
|
360
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
361
|
+
|
362
|
+
const int nb = n / QK_K;
|
363
|
+
float sumf = 0.0f;
|
364
|
+
|
365
|
+
for (int i = 0; i < nb; ++i) {
|
366
|
+
int32_t sumi = 0;
|
367
|
+
|
368
|
+
for (size_t j = 0; j < sizeof(x->qs); j += 32) {
|
369
|
+
for (size_t l = 0; l < 4; ++l) {
|
370
|
+
for (size_t k = 0; k < 32; ++k) {
|
371
|
+
sumi += y[i].qs[j*4 + l*32 + k] * (((x[i].qs[j + k] >> (l*2)) & 3) - 1);
|
372
|
+
}
|
373
|
+
}
|
374
|
+
}
|
375
|
+
|
376
|
+
const float d = y[i].d * GGML_CPU_FP16_TO_FP32(x[i].d);
|
377
|
+
|
378
|
+
sumf += (float) sumi * d;
|
379
|
+
}
|
380
|
+
|
381
|
+
*s = sumf;
|
382
|
+
}
|
383
|
+
|
384
|
+
void ggml_vec_dot_q2_K_q8_K_generic(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) {
|
385
|
+
assert(nrc == 1);
|
386
|
+
UNUSED(nrc);
|
387
|
+
UNUSED(bx);
|
388
|
+
UNUSED(by);
|
389
|
+
UNUSED(bs);
|
390
|
+
|
391
|
+
const block_q2_K * GGML_RESTRICT x = vx;
|
392
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
393
|
+
|
394
|
+
const int nb = n / QK_K;
|
395
|
+
|
396
|
+
float sumf = 0;
|
397
|
+
|
398
|
+
for (int i = 0; i < nb; ++i) {
|
399
|
+
|
400
|
+
const uint8_t * q2 = x[i].qs;
|
401
|
+
const int8_t * q8 = y[i].qs;
|
402
|
+
const uint8_t * sc = x[i].scales;
|
403
|
+
|
404
|
+
int summs = 0;
|
405
|
+
for (int j = 0; j < 16; ++j) {
|
406
|
+
summs += y[i].bsums[j] * (sc[j] >> 4);
|
407
|
+
}
|
408
|
+
|
409
|
+
const float dall = y[i].d * GGML_CPU_FP16_TO_FP32(x[i].d);
|
410
|
+
const float dmin = y[i].d * GGML_CPU_FP16_TO_FP32(x[i].dmin);
|
411
|
+
|
412
|
+
int isum = 0;
|
413
|
+
int is = 0;
|
414
|
+
int d;
|
415
|
+
for (int k = 0; k < QK_K/128; ++k) {
|
416
|
+
int shift = 0;
|
417
|
+
for (int j = 0; j < 4; ++j) {
|
418
|
+
d = sc[is++] & 0xF;
|
419
|
+
int isuml = 0;
|
420
|
+
for (int l = 0; l < 16; ++l) isuml += q8[l] * ((q2[l] >> shift) & 3);
|
421
|
+
isum += d * isuml;
|
422
|
+
d = sc[is++] & 0xF;
|
423
|
+
isuml = 0;
|
424
|
+
for (int l = 16; l < 32; ++l) isuml += q8[l] * ((q2[l] >> shift) & 3);
|
425
|
+
isum += d * isuml;
|
426
|
+
shift += 2;
|
427
|
+
q8 += 32;
|
428
|
+
}
|
429
|
+
q2 += 32;
|
430
|
+
}
|
431
|
+
sumf += dall * isum - dmin * summs;
|
432
|
+
}
|
433
|
+
*s = sumf;
|
434
|
+
}
|
435
|
+
|
436
|
+
void ggml_vec_dot_q3_K_q8_K_generic(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) {
|
437
|
+
assert(n % QK_K == 0);
|
438
|
+
assert(nrc == 1);
|
439
|
+
UNUSED(nrc);
|
440
|
+
UNUSED(bx);
|
441
|
+
UNUSED(by);
|
442
|
+
UNUSED(bs);
|
443
|
+
|
444
|
+
const uint32_t kmask1 = 0x03030303;
|
445
|
+
const uint32_t kmask2 = 0x0f0f0f0f;
|
446
|
+
|
447
|
+
const block_q3_K * GGML_RESTRICT x = vx;
|
448
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
449
|
+
|
450
|
+
const int nb = n / QK_K;
|
451
|
+
|
452
|
+
// scalar version
|
453
|
+
// This function is written like this so the compiler can manage to vectorize most of it
|
454
|
+
// Using -Ofast, GCC and clang manage to produce code that is within a factor of 2 or so from the
|
455
|
+
// manually vectorized version above. Every other version I tried would run at least 4 times slower.
|
456
|
+
// The ideal situation would be if we could just write the code once, and the compiler would
|
457
|
+
// automatically produce the best possible set of machine instructions, instead of us having to manually
|
458
|
+
// write vectorized versions for AVX, ARM_NEON, etc.
|
459
|
+
|
460
|
+
int8_t aux8[QK_K];
|
461
|
+
int16_t aux16[8];
|
462
|
+
float sums [8];
|
463
|
+
int32_t aux32[8];
|
464
|
+
memset(sums, 0, 8*sizeof(float));
|
465
|
+
|
466
|
+
uint32_t auxs[4];
|
467
|
+
const int8_t * scales = (const int8_t*)auxs;
|
468
|
+
|
469
|
+
float sumf = 0;
|
470
|
+
for (int i = 0; i < nb; ++i) {
|
471
|
+
const uint8_t * GGML_RESTRICT q3 = x[i].qs;
|
472
|
+
const uint8_t * GGML_RESTRICT hm = x[i].hmask;
|
473
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
474
|
+
memset(aux32, 0, 8*sizeof(int32_t));
|
475
|
+
int8_t * GGML_RESTRICT a = aux8;
|
476
|
+
uint8_t m = 1;
|
477
|
+
for (int j = 0; j < QK_K; j += 128) {
|
478
|
+
for (int l = 0; l < 32; ++l) a[l] = q3[l] & 3;
|
479
|
+
for (int l = 0; l < 32; ++l) a[l] -= (hm[l] & m ? 0 : 4);
|
480
|
+
a += 32; m <<= 1;
|
481
|
+
for (int l = 0; l < 32; ++l) a[l] = (q3[l] >> 2) & 3;
|
482
|
+
for (int l = 0; l < 32; ++l) a[l] -= (hm[l] & m ? 0 : 4);
|
483
|
+
a += 32; m <<= 1;
|
484
|
+
for (int l = 0; l < 32; ++l) a[l] = (q3[l] >> 4) & 3;
|
485
|
+
for (int l = 0; l < 32; ++l) a[l] -= (hm[l] & m ? 0 : 4);
|
486
|
+
a += 32; m <<= 1;
|
487
|
+
for (int l = 0; l < 32; ++l) a[l] = (q3[l] >> 6) & 3;
|
488
|
+
for (int l = 0; l < 32; ++l) a[l] -= (hm[l] & m ? 0 : 4);
|
489
|
+
a += 32; m <<= 1;
|
490
|
+
q3 += 32;
|
491
|
+
}
|
492
|
+
a = aux8;
|
493
|
+
|
494
|
+
memcpy(auxs, x[i].scales, 12);
|
495
|
+
uint32_t tmp = auxs[2];
|
496
|
+
auxs[2] = ((auxs[0] >> 4) & kmask2) | (((tmp >> 4) & kmask1) << 4);
|
497
|
+
auxs[3] = ((auxs[1] >> 4) & kmask2) | (((tmp >> 6) & kmask1) << 4);
|
498
|
+
auxs[0] = (auxs[0] & kmask2) | (((tmp >> 0) & kmask1) << 4);
|
499
|
+
auxs[1] = (auxs[1] & kmask2) | (((tmp >> 2) & kmask1) << 4);
|
500
|
+
for (int j = 0; j < QK_K/16; ++j) {
|
501
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
502
|
+
for (int l = 0; l < 8; ++l) aux32[l] += (scales[j] - 32) * aux16[l];
|
503
|
+
q8 += 8; a += 8;
|
504
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
505
|
+
for (int l = 0; l < 8; ++l) aux32[l] += (scales[j] - 32) * aux16[l];
|
506
|
+
q8 += 8; a += 8;
|
507
|
+
}
|
508
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
509
|
+
for (int l = 0; l < 8; ++l) sums[l] += d * aux32[l];
|
510
|
+
}
|
511
|
+
for (int l = 0; l < 8; ++l) sumf += sums[l];
|
512
|
+
*s = sumf;
|
513
|
+
}
|
514
|
+
|
515
|
+
void ggml_vec_dot_q4_K_q8_K_generic(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) {
|
516
|
+
assert(n % QK_K == 0);
|
517
|
+
assert(nrc == 1);
|
518
|
+
UNUSED(nrc);
|
519
|
+
UNUSED(bx);
|
520
|
+
UNUSED(by);
|
521
|
+
UNUSED(bs);
|
522
|
+
|
523
|
+
const block_q4_K * GGML_RESTRICT x = vx;
|
524
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
525
|
+
|
526
|
+
const int nb = n / QK_K;
|
527
|
+
|
528
|
+
static const uint32_t kmask1 = 0x3f3f3f3f;
|
529
|
+
static const uint32_t kmask2 = 0x0f0f0f0f;
|
530
|
+
static const uint32_t kmask3 = 0x03030303;
|
531
|
+
|
532
|
+
uint32_t utmp[4];
|
533
|
+
|
534
|
+
const uint8_t * scales = (const uint8_t*)&utmp[0];
|
535
|
+
const uint8_t * mins = (const uint8_t*)&utmp[2];
|
536
|
+
|
537
|
+
int8_t aux8[QK_K];
|
538
|
+
int16_t aux16[8];
|
539
|
+
float sums [8];
|
540
|
+
int32_t aux32[8];
|
541
|
+
memset(sums, 0, 8*sizeof(float));
|
542
|
+
|
543
|
+
float sumf = 0;
|
544
|
+
for (int i = 0; i < nb; ++i) {
|
545
|
+
const uint8_t * GGML_RESTRICT q4 = x[i].qs;
|
546
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
547
|
+
memset(aux32, 0, 8*sizeof(int32_t));
|
548
|
+
int8_t * GGML_RESTRICT a = aux8;
|
549
|
+
for (int j = 0; j < QK_K/64; ++j) {
|
550
|
+
for (int l = 0; l < 32; ++l) a[l] = (int8_t)(q4[l] & 0xF);
|
551
|
+
a += 32;
|
552
|
+
for (int l = 0; l < 32; ++l) a[l] = (int8_t)(q4[l] >> 4);
|
553
|
+
a += 32; q4 += 32;
|
554
|
+
}
|
555
|
+
memcpy(utmp, x[i].scales, 12);
|
556
|
+
utmp[3] = ((utmp[2] >> 4) & kmask2) | (((utmp[1] >> 6) & kmask3) << 4);
|
557
|
+
const uint32_t uaux = utmp[1] & kmask1;
|
558
|
+
utmp[1] = (utmp[2] & kmask2) | (((utmp[0] >> 6) & kmask3) << 4);
|
559
|
+
utmp[2] = uaux;
|
560
|
+
utmp[0] &= kmask1;
|
561
|
+
|
562
|
+
int sumi = 0;
|
563
|
+
for (int j = 0; j < QK_K/16; ++j) sumi += y[i].bsums[j] * mins[j/2];
|
564
|
+
a = aux8;
|
565
|
+
int is = 0;
|
566
|
+
for (int j = 0; j < QK_K/32; ++j) {
|
567
|
+
int32_t scale = scales[is++];
|
568
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
569
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
570
|
+
q8 += 8; a += 8;
|
571
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
572
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
573
|
+
q8 += 8; a += 8;
|
574
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
575
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
576
|
+
q8 += 8; a += 8;
|
577
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
578
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
579
|
+
q8 += 8; a += 8;
|
580
|
+
}
|
581
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
582
|
+
for (int l = 0; l < 8; ++l) sums[l] += d * aux32[l];
|
583
|
+
const float dmin = GGML_CPU_FP16_TO_FP32(x[i].dmin) * y[i].d;
|
584
|
+
sumf -= dmin * sumi;
|
585
|
+
}
|
586
|
+
for (int l = 0; l < 8; ++l) sumf += sums[l];
|
587
|
+
*s = sumf;
|
588
|
+
}
|
589
|
+
|
590
|
+
void ggml_vec_dot_q5_K_q8_K_generic(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) {
|
591
|
+
assert(n % QK_K == 0);
|
592
|
+
assert(nrc == 1);
|
593
|
+
UNUSED(nrc);
|
594
|
+
UNUSED(bx);
|
595
|
+
UNUSED(by);
|
596
|
+
UNUSED(bs);
|
597
|
+
|
598
|
+
const block_q5_K * GGML_RESTRICT x = vx;
|
599
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
600
|
+
|
601
|
+
const int nb = n / QK_K;
|
602
|
+
|
603
|
+
static const uint32_t kmask1 = 0x3f3f3f3f;
|
604
|
+
static const uint32_t kmask2 = 0x0f0f0f0f;
|
605
|
+
static const uint32_t kmask3 = 0x03030303;
|
606
|
+
|
607
|
+
uint32_t utmp[4];
|
608
|
+
|
609
|
+
const uint8_t * scales = (const uint8_t*)&utmp[0];
|
610
|
+
const uint8_t * mins = (const uint8_t*)&utmp[2];
|
611
|
+
|
612
|
+
int8_t aux8[QK_K];
|
613
|
+
int16_t aux16[8];
|
614
|
+
float sums [8];
|
615
|
+
int32_t aux32[8];
|
616
|
+
memset(sums, 0, 8*sizeof(float));
|
617
|
+
|
618
|
+
float sumf = 0;
|
619
|
+
for (int i = 0; i < nb; ++i) {
|
620
|
+
const uint8_t * GGML_RESTRICT q4 = x[i].qs;
|
621
|
+
const uint8_t * GGML_RESTRICT hm = x[i].qh;
|
622
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
623
|
+
memset(aux32, 0, 8*sizeof(int32_t));
|
624
|
+
int8_t * GGML_RESTRICT a = aux8;
|
625
|
+
uint8_t m = 1;
|
626
|
+
for (int j = 0; j < QK_K/64; ++j) {
|
627
|
+
for (int l = 0; l < 32; ++l) a[l] = (int8_t)(q4[l] & 0xF);
|
628
|
+
for (int l = 0; l < 32; ++l) a[l] += (hm[l] & m ? 16 : 0);
|
629
|
+
a += 32; m <<= 1;
|
630
|
+
for (int l = 0; l < 32; ++l) a[l] = (int8_t)(q4[l] >> 4);
|
631
|
+
for (int l = 0; l < 32; ++l) a[l] += (hm[l] & m ? 16 : 0);
|
632
|
+
a += 32; m <<= 1;
|
633
|
+
q4 += 32;
|
634
|
+
}
|
635
|
+
memcpy(utmp, x[i].scales, 12);
|
636
|
+
utmp[3] = ((utmp[2] >> 4) & kmask2) | (((utmp[1] >> 6) & kmask3) << 4);
|
637
|
+
const uint32_t uaux = utmp[1] & kmask1;
|
638
|
+
utmp[1] = (utmp[2] & kmask2) | (((utmp[0] >> 6) & kmask3) << 4);
|
639
|
+
utmp[2] = uaux;
|
640
|
+
utmp[0] &= kmask1;
|
641
|
+
|
642
|
+
int sumi = 0;
|
643
|
+
for (int j = 0; j < QK_K/16; ++j) sumi += y[i].bsums[j] * mins[j/2];
|
644
|
+
a = aux8;
|
645
|
+
int is = 0;
|
646
|
+
for (int j = 0; j < QK_K/32; ++j) {
|
647
|
+
int32_t scale = scales[is++];
|
648
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
649
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
650
|
+
q8 += 8; a += 8;
|
651
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
652
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
653
|
+
q8 += 8; a += 8;
|
654
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
655
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
656
|
+
q8 += 8; a += 8;
|
657
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
658
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
659
|
+
q8 += 8; a += 8;
|
660
|
+
}
|
661
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
662
|
+
for (int l = 0; l < 8; ++l) sums[l] += d * aux32[l];
|
663
|
+
const float dmin = GGML_CPU_FP16_TO_FP32(x[i].dmin) * y[i].d;
|
664
|
+
sumf -= dmin * sumi;
|
665
|
+
}
|
666
|
+
for (int l = 0; l < 8; ++l) sumf += sums[l];
|
667
|
+
*s = sumf;
|
668
|
+
}
|
669
|
+
|
670
|
+
void ggml_vec_dot_q6_K_q8_K_generic(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) {
|
671
|
+
assert(n % QK_K == 0);
|
672
|
+
assert(nrc == 1);
|
673
|
+
UNUSED(nrc);
|
674
|
+
UNUSED(bx);
|
675
|
+
UNUSED(by);
|
676
|
+
UNUSED(bs);
|
677
|
+
|
678
|
+
const block_q6_K * GGML_RESTRICT x = vx;
|
679
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
680
|
+
|
681
|
+
const int nb = n / QK_K;
|
682
|
+
|
683
|
+
int8_t aux8[QK_K];
|
684
|
+
int16_t aux16[8];
|
685
|
+
float sums [8];
|
686
|
+
int32_t aux32[8];
|
687
|
+
memset(sums, 0, 8*sizeof(float));
|
688
|
+
|
689
|
+
float sumf = 0;
|
690
|
+
for (int i = 0; i < nb; ++i) {
|
691
|
+
const uint8_t * GGML_RESTRICT q4 = x[i].ql;
|
692
|
+
const uint8_t * GGML_RESTRICT qh = x[i].qh;
|
693
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
694
|
+
memset(aux32, 0, 8*sizeof(int32_t));
|
695
|
+
int8_t * GGML_RESTRICT a = aux8;
|
696
|
+
for (int j = 0; j < QK_K; j += 128) {
|
697
|
+
for (int l = 0; l < 32; ++l) {
|
698
|
+
a[l + 0] = (int8_t)((q4[l + 0] & 0xF) | (((qh[l] >> 0) & 3) << 4)) - 32;
|
699
|
+
a[l + 32] = (int8_t)((q4[l + 32] & 0xF) | (((qh[l] >> 2) & 3) << 4)) - 32;
|
700
|
+
a[l + 64] = (int8_t)((q4[l + 0] >> 4) | (((qh[l] >> 4) & 3) << 4)) - 32;
|
701
|
+
a[l + 96] = (int8_t)((q4[l + 32] >> 4) | (((qh[l] >> 6) & 3) << 4)) - 32;
|
702
|
+
}
|
703
|
+
a += 128;
|
704
|
+
q4 += 64;
|
705
|
+
qh += 32;
|
706
|
+
}
|
707
|
+
a = aux8;
|
708
|
+
int is = 0;
|
709
|
+
for (int j = 0; j < QK_K/16; ++j) {
|
710
|
+
int scale = x[i].scales[is++];
|
711
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
712
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
713
|
+
q8 += 8; a += 8;
|
714
|
+
for (int l = 0; l < 8; ++l) aux16[l] = q8[l] * a[l];
|
715
|
+
for (int l = 0; l < 8; ++l) aux32[l] += scale * aux16[l];
|
716
|
+
q8 += 8; a += 8;
|
717
|
+
}
|
718
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
719
|
+
for (int l = 0; l < 8; ++l) sums[l] += d * aux32[l];
|
720
|
+
}
|
721
|
+
for (int l = 0; l < 8; ++l) sumf += sums[l];
|
722
|
+
*s = sumf;
|
723
|
+
}
|
724
|
+
|
725
|
+
void ggml_vec_dot_iq2_xxs_q8_K_generic(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) {
|
726
|
+
assert(n % QK_K == 0);
|
727
|
+
assert(nrc == 1);
|
728
|
+
UNUSED(nrc);
|
729
|
+
UNUSED(bx);
|
730
|
+
UNUSED(by);
|
731
|
+
UNUSED(bs);
|
732
|
+
|
733
|
+
const block_iq2_xxs * GGML_RESTRICT x = vx;
|
734
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
735
|
+
|
736
|
+
const int nb = n / QK_K;
|
737
|
+
|
738
|
+
uint32_t aux32[2];
|
739
|
+
const uint8_t * aux8 = (const uint8_t *)aux32;
|
740
|
+
|
741
|
+
float sumf = 0.f;
|
742
|
+
for (int i = 0; i < nb; ++i) {
|
743
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
744
|
+
const uint16_t * GGML_RESTRICT q2 = x[i].qs;
|
745
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
746
|
+
int32_t bsum = 0;
|
747
|
+
for (int ib32 = 0; ib32 < QK_K/32; ++ib32) {
|
748
|
+
memcpy(aux32, q2, 2*sizeof(uint32_t));
|
749
|
+
q2 += 4;
|
750
|
+
const uint32_t ls = 2*(aux32[1] >> 28) + 1;
|
751
|
+
int32_t sumi = 0;
|
752
|
+
for (int l = 0; l < 4; ++l) {
|
753
|
+
const uint8_t * grid = (const uint8_t *)(iq2xxs_grid + aux8[l]);
|
754
|
+
const uint8_t signs = ksigns_iq2xs[(aux32[1] >> 7*l) & 127];
|
755
|
+
for (int j = 0; j < 8; ++j) {
|
756
|
+
sumi += grid[j] * q8[j] * (signs & kmask_iq2xs[j] ? -1 : 1);
|
757
|
+
}
|
758
|
+
q8 += 8;
|
759
|
+
}
|
760
|
+
bsum += sumi * ls;
|
761
|
+
}
|
762
|
+
sumf += d * bsum;
|
763
|
+
}
|
764
|
+
*s = 0.125f * sumf;
|
765
|
+
}
|
766
|
+
|
767
|
+
void ggml_vec_dot_iq2_xs_q8_K_generic(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) {
|
768
|
+
assert(n % QK_K == 0);
|
769
|
+
assert(nrc == 1);
|
770
|
+
UNUSED(nrc);
|
771
|
+
UNUSED(bx);
|
772
|
+
UNUSED(by);
|
773
|
+
UNUSED(bs);
|
774
|
+
|
775
|
+
const block_iq2_xs * GGML_RESTRICT x = vx;
|
776
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
777
|
+
|
778
|
+
const int nb = n / QK_K;
|
779
|
+
|
780
|
+
float sumf = 0.f;
|
781
|
+
for (int i = 0; i < nb; ++i) {
|
782
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
783
|
+
const uint16_t * GGML_RESTRICT q2 = x[i].qs;
|
784
|
+
const uint8_t * GGML_RESTRICT sc = x[i].scales;
|
785
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
786
|
+
int32_t bsum = 0;
|
787
|
+
for (int ib32 = 0; ib32 < QK_K/32; ++ib32) {
|
788
|
+
const uint16_t ls1 = 2*(sc[ib32] & 0xf) + 1;
|
789
|
+
const uint16_t ls2 = 2*(sc[ib32] >> 4) + 1;
|
790
|
+
int32_t sumi = 0;
|
791
|
+
for (int l = 0; l < 2; ++l) {
|
792
|
+
const uint8_t * grid = (const uint8_t *)(iq2xs_grid + (q2[l] & 511));
|
793
|
+
const uint8_t signs = ksigns_iq2xs[q2[l] >> 9];
|
794
|
+
for (int j = 0; j < 8; ++j) {
|
795
|
+
sumi += grid[j] * q8[j] * (signs & kmask_iq2xs[j] ? -1 : 1);
|
796
|
+
}
|
797
|
+
q8 += 8;
|
798
|
+
}
|
799
|
+
bsum += sumi * ls1;
|
800
|
+
sumi = 0;
|
801
|
+
for (int l = 2; l < 4; ++l) {
|
802
|
+
const uint8_t * grid = (const uint8_t *)(iq2xs_grid + (q2[l] & 511));
|
803
|
+
const uint8_t signs = ksigns_iq2xs[q2[l] >> 9];
|
804
|
+
for (int j = 0; j < 8; ++j) {
|
805
|
+
sumi += grid[j] * q8[j] * (signs & kmask_iq2xs[j] ? -1 : 1);
|
806
|
+
}
|
807
|
+
q8 += 8;
|
808
|
+
}
|
809
|
+
bsum += sumi * ls2;
|
810
|
+
q2 += 4;
|
811
|
+
}
|
812
|
+
sumf += d * bsum;
|
813
|
+
}
|
814
|
+
*s = 0.125f * sumf;
|
815
|
+
}
|
816
|
+
|
817
|
+
void ggml_vec_dot_iq2_s_q8_K_generic(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) {
|
818
|
+
assert(n % QK_K == 0);
|
819
|
+
assert(nrc == 1);
|
820
|
+
UNUSED(nrc);
|
821
|
+
UNUSED(bx);
|
822
|
+
UNUSED(by);
|
823
|
+
UNUSED(bs);
|
824
|
+
|
825
|
+
const block_iq2_s * GGML_RESTRICT x = vx;
|
826
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
827
|
+
|
828
|
+
const int nb = n / QK_K;
|
829
|
+
|
830
|
+
float sumf = 0;
|
831
|
+
for (int i = 0; i < nb; i++) {
|
832
|
+
|
833
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
834
|
+
const int8_t * q8 = y[i].qs;
|
835
|
+
const uint8_t * qs = x[i].qs;
|
836
|
+
const uint8_t * qh = x[i].qh;
|
837
|
+
const uint8_t * signs = qs + QK_K/8;
|
838
|
+
|
839
|
+
int bsum = 0;
|
840
|
+
for (int ib32 = 0; ib32 < QK_K/32; ++ib32) {
|
841
|
+
int ls1 = 1 + 2*(x[i].scales[ib32] & 0xf);
|
842
|
+
int ls2 = 1 + 2*(x[i].scales[ib32] >> 4);
|
843
|
+
int sumi1 = 0, sumi2 = 0;
|
844
|
+
for (int l = 0; l < 2; ++l) {
|
845
|
+
const uint8_t * grid = (const uint8_t *)(iq2s_grid + (qs[l] | (qh[ib32] << (8-2*l) & 0x300)));
|
846
|
+
for (int j = 0; j < 8; ++j) {
|
847
|
+
sumi1 += q8[j] * grid[j] * (signs[l] & kmask_iq2xs[j] ? -1 : 1);
|
848
|
+
}
|
849
|
+
q8 += 8;
|
850
|
+
}
|
851
|
+
for (int l = 2; l < 4; ++l) {
|
852
|
+
const uint8_t * grid = (const uint8_t *)(iq2s_grid + (qs[l] | (qh[ib32] << (8-2*l) & 0x300)));
|
853
|
+
for (int j = 0; j < 8; ++j) {
|
854
|
+
sumi2 += q8[j] * grid[j] * (signs[l] & kmask_iq2xs[j] ? -1 : 1);
|
855
|
+
}
|
856
|
+
q8 += 8;
|
857
|
+
}
|
858
|
+
bsum += ls1 * sumi1 + ls2 * sumi2;
|
859
|
+
qs += 4;
|
860
|
+
signs += 4;
|
861
|
+
}
|
862
|
+
|
863
|
+
sumf += d * bsum;
|
864
|
+
}
|
865
|
+
|
866
|
+
*s = 0.125f * sumf;
|
867
|
+
}
|
868
|
+
|
869
|
+
void ggml_vec_dot_iq3_xxs_q8_K_generic(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) {
|
870
|
+
assert(n % QK_K == 0);
|
871
|
+
assert(nrc == 1);
|
872
|
+
UNUSED(nrc);
|
873
|
+
UNUSED(bx);
|
874
|
+
UNUSED(by);
|
875
|
+
UNUSED(bs);
|
876
|
+
|
877
|
+
const block_iq3_xxs * GGML_RESTRICT x = vx;
|
878
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
879
|
+
|
880
|
+
const int nb = n / QK_K;
|
881
|
+
|
882
|
+
uint32_t aux32;
|
883
|
+
|
884
|
+
float sumf = 0.f;
|
885
|
+
for (int i = 0; i < nb; ++i) {
|
886
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
887
|
+
const uint8_t * GGML_RESTRICT q3 = x[i].qs;
|
888
|
+
const uint8_t * GGML_RESTRICT gas = x[i].qs + QK_K/4;
|
889
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
890
|
+
int32_t bsum = 0;
|
891
|
+
for (int ib32 = 0; ib32 < QK_K/32; ++ib32) {
|
892
|
+
memcpy(&aux32, gas, sizeof(uint32_t)); gas += sizeof(uint32_t);
|
893
|
+
const uint32_t ls = 2*(aux32 >> 28) + 1;
|
894
|
+
int32_t sumi = 0;
|
895
|
+
for (int l = 0; l < 4; ++l) {
|
896
|
+
const uint8_t * grid1 = (const uint8_t *)(iq3xxs_grid + q3[2*l+0]);
|
897
|
+
const uint8_t * grid2 = (const uint8_t *)(iq3xxs_grid + q3[2*l+1]);
|
898
|
+
const uint8_t signs = ksigns_iq2xs[(aux32 >> 7*l) & 127];
|
899
|
+
for (int j = 0; j < 4; ++j) {
|
900
|
+
sumi += grid1[j] * q8[j+0] * (signs & kmask_iq2xs[j+0] ? -1 : 1);
|
901
|
+
sumi += grid2[j] * q8[j+4] * (signs & kmask_iq2xs[j+4] ? -1 : 1);
|
902
|
+
}
|
903
|
+
q8 += 8;
|
904
|
+
}
|
905
|
+
q3 += 8;
|
906
|
+
bsum += sumi * ls;
|
907
|
+
}
|
908
|
+
sumf += d * bsum;
|
909
|
+
}
|
910
|
+
*s = 0.25f * sumf;
|
911
|
+
}
|
912
|
+
|
913
|
+
void ggml_vec_dot_iq3_s_q8_K_generic(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) {
|
914
|
+
assert(n % QK_K == 0);
|
915
|
+
assert(nrc == 1);
|
916
|
+
UNUSED(nrc);
|
917
|
+
UNUSED(bx);
|
918
|
+
UNUSED(by);
|
919
|
+
UNUSED(bs);
|
920
|
+
|
921
|
+
const block_iq3_s * GGML_RESTRICT x = vx;
|
922
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
923
|
+
|
924
|
+
const int nb = n / QK_K;
|
925
|
+
|
926
|
+
float sumf = 0.f;
|
927
|
+
for (int i = 0; i < nb; ++i) {
|
928
|
+
const float d = GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d;
|
929
|
+
const uint8_t * GGML_RESTRICT qs = x[i].qs;
|
930
|
+
const uint8_t * GGML_RESTRICT qh = x[i].qh;
|
931
|
+
const uint8_t * GGML_RESTRICT signs = x[i].signs;
|
932
|
+
const int8_t * GGML_RESTRICT q8 = y[i].qs;
|
933
|
+
int32_t bsum = 0;
|
934
|
+
for (int ib32 = 0; ib32 < QK_K/32; ib32 += 2) {
|
935
|
+
const uint32_t ls1 = 2*(x[i].scales[ib32/2] & 0xf) + 1;
|
936
|
+
const uint32_t ls2 = 2*(x[i].scales[ib32/2] >> 4) + 1;
|
937
|
+
int32_t sumi = 0;
|
938
|
+
for (int l = 0; l < 4; ++l) {
|
939
|
+
const uint8_t * grid1 = (const uint8_t *)(iq3s_grid + (qs[2*l+0] | ((qh[ib32+0] << (8-2*l)) & 256)));
|
940
|
+
const uint8_t * grid2 = (const uint8_t *)(iq3s_grid + (qs[2*l+1] | ((qh[ib32+0] << (7-2*l)) & 256)));
|
941
|
+
for (int j = 0; j < 4; ++j) {
|
942
|
+
sumi += grid1[j] * q8[j+0] * (signs[l] & kmask_iq2xs[j+0] ? -1 : 1);
|
943
|
+
sumi += grid2[j] * q8[j+4] * (signs[l] & kmask_iq2xs[j+4] ? -1 : 1);
|
944
|
+
}
|
945
|
+
q8 += 8;
|
946
|
+
}
|
947
|
+
qs += 8;
|
948
|
+
signs += 4;
|
949
|
+
bsum += sumi * ls1;
|
950
|
+
sumi = 0;
|
951
|
+
for (int l = 0; l < 4; ++l) {
|
952
|
+
const uint8_t * grid1 = (const uint8_t *)(iq3s_grid + (qs[2*l+0] | ((qh[ib32+1] << (8-2*l)) & 256)));
|
953
|
+
const uint8_t * grid2 = (const uint8_t *)(iq3s_grid + (qs[2*l+1] | ((qh[ib32+1] << (7-2*l)) & 256)));
|
954
|
+
for (int j = 0; j < 4; ++j) {
|
955
|
+
sumi += grid1[j] * q8[j+0] * (signs[l] & kmask_iq2xs[j+0] ? -1 : 1);
|
956
|
+
sumi += grid2[j] * q8[j+4] * (signs[l] & kmask_iq2xs[j+4] ? -1 : 1);
|
957
|
+
}
|
958
|
+
q8 += 8;
|
959
|
+
}
|
960
|
+
qs += 8;
|
961
|
+
signs += 4;
|
962
|
+
bsum += sumi * ls2;
|
963
|
+
}
|
964
|
+
sumf += d * bsum;
|
965
|
+
}
|
966
|
+
*s = sumf;
|
967
|
+
}
|
968
|
+
|
969
|
+
void ggml_vec_dot_iq1_s_q8_K_generic(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) {
|
970
|
+
assert(n % QK_K == 0);
|
971
|
+
assert(nrc == 1);
|
972
|
+
UNUSED(nrc);
|
973
|
+
UNUSED(bx);
|
974
|
+
UNUSED(by);
|
975
|
+
UNUSED(bs);
|
976
|
+
|
977
|
+
const block_iq1_s * GGML_RESTRICT x = vx;
|
978
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
979
|
+
|
980
|
+
const int nb = n / QK_K;
|
981
|
+
|
982
|
+
float sumf = 0;
|
983
|
+
for (int i = 0; i < nb; i++) {
|
984
|
+
|
985
|
+
const int8_t * q8 = y[i].qs;
|
986
|
+
const uint8_t * qs = x[i].qs;
|
987
|
+
const uint16_t * qh = x[i].qh;
|
988
|
+
|
989
|
+
int sumi = 0, sumi1 = 0;
|
990
|
+
for (int ib = 0; ib < QK_K/32; ++ib) {
|
991
|
+
const int ls = 2*((qh[ib] >> 12) & 7) + 1;
|
992
|
+
const int delta = qh[ib] & 0x8000 ? -1 : 1;
|
993
|
+
int lsum = 0;
|
994
|
+
for (int l = 0; l < 4; ++l) {
|
995
|
+
const int8_t * grid = (const int8_t *)(iq1s_grid + (qs[l] | (((qh[ib] >> 3*l) & 7) << 8)));
|
996
|
+
for (int j = 0; j < 8; ++j) {
|
997
|
+
lsum += q8[j] * grid[j];
|
998
|
+
}
|
999
|
+
q8 += 8;
|
1000
|
+
}
|
1001
|
+
sumi += ls * lsum;
|
1002
|
+
sumi1 += ls * delta * (y[i].bsums[2*ib+0] + y[i].bsums[2*ib+1]);
|
1003
|
+
qs += 4;
|
1004
|
+
}
|
1005
|
+
|
1006
|
+
sumf += GGML_CPU_FP16_TO_FP32(x[i].d) * y[i].d * (sumi + IQ1S_DELTA * sumi1);
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
*s = sumf;
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
void ggml_vec_dot_iq1_m_q8_K_generic(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) {
|
1013
|
+
assert(n % QK_K == 0);
|
1014
|
+
assert(nrc == 1);
|
1015
|
+
UNUSED(nrc);
|
1016
|
+
UNUSED(bx);
|
1017
|
+
UNUSED(by);
|
1018
|
+
UNUSED(bs);
|
1019
|
+
|
1020
|
+
const block_iq1_m * GGML_RESTRICT x = vx;
|
1021
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
1022
|
+
|
1023
|
+
const int nb = n / QK_K;
|
1024
|
+
|
1025
|
+
iq1m_scale_t scale;
|
1026
|
+
|
1027
|
+
int sum1[2], sum2[2], delta[4];
|
1028
|
+
|
1029
|
+
float sumf = 0;
|
1030
|
+
for (int i = 0; i < nb; i++) {
|
1031
|
+
|
1032
|
+
const int8_t * q8 = y[i].qs;
|
1033
|
+
const uint8_t * qs = x[i].qs;
|
1034
|
+
const uint8_t * qh = x[i].qh;
|
1035
|
+
const uint16_t * sc = (const uint16_t *)x[i].scales;
|
1036
|
+
|
1037
|
+
scale.u16 = (sc[0] >> 12) | ((sc[1] >> 8) & 0x00f0) | ((sc[2] >> 4) & 0x0f00) | (sc[3] & 0xf000);
|
1038
|
+
|
1039
|
+
int sumi1 = 0, sumi2 = 0;
|
1040
|
+
for (int ib = 0; ib < QK_K/32; ++ib) {
|
1041
|
+
delta[0] = qh[0] & 0x08 ? -1 : 1;
|
1042
|
+
delta[1] = qh[0] & 0x80 ? -1 : 1;
|
1043
|
+
delta[2] = qh[1] & 0x08 ? -1 : 1;
|
1044
|
+
delta[3] = qh[1] & 0x80 ? -1 : 1;
|
1045
|
+
sum1[0] = sum1[1] = sum2[0] = sum2[1] = 0;
|
1046
|
+
for (int l = 0; l < 4; ++l) {
|
1047
|
+
const int8_t * grid = (const int8_t *)(iq1s_grid + (qs[l] | (((uint16_t)qh[l/2] << (8 - 4*(l%2))) & 0x700)));
|
1048
|
+
int lsum1 = 0, lsum2 = 0;
|
1049
|
+
for (int j = 0; j < 8; ++j) {
|
1050
|
+
lsum1 += q8[j] * grid[j];
|
1051
|
+
lsum2 += q8[j];
|
1052
|
+
}
|
1053
|
+
q8 += 8;
|
1054
|
+
sum1[l/2] += lsum1;
|
1055
|
+
sum2[l/2] += lsum2*delta[l];
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
const int ls1 = 2*((sc[ib/2] >> (6*(ib%2)+0)) & 0x7) + 1;
|
1059
|
+
const int ls2 = 2*((sc[ib/2] >> (6*(ib%2)+3)) & 0x7) + 1;
|
1060
|
+
|
1061
|
+
sumi1 += sum1[0] * ls1 + sum1[1] * ls2;
|
1062
|
+
sumi2 += sum2[0] * ls1 + sum2[1] * ls2;
|
1063
|
+
qs += 4;
|
1064
|
+
qh += 2;
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
sumf += GGML_CPU_FP16_TO_FP32(scale.f16) * y[i].d * (sumi1 + IQ1M_DELTA * sumi2);
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
*s = sumf;
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
void ggml_vec_dot_iq4_nl_q8_0_generic(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) {
|
1074
|
+
assert(nrc == 1);
|
1075
|
+
UNUSED(nrc);
|
1076
|
+
UNUSED(bx);
|
1077
|
+
UNUSED(by);
|
1078
|
+
UNUSED(bs);
|
1079
|
+
assert(n % QK4_NL == 0);
|
1080
|
+
static_assert(QK4_NL == QK8_0, "QK4_NL and QK8_0 must be the same");
|
1081
|
+
|
1082
|
+
const block_iq4_nl * GGML_RESTRICT x = vx;
|
1083
|
+
const block_q8_0 * GGML_RESTRICT y = vy;
|
1084
|
+
|
1085
|
+
const int nb = n / QK4_NL;
|
1086
|
+
|
1087
|
+
int ib = 0;
|
1088
|
+
float sumf = 0;
|
1089
|
+
|
1090
|
+
for (; ib < nb; ++ib) {
|
1091
|
+
const float d = GGML_CPU_FP16_TO_FP32(y[ib].d)*GGML_CPU_FP16_TO_FP32(x[ib].d);
|
1092
|
+
int sumi1 = 0, sumi2 = 0;
|
1093
|
+
for (int j = 0; j < QK4_NL/2; ++j) {
|
1094
|
+
sumi1 += y[ib].qs[j+ 0] * kvalues_iq4nl[x[ib].qs[j] & 0xf];
|
1095
|
+
sumi2 += y[ib].qs[j+QK4_NL/2] * kvalues_iq4nl[x[ib].qs[j] >> 4];
|
1096
|
+
}
|
1097
|
+
sumf += d * (sumi1 + sumi2);
|
1098
|
+
}
|
1099
|
+
*s = sumf;
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
void ggml_vec_dot_iq4_xs_q8_K_generic(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) {
|
1103
|
+
assert(nrc == 1);
|
1104
|
+
UNUSED(nrc);
|
1105
|
+
UNUSED(bx);
|
1106
|
+
UNUSED(by);
|
1107
|
+
UNUSED(bs);
|
1108
|
+
assert(n % QK_K == 0);
|
1109
|
+
|
1110
|
+
const block_iq4_xs * GGML_RESTRICT x = vx;
|
1111
|
+
const block_q8_K * GGML_RESTRICT y = vy;
|
1112
|
+
|
1113
|
+
const int nb = n / QK_K;
|
1114
|
+
|
1115
|
+
float sumf = 0;
|
1116
|
+
for (int ibl = 0; ibl < nb; ++ibl) {
|
1117
|
+
const float d4d8 = GGML_CPU_FP16_TO_FP32(x[ibl].d) * y[ibl].d;
|
1118
|
+
uint16_t h = x[ibl].scales_h;
|
1119
|
+
const uint8_t * qs = x[ibl].qs;
|
1120
|
+
const int8_t * q8 = y[ibl].qs;
|
1121
|
+
for (int ib = 0; ib < QK_K/32; ib += 2) {
|
1122
|
+
const uint8_t ls1 = (x[ibl].scales_l[ib/2] & 0xf) | ((h << 4) & 0x30);
|
1123
|
+
const uint8_t ls2 = (x[ibl].scales_l[ib/2] >> 4) | ((h << 2) & 0x30);
|
1124
|
+
h >>= 4;
|
1125
|
+
const float d1 = d4d8*(ls1 - 32);
|
1126
|
+
const float d2 = d4d8*(ls2 - 32);
|
1127
|
+
int sumi1 = 0, sumi2 = 0;
|
1128
|
+
for (int j = 0; j < 16; ++j) {
|
1129
|
+
sumi1 += q8[j+ 0] * kvalues_iq4nl[qs[j] & 0xf];
|
1130
|
+
sumi2 += q8[j+16] * kvalues_iq4nl[qs[j] >> 4];
|
1131
|
+
}
|
1132
|
+
sumf += d1 * (sumi1 + sumi2);
|
1133
|
+
qs += 16;
|
1134
|
+
q8 += 32;
|
1135
|
+
sumi1 = sumi2 = 0;
|
1136
|
+
for (int j = 0; j < 16; ++j) {
|
1137
|
+
sumi1 += q8[j+ 0] * kvalues_iq4nl[qs[j] & 0xf];
|
1138
|
+
sumi2 += q8[j+16] * kvalues_iq4nl[qs[j] >> 4];
|
1139
|
+
}
|
1140
|
+
sumf += d2 * (sumi1 + sumi2);
|
1141
|
+
qs += 16;
|
1142
|
+
q8 += 32;
|
1143
|
+
}
|
1144
|
+
}
|
1145
|
+
*s = sumf;
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
// ============================ 4-bit non-linear quants
|
1149
|
+
|
1150
|
+
void quantize_row_iq4_nl(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
1151
|
+
assert(k % QK4_NL == 0);
|
1152
|
+
quantize_row_iq4_nl_ref(x, y, k);
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
void quantize_row_iq4_xs(const float * GGML_RESTRICT x, void * GGML_RESTRICT y, int64_t k) {
|
1156
|
+
assert(k % QK_K == 0);
|
1157
|
+
quantize_iq4_xs(x, y, 1, k, NULL);
|
1158
|
+
}
|