@novastera-oss/llamarn 0.2.7 → 0.3.0
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.
- package/android/src/main/cpp/include/llama.h +8 -3
- package/android/src/main/jniLibs/arm64-v8a/libggml-base.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libllama.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libggml-base.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libggml.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libllama.so +0 -0
- package/android/src/main/jniLibs/x86/libggml-base.so +0 -0
- package/android/src/main/jniLibs/x86/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/x86/libggml.so +0 -0
- package/android/src/main/jniLibs/x86/libllama.so +0 -0
- package/android/src/main/jniLibs/x86_64/libggml-base.so +0 -0
- package/android/src/main/jniLibs/x86_64/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/x86_64/libggml.so +0 -0
- package/android/src/main/jniLibs/x86_64/libllama.so +0 -0
- package/cpp/LlamaCppModel.cpp +56 -22
- package/cpp/build-info.cpp +2 -2
- package/cpp/llama.cpp/CMakeLists.txt +1 -2
- package/cpp/llama.cpp/README.md +4 -5
- package/cpp/llama.cpp/build-xcframework.sh +1 -1
- package/cpp/llama.cpp/common/CMakeLists.txt +4 -5
- package/cpp/llama.cpp/common/arg.cpp +24 -0
- package/cpp/llama.cpp/common/chat.cpp +37 -20
- package/cpp/llama.cpp/common/chat.h +2 -0
- package/cpp/llama.cpp/common/common.cpp +3 -0
- package/cpp/llama.cpp/common/common.h +5 -0
- package/cpp/llama.cpp/common/json-schema-to-grammar.cpp +3 -46
- package/cpp/llama.cpp/convert_hf_to_gguf.py +860 -23
- package/cpp/llama.cpp/convert_hf_to_gguf_update.py +9 -0
- package/cpp/llama.cpp/ggml/CMakeLists.txt +8 -2
- package/cpp/llama.cpp/ggml/include/ggml-backend.h +1 -1
- package/cpp/llama.cpp/ggml/include/ggml-cpu.h +2 -0
- package/cpp/llama.cpp/ggml/include/ggml.h +206 -10
- package/cpp/llama.cpp/ggml/src/CMakeLists.txt +17 -1
- package/cpp/llama.cpp/ggml/src/ggml-backend-reg.cpp +0 -8
- package/cpp/llama.cpp/ggml/src/ggml-backend.cpp +36 -18
- package/cpp/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +68 -5
- package/cpp/llama.cpp/ggml/src/ggml-cann/common.h +1 -1
- package/cpp/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +16 -2
- package/cpp/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +37 -3
- package/cpp/llama.cpp/ggml/src/ggml-cpu/amx/mmq.cpp +10 -9
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/arm/quants.c +109 -108
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/arm/repack.cpp +1027 -1038
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/loongarch/quants.c +53 -52
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/powerpc/cpu-feats.cpp +82 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/powerpc/quants.c +56 -55
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/riscv/quants.c +42 -41
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/riscv/repack.cpp +24 -23
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/s390/quants.c +29 -28
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/wasm/quants.c +30 -29
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/x86/quants.c +83 -82
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/x86/repack.cpp +20 -19
- package/cpp/llama.cpp/ggml/src/ggml-cpu/common.h +3 -2
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-impl.h +9 -3
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +111 -103
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +4 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/llamafile/sgemm.cpp +3 -2
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ops.cpp +1405 -240
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ops.h +8 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/quants.c +25 -24
- package/cpp/llama.cpp/ggml/src/ggml-cpu/repack.cpp +56 -40
- package/cpp/llama.cpp/ggml/src/ggml-cpu/simd-mappings.h +212 -34
- package/cpp/llama.cpp/ggml/src/ggml-cpu/vec.cpp +35 -11
- package/cpp/llama.cpp/ggml/src/ggml-cpu/vec.h +187 -54
- package/cpp/llama.cpp/ggml/src/ggml-cuda/common.cuh +71 -29
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv2d-dw.cu +161 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv2d-dw.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv2d-transpose.cu +91 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv2d-transpose.cuh +4 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/convert.cu +22 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/convert.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/cross-entropy-loss.cu +2 -14
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-common.cuh +4 -1
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-mma-f16.cuh +8 -4
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-tile-f16.cu +6 -4
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-tile-f32.cu +14 -12
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-vec-f16.cuh +5 -3
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-vec-f32.cuh +15 -10
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-wmma-f16.cu +12 -6
- package/cpp/llama.cpp/ggml/src/ggml-cuda/getrows.cu +8 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu +269 -110
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mean.cu +19 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mean.cuh +3 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmq.cuh +2 -8
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmv.cu +257 -87
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmv.cuh +2 -3
- package/cpp/llama.cpp/ggml/src/ggml-cuda/rope.cu +21 -27
- package/cpp/llama.cpp/ggml/src/ggml-cuda/scale.cu +8 -6
- package/cpp/llama.cpp/ggml/src/ggml-cuda/softmax.cu +119 -58
- package/cpp/llama.cpp/ggml/src/ggml-cuda/ssm-conv.cu +10 -2
- package/cpp/llama.cpp/ggml/src/ggml-cuda/ssm-scan.cu +192 -52
- package/cpp/llama.cpp/ggml/src/ggml-cuda/sumrows.cu +5 -18
- package/cpp/llama.cpp/ggml/src/ggml-cuda/sumrows.cuh +0 -1
- package/cpp/llama.cpp/ggml/src/ggml-cuda/unary.cu +97 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/unary.cuh +11 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/upscale.cu +92 -6
- package/cpp/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +14 -5
- package/cpp/llama.cpp/ggml/src/ggml-impl.h +125 -183
- package/cpp/llama.cpp/ggml/src/ggml-metal/CMakeLists.txt +4 -2
- package/cpp/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +51 -9
- package/cpp/llama.cpp/ggml/src/ggml-metal/ggml-metal.m +394 -80
- package/cpp/llama.cpp/ggml/src/ggml-metal/ggml-metal.metal +616 -239
- package/cpp/llama.cpp/ggml/src/ggml-musa/mudnn.cuh +2 -2
- package/cpp/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +3 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +741 -571
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/gelu.cl +27 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/glu.cl +337 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/mul_mat_f16_f32.cl +130 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/scale.cl +3 -2
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/set_rows.cl +95 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_4_f16.cl +24 -11
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_4_f32.cl +24 -11
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_f16.cl +24 -11
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_f32.cl +24 -11
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/upscale.cl +2 -3
- package/cpp/llama.cpp/ggml/src/ggml-quants.c +6 -6
- package/cpp/llama.cpp/ggml/src/ggml-sycl/backend.hpp +1 -0
- package/cpp/llama.cpp/ggml/src/ggml-sycl/binbcast.cpp +5 -6
- package/cpp/llama.cpp/ggml/src/ggml-sycl/common.hpp +1 -24
- package/cpp/llama.cpp/ggml/src/ggml-sycl/concat.cpp +28 -41
- package/cpp/llama.cpp/ggml/src/ggml-sycl/conv.cpp +4 -10
- package/cpp/llama.cpp/ggml/src/ggml-sycl/convert.cpp +99 -166
- package/cpp/llama.cpp/ggml/src/ggml-sycl/cpy.cpp +94 -72
- package/cpp/llama.cpp/ggml/src/ggml-sycl/dmmv.cpp +49 -67
- package/cpp/llama.cpp/ggml/src/ggml-sycl/dpct/helper.hpp +31 -1
- package/cpp/llama.cpp/ggml/src/ggml-sycl/element_wise.cpp +697 -1098
- package/cpp/llama.cpp/ggml/src/ggml-sycl/element_wise.hpp +18 -9
- package/cpp/llama.cpp/ggml/src/ggml-sycl/getrows.cpp +6 -9
- package/cpp/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +104 -62
- package/cpp/llama.cpp/ggml/src/ggml-sycl/gla.cpp +2 -2
- package/cpp/llama.cpp/ggml/src/ggml-sycl/im2col.cpp +1 -1
- package/cpp/llama.cpp/ggml/src/ggml-sycl/mmq.cpp +60 -80
- package/cpp/llama.cpp/ggml/src/ggml-sycl/mmvq.cpp +132 -201
- package/cpp/llama.cpp/ggml/src/ggml-sycl/norm.cpp +55 -74
- package/cpp/llama.cpp/ggml/src/ggml-sycl/rope.cpp +39 -38
- package/cpp/llama.cpp/ggml/src/ggml-sycl/set_rows.cpp +131 -0
- package/cpp/llama.cpp/ggml/src/ggml-sycl/set_rows.hpp +8 -0
- package/cpp/llama.cpp/ggml/src/ggml-sycl/softmax.cpp +3 -3
- package/cpp/llama.cpp/ggml/src/ggml-sycl/sycl_hw.cpp +3 -1
- package/cpp/llama.cpp/ggml/src/ggml-sycl/sycl_hw.hpp +3 -0
- package/cpp/llama.cpp/ggml/src/ggml-sycl/tsembd.cpp +3 -8
- package/cpp/llama.cpp/ggml/src/ggml-sycl/wkv.cpp +12 -16
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/CMakeLists.txt +12 -1
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +767 -292
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt +4 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/copy_to_quant.comp +58 -7
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +28 -23
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_base.comp +14 -9
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +38 -32
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp +32 -27
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_split_k_reduce.comp +44 -12
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/geglu.comp +13 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/geglu_erf.comp +27 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/geglu_quick.comp +11 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp +39 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.comp +15 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/glu_main.comp +29 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +128 -72
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +38 -9
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/reglu.comp +9 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +12 -3
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/roll.comp +46 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_multi.comp +7 -9
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_neox.comp +7 -9
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rope_norm.comp +7 -9
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/scale.comp +1 -1
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp +20 -4
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/swiglu.comp +9 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/upscale.comp +69 -5
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +23 -3
- package/cpp/llama.cpp/ggml/src/ggml.c +449 -72
- package/cpp/llama.cpp/ggml/src/gguf.cpp +13 -2
- package/cpp/llama.cpp/gguf-py/gguf/constants.py +285 -0
- package/cpp/llama.cpp/gguf-py/gguf/gguf_writer.py +27 -0
- package/cpp/llama.cpp/gguf-py/gguf/tensor_mapping.py +137 -21
- package/cpp/llama.cpp/gguf-py/gguf/vocab.py +109 -7
- package/cpp/llama.cpp/gguf-py/pyproject.toml +2 -2
- package/cpp/llama.cpp/include/llama.h +8 -43
- package/cpp/llama.cpp/models/templates/Mistral-Small-3.2-24B-Instruct-2506.jinja +124 -0
- package/cpp/llama.cpp/src/llama-arch.cpp +265 -3
- package/cpp/llama.cpp/src/llama-arch.h +36 -1
- package/cpp/llama.cpp/src/llama-batch.cpp +596 -359
- package/cpp/llama.cpp/src/llama-batch.h +105 -70
- package/cpp/llama.cpp/src/llama-chat.cpp +26 -6
- package/cpp/llama.cpp/src/llama-chat.h +1 -0
- package/cpp/llama.cpp/src/llama-context.cpp +101 -107
- package/cpp/llama.cpp/src/llama-context.h +13 -13
- package/cpp/llama.cpp/src/llama-graph.cpp +286 -404
- package/cpp/llama.cpp/src/llama-graph.h +78 -79
- package/cpp/llama.cpp/src/llama-hparams.cpp +11 -1
- package/cpp/llama.cpp/src/llama-hparams.h +11 -0
- package/cpp/llama.cpp/src/llama-kv-cache-unified-iswa.cpp +74 -66
- package/cpp/llama.cpp/src/llama-kv-cache-unified-iswa.h +23 -26
- package/cpp/llama.cpp/src/llama-kv-cache-unified.cpp +312 -157
- package/cpp/llama.cpp/src/llama-kv-cache-unified.h +79 -46
- package/cpp/llama.cpp/src/llama-kv-cells.h +97 -21
- package/cpp/llama.cpp/src/llama-memory-hybrid.cpp +73 -69
- package/cpp/llama.cpp/src/llama-memory-hybrid.h +19 -22
- package/cpp/llama.cpp/src/llama-memory-recurrent.cpp +88 -77
- package/cpp/llama.cpp/src/llama-memory-recurrent.h +15 -20
- package/cpp/llama.cpp/src/llama-memory.cpp +17 -0
- package/cpp/llama.cpp/src/llama-memory.h +21 -22
- package/cpp/llama.cpp/src/llama-model-saver.cpp +1 -0
- package/cpp/llama.cpp/src/llama-model.cpp +5301 -2922
- package/cpp/llama.cpp/src/llama-model.h +40 -0
- package/cpp/llama.cpp/src/llama-quant.cpp +88 -5
- package/cpp/llama.cpp/src/llama-vocab.cpp +37 -3
- package/cpp/llama.cpp/src/llama-vocab.h +42 -0
- package/cpp/rn-utils.h +3 -0
- package/ios/include/chat.h +2 -0
- package/ios/include/common.h +5 -0
- package/ios/include/llama.h +8 -43
- package/ios/libs/llama.xcframework/Info.plist +19 -19
- package/ios/libs/llama.xcframework/ios-arm64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/ios-arm64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5059 -4863
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5030 -4834
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +3889 -3742
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5030 -4834
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +3891 -3744
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5059 -4863
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5030 -4834
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +3889 -3742
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5095 -4900
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5066 -4871
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +3919 -3773
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/ggml-backend.h +1 -1
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/ggml-cpu.h +2 -0
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/ggml.h +206 -10
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/llama.h +8 -43
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/llama +0 -0
- package/package.json +1 -1
- package/cpp/llama.cpp/ggml/include/ggml-kompute.h +0 -50
- package/cpp/llama.cpp/ggml/src/ggml-kompute/CMakeLists.txt +0 -166
- package/cpp/llama.cpp/ggml/src/ggml-kompute/ggml-kompute.cpp +0 -2251
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/common.comp +0 -112
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_add.comp +0 -58
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_addrow.comp +0 -25
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f16_f16.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f16_f32.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f32_f16.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_cpy_f32_f32.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_diagmask.comp +0 -30
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_gelu.comp +0 -22
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows.comp +0 -17
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_f16.comp +0 -31
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_f32.comp +0 -31
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q4_0.comp +0 -38
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q4_1.comp +0 -39
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_getrows_q6_k.comp +0 -44
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_f16.comp +0 -69
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_mat_f32.comp +0 -51
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_0.comp +0 -33
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_1.comp +0 -35
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q4_k.comp +0 -140
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q6_k.comp +0 -106
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mat_q8_0.comp +0 -73
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mv_q_n.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_mul_mv_q_n_pre.comp +0 -28
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_norm.comp +0 -84
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_relu.comp +0 -21
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rmsnorm.comp +0 -53
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_neox_f16.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_neox_f32.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_norm_f16.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_rope_norm_f32.comp +0 -52
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_scale.comp +0 -19
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_scale_8.comp +0 -23
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_silu.comp +0 -22
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/op_softmax.comp +0 -72
- package/cpp/llama.cpp/ggml/src/ggml-kompute/kompute-shaders/rope_common.comp +0 -71
|
@@ -2,10 +2,167 @@
|
|
|
2
2
|
|
|
3
3
|
#include "ggml-cpu-impl.h"
|
|
4
4
|
|
|
5
|
+
#ifdef __ARM_FEATURE_SVE
|
|
6
|
+
#include <arm_sve.h>
|
|
7
|
+
#endif // __ARM_FEATURE_SVE
|
|
8
|
+
|
|
9
|
+
#if defined(__ARM_NEON) && !defined(__CUDACC__) && !defined(__MUSACC__)
|
|
10
|
+
// if YCM cannot find <arm_neon.h>, make a symbolic link to it, for example:
|
|
11
|
+
//
|
|
12
|
+
// $ ln -sfn /Library/Developer/CommandLineTools/usr/lib/clang/13.1.6/include/arm_neon.h ./src/
|
|
13
|
+
//
|
|
14
|
+
#include <arm_neon.h>
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
#if defined(__F16C__)
|
|
18
|
+
#include <immintrin.h>
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
extern "C" {
|
|
23
|
+
#endif
|
|
24
|
+
|
|
5
25
|
//
|
|
6
26
|
// simd mappings
|
|
7
27
|
//
|
|
8
28
|
|
|
29
|
+
// FP16 to FP32 conversion
|
|
30
|
+
|
|
31
|
+
// 16-bit float
|
|
32
|
+
// on Arm, we use __fp16
|
|
33
|
+
// on x86, we use uint16_t
|
|
34
|
+
//
|
|
35
|
+
// for old CUDA compilers (<= 11), we use uint16_t: ref https://github.com/ggml-org/llama.cpp/pull/10616
|
|
36
|
+
// for MUSA compilers , we use uint16_t: ref https://github.com/ggml-org/llama.cpp/pull/11843
|
|
37
|
+
//
|
|
38
|
+
#if defined(__ARM_NEON) && !(defined(__CUDACC__) && __CUDACC_VER_MAJOR__ <= 11) && !defined(__MUSACC__)
|
|
39
|
+
#define GGML_CPU_COMPUTE_FP16_TO_FP32(x) neon_compute_fp16_to_fp32(x)
|
|
40
|
+
#define GGML_CPU_COMPUTE_FP32_TO_FP16(x) neon_compute_fp32_to_fp16(x)
|
|
41
|
+
|
|
42
|
+
#define GGML_CPU_FP16_TO_FP32(x) GGML_CPU_COMPUTE_FP16_TO_FP32(x)
|
|
43
|
+
|
|
44
|
+
static inline float neon_compute_fp16_to_fp32(ggml_fp16_t h) {
|
|
45
|
+
__fp16 tmp;
|
|
46
|
+
memcpy(&tmp, &h, sizeof(ggml_fp16_t));
|
|
47
|
+
return (float)tmp;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static inline ggml_fp16_t neon_compute_fp32_to_fp16(float f) {
|
|
51
|
+
ggml_fp16_t res;
|
|
52
|
+
__fp16 tmp = f;
|
|
53
|
+
memcpy(&res, &tmp, sizeof(ggml_fp16_t));
|
|
54
|
+
return res;
|
|
55
|
+
}
|
|
56
|
+
#elif defined(__F16C__)
|
|
57
|
+
#ifdef _MSC_VER
|
|
58
|
+
#define GGML_CPU_COMPUTE_FP16_TO_FP32(x) _mm_cvtss_f32(_mm_cvtph_ps(_mm_cvtsi32_si128(x)))
|
|
59
|
+
#define GGML_CPU_COMPUTE_FP32_TO_FP16(x) _mm_extract_epi16(_mm_cvtps_ph(_mm_set_ss(x), 0), 0)
|
|
60
|
+
#else
|
|
61
|
+
#define GGML_CPU_COMPUTE_FP16_TO_FP32(x) _cvtsh_ss(x)
|
|
62
|
+
#define GGML_CPU_COMPUTE_FP32_TO_FP16(x) _cvtss_sh(x, 0)
|
|
63
|
+
#endif
|
|
64
|
+
#elif defined(__POWER9_VECTOR__)
|
|
65
|
+
#define GGML_CPU_COMPUTE_FP16_TO_FP32(x) power_compute_fp16_to_fp32(x)
|
|
66
|
+
#define GGML_CPU_COMPUTE_FP32_TO_FP16(x) power_compute_fp32_to_fp16(x)
|
|
67
|
+
/* the inline asm below is about 12% faster than the lookup method */
|
|
68
|
+
#define GGML_CPU_FP16_TO_FP32(x) GGML_CPU_COMPUTE_FP16_TO_FP32(x)
|
|
69
|
+
#define GGML_CPU_FP32_TO_FP16(x) GGML_CPU_COMPUTE_FP32_TO_FP16(x)
|
|
70
|
+
|
|
71
|
+
static inline float power_compute_fp16_to_fp32(ggml_fp16_t h) {
|
|
72
|
+
float f;
|
|
73
|
+
double d;
|
|
74
|
+
__asm__(
|
|
75
|
+
"mtfprd %0,%2\n"
|
|
76
|
+
"xscvhpdp %0,%0\n"
|
|
77
|
+
"frsp %1,%0\n" :
|
|
78
|
+
/* temp */ "=d"(d),
|
|
79
|
+
/* out */ "=f"(f):
|
|
80
|
+
/* in */ "r"(h));
|
|
81
|
+
return f;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static inline ggml_fp16_t power_compute_fp32_to_fp16(float f) {
|
|
85
|
+
double d;
|
|
86
|
+
ggml_fp16_t r;
|
|
87
|
+
__asm__( /* xscvdphp can work on double or single precision */
|
|
88
|
+
"xscvdphp %0,%2\n"
|
|
89
|
+
"mffprd %1,%0\n" :
|
|
90
|
+
/* temp */ "=d"(d),
|
|
91
|
+
/* out */ "=r"(r):
|
|
92
|
+
/* in */ "f"(f));
|
|
93
|
+
return r;
|
|
94
|
+
}
|
|
95
|
+
#elif defined(__riscv) && defined(__riscv_zfhmin)
|
|
96
|
+
static inline float riscv_compute_fp16_to_fp32(ggml_fp16_t h) {
|
|
97
|
+
float f;
|
|
98
|
+
__asm__(
|
|
99
|
+
"fmv.h.x %[f], %[h]\n\t"
|
|
100
|
+
"fcvt.s.h %[f], %[f]"
|
|
101
|
+
: [f] "=&f" (f)
|
|
102
|
+
: [h] "r" (h)
|
|
103
|
+
);
|
|
104
|
+
return f;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static inline ggml_fp16_t riscv_compute_fp32_to_fp16(float f) {
|
|
108
|
+
ggml_fp16_t res;
|
|
109
|
+
__asm__(
|
|
110
|
+
"fcvt.h.s %[f], %[f]\n\t"
|
|
111
|
+
"fmv.x.h %[h], %[f]"
|
|
112
|
+
: [h] "=&r" (res)
|
|
113
|
+
: [f] "f" (f)
|
|
114
|
+
);
|
|
115
|
+
return res;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#define GGML_CPU_COMPUTE_FP16_TO_FP32(x) riscv_compute_fp16_to_fp32(x)
|
|
119
|
+
#define GGML_CPU_COMPUTE_FP32_TO_FP16(x) riscv_compute_fp32_to_fp16(x)
|
|
120
|
+
#define GGML_CPU_FP16_TO_FP32(x) GGML_CPU_COMPUTE_FP16_TO_FP32(x)
|
|
121
|
+
#define GGML_CPU_FP32_TO_FP16(x) GGML_CPU_COMPUTE_FP32_TO_FP16(x)
|
|
122
|
+
#elif defined(__NNPA__)
|
|
123
|
+
#define GGML_CPU_COMPUTE_FP16_TO_FP32(x) nnpa_compute_fp16_to_fp32(x)
|
|
124
|
+
#define GGML_CPU_COMPUTE_FP32_TO_FP16(x) nnpa_compute_fp32_to_fp16(x)
|
|
125
|
+
|
|
126
|
+
#define GGML_CPU_FP16_TO_FP32(x) GGML_CPU_COMPUTE_FP16_TO_FP32(x)
|
|
127
|
+
#define GGML_CPU_FP32_TO_FP16(x) GGML_CPU_COMPUTE_FP32_TO_FP16(x)
|
|
128
|
+
|
|
129
|
+
static inline float nnpa_compute_fp16_to_fp32(ggml_fp16_t h) {
|
|
130
|
+
uint16x8_t v_h = vec_splats(h);
|
|
131
|
+
uint16x8_t v_hd = vec_convert_from_fp16(v_h, 0);
|
|
132
|
+
return vec_extend_to_fp32_hi(v_hd, 0)[0];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
static inline ggml_fp16_t nnpa_compute_fp32_to_fp16(float f) {
|
|
136
|
+
float32x4_t v_f = vec_splats(f);
|
|
137
|
+
float32x4_t v_zero = vec_splats(0.0f);
|
|
138
|
+
uint16x8_t v_hd = vec_round_from_fp32(v_f, v_zero, 0);
|
|
139
|
+
uint16x8_t v_h = vec_convert_to_fp16(v_hd, 0);
|
|
140
|
+
return vec_extract(v_h, 0);
|
|
141
|
+
}
|
|
142
|
+
#endif
|
|
143
|
+
|
|
144
|
+
// precomputed f32 table for f16 (256 KB)
|
|
145
|
+
// defined in ggml-cpu.c, initialized in ggml_cpu_init()
|
|
146
|
+
extern float ggml_table_f32_f16[1 << 16];
|
|
147
|
+
|
|
148
|
+
// On ARM NEON, it's quicker to directly convert x -> x instead of calling into ggml_lookup_fp16_to_fp32,
|
|
149
|
+
// so we define GGML_CPU_FP16_TO_FP32 and GGML_CPU_FP32_TO_FP16 elsewhere for NEON.
|
|
150
|
+
// This is also true for POWER9.
|
|
151
|
+
#if !defined(GGML_CPU_FP16_TO_FP32)
|
|
152
|
+
inline static float ggml_lookup_fp16_to_fp32(ggml_fp16_t f) {
|
|
153
|
+
uint16_t s;
|
|
154
|
+
memcpy(&s, &f, sizeof(uint16_t));
|
|
155
|
+
return ggml_table_f32_f16[s];
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
#define GGML_CPU_FP16_TO_FP32(x) ggml_lookup_fp16_to_fp32(x)
|
|
159
|
+
#endif
|
|
160
|
+
|
|
161
|
+
#if !defined(GGML_CPU_FP32_TO_FP16)
|
|
162
|
+
#define GGML_CPU_FP32_TO_FP16(x) GGML_COMPUTE_FP32_TO_FP16(x)
|
|
163
|
+
#endif
|
|
164
|
+
|
|
165
|
+
|
|
9
166
|
// we define a common set of C macros which map to specific intrinsics based on the current architecture
|
|
10
167
|
// we then implement the fundamental computation operations below using only these macros
|
|
11
168
|
// adding support for new architectures requires to define the corresponding SIMD macros
|
|
@@ -32,7 +189,7 @@
|
|
|
32
189
|
#define GGML_F32xt_LOAD(...) GGML_F32xt_LOAD_IMPL(DEFAULT_PG, __VA_ARGS__)
|
|
33
190
|
#define GGML_F32xt_STORE_IMPL(pg,a,b) svst1_f32(pg, a, b)
|
|
34
191
|
#define GGML_F32xt_STORE(...) GGML_F32xt_STORE_IMPL(DEFAULT_PG, __VA_ARGS__)
|
|
35
|
-
#define GGML_F32xt_FMA_IMPL(pg, a, b, c) svmad_f32_m(pg,
|
|
192
|
+
#define GGML_F32xt_FMA_IMPL(pg, a, b, c) svmad_f32_m(pg, b, c, a)
|
|
36
193
|
#define GGML_F32xt_FMA(...) GGML_F32xt_FMA_IMPL(DEFAULT_PG, __VA_ARGS__)
|
|
37
194
|
#define GGML_F32xt_ADD_IMPL(pg, a, b) svadd_f32_m(pg, a, b)
|
|
38
195
|
#define GGML_F32xt_ADD(...) GGML_F32xt_ADD_IMPL(DEFAULT_PG, __VA_ARGS__)
|
|
@@ -415,7 +572,7 @@ static inline __m256 __avx_f32cx8_load(const ggml_fp16_t * x) {
|
|
|
415
572
|
float tmp[8];
|
|
416
573
|
|
|
417
574
|
for (int i = 0; i < 8; i++) {
|
|
418
|
-
tmp[i] =
|
|
575
|
+
tmp[i] = GGML_CPU_FP16_TO_FP32(x[i]);
|
|
419
576
|
}
|
|
420
577
|
|
|
421
578
|
return _mm256_loadu_ps(tmp);
|
|
@@ -426,7 +583,7 @@ static inline void __avx_f32cx8_store(ggml_fp16_t *x, __m256 y) {
|
|
|
426
583
|
_mm256_storeu_ps(arr, y);
|
|
427
584
|
|
|
428
585
|
for (int i = 0; i < 8; i++)
|
|
429
|
-
x[i] =
|
|
586
|
+
x[i] = GGML_CPU_FP32_TO_FP16(arr[i]);
|
|
430
587
|
}
|
|
431
588
|
#define GGML_F32Cx8_LOAD(x) __avx_f32cx8_load(x)
|
|
432
589
|
#define GGML_F32Cx8_STORE(x, y) __avx_f32cx8_store(x, y)
|
|
@@ -574,10 +731,10 @@ static inline unsigned char ggml_endian_byte(int i) {
|
|
|
574
731
|
inline static v128_t __wasm_f16x4_load(const ggml_fp16_t * p) {
|
|
575
732
|
float tmp[4];
|
|
576
733
|
|
|
577
|
-
tmp[0] =
|
|
578
|
-
tmp[1] =
|
|
579
|
-
tmp[2] =
|
|
580
|
-
tmp[3] =
|
|
734
|
+
tmp[0] = GGML_CPU_FP16_TO_FP32(p[0]);
|
|
735
|
+
tmp[1] = GGML_CPU_FP16_TO_FP32(p[1]);
|
|
736
|
+
tmp[2] = GGML_CPU_FP16_TO_FP32(p[2]);
|
|
737
|
+
tmp[3] = GGML_CPU_FP16_TO_FP32(p[3]);
|
|
581
738
|
|
|
582
739
|
return wasm_v128_load(tmp);
|
|
583
740
|
}
|
|
@@ -587,10 +744,10 @@ inline static void __wasm_f16x4_store(ggml_fp16_t * p, v128_t x) {
|
|
|
587
744
|
|
|
588
745
|
wasm_v128_store(tmp, x);
|
|
589
746
|
|
|
590
|
-
p[0] =
|
|
591
|
-
p[1] =
|
|
592
|
-
p[2] =
|
|
593
|
-
p[3] =
|
|
747
|
+
p[0] = GGML_CPU_FP32_TO_FP16(tmp[0]);
|
|
748
|
+
p[1] = GGML_CPU_FP32_TO_FP16(tmp[1]);
|
|
749
|
+
p[2] = GGML_CPU_FP32_TO_FP16(tmp[2]);
|
|
750
|
+
p[3] = GGML_CPU_FP32_TO_FP16(tmp[3]);
|
|
594
751
|
}
|
|
595
752
|
|
|
596
753
|
#define GGML_F16x4 v128_t
|
|
@@ -690,10 +847,10 @@ inline static void __wasm_f16x4_store(ggml_fp16_t * p, v128_t x) {
|
|
|
690
847
|
static inline __m128 __sse_f16x4_load(const ggml_fp16_t * x) {
|
|
691
848
|
float tmp[4];
|
|
692
849
|
|
|
693
|
-
tmp[0] =
|
|
694
|
-
tmp[1] =
|
|
695
|
-
tmp[2] =
|
|
696
|
-
tmp[3] =
|
|
850
|
+
tmp[0] = GGML_CPU_FP16_TO_FP32(x[0]);
|
|
851
|
+
tmp[1] = GGML_CPU_FP16_TO_FP32(x[1]);
|
|
852
|
+
tmp[2] = GGML_CPU_FP16_TO_FP32(x[2]);
|
|
853
|
+
tmp[3] = GGML_CPU_FP16_TO_FP32(x[3]);
|
|
697
854
|
|
|
698
855
|
return _mm_loadu_ps(tmp);
|
|
699
856
|
}
|
|
@@ -703,10 +860,10 @@ static inline void __sse_f16x4_store(ggml_fp16_t * x, __m128 y) {
|
|
|
703
860
|
|
|
704
861
|
_mm_storeu_ps(arr, y);
|
|
705
862
|
|
|
706
|
-
x[0] =
|
|
707
|
-
x[1] =
|
|
708
|
-
x[2] =
|
|
709
|
-
x[3] =
|
|
863
|
+
x[0] = GGML_CPU_FP32_TO_FP16(arr[0]);
|
|
864
|
+
x[1] = GGML_CPU_FP32_TO_FP16(arr[1]);
|
|
865
|
+
x[2] = GGML_CPU_FP32_TO_FP16(arr[2]);
|
|
866
|
+
x[3] = GGML_CPU_FP32_TO_FP16(arr[3]);
|
|
710
867
|
}
|
|
711
868
|
|
|
712
869
|
#define GGML_F32Cx4 __m128
|
|
@@ -828,7 +985,7 @@ static inline void __lasx_f32cx8_store(ggml_fp16_t * x, __m256 y) {
|
|
|
828
985
|
#define GGML_F32x4_ZERO __lsx_vldi(0)
|
|
829
986
|
#define GGML_F32x4_SET1(x) __lsx_vinsgr2vr_w(__lsx_vldi(0),(x), 0)
|
|
830
987
|
#define GGML_F32x4_LOAD(x) __lsx_vld((x), 0)
|
|
831
|
-
#define GGML_F32x4_STORE(
|
|
988
|
+
#define GGML_F32x4_STORE(x, y) __lsx_vst(y, x, 0)
|
|
832
989
|
#define GGML_F32x4_FMA(a, b, c) __lsx_vfmadd_s(b, c, a)
|
|
833
990
|
#define GGML_F32x4_ADD __lsx_vfadd_s
|
|
834
991
|
#define GGML_F32x4_MUL __lsx_vfmul_s
|
|
@@ -874,10 +1031,10 @@ static inline void __lasx_f32cx8_store(ggml_fp16_t * x, __m256 y) {
|
|
|
874
1031
|
static inline __m128 __lsx_f16x4_load(const ggml_fp16_t * x) {
|
|
875
1032
|
float tmp[4];
|
|
876
1033
|
|
|
877
|
-
tmp[0] =
|
|
878
|
-
tmp[1] =
|
|
879
|
-
tmp[2] =
|
|
880
|
-
tmp[3] =
|
|
1034
|
+
tmp[0] = GGML_CPU_FP16_TO_FP32(x[0]);
|
|
1035
|
+
tmp[1] = GGML_CPU_FP16_TO_FP32(x[1]);
|
|
1036
|
+
tmp[2] = GGML_CPU_FP16_TO_FP32(x[2]);
|
|
1037
|
+
tmp[3] = GGML_CPU_FP16_TO_FP32(x[3]);
|
|
881
1038
|
|
|
882
1039
|
return __lsx_vld(tmp, 0);
|
|
883
1040
|
}
|
|
@@ -887,10 +1044,10 @@ static inline void __lsx_f16x4_store(ggml_fp16_t * x, __m128 y) {
|
|
|
887
1044
|
|
|
888
1045
|
__lsx_vst(y, arr, 0);
|
|
889
1046
|
|
|
890
|
-
x[0] =
|
|
891
|
-
x[1] =
|
|
892
|
-
x[2] =
|
|
893
|
-
x[3] =
|
|
1047
|
+
x[0] = GGML_CPU_FP32_TO_FP16(arr[0]);
|
|
1048
|
+
x[1] = GGML_CPU_FP32_TO_FP16(arr[1]);
|
|
1049
|
+
x[2] = GGML_CPU_FP32_TO_FP16(arr[2]);
|
|
1050
|
+
x[3] = GGML_CPU_FP32_TO_FP16(arr[3]);
|
|
894
1051
|
}
|
|
895
1052
|
|
|
896
1053
|
#define GGML_F32Cx4 __m128
|
|
@@ -922,7 +1079,7 @@ static inline void __lsx_f16x4_store(ggml_fp16_t * x, __m128 y) {
|
|
|
922
1079
|
#define GGML_F32_STEP 32
|
|
923
1080
|
#define GGML_F32_EPR 4
|
|
924
1081
|
|
|
925
|
-
#define GGML_F32x4
|
|
1082
|
+
#define GGML_F32x4 float32x4_t
|
|
926
1083
|
#define GGML_F32x4_ZERO vec_splats(0.0f)
|
|
927
1084
|
#define GGML_F32x4_SET1 vec_splats
|
|
928
1085
|
#define GGML_F32x4_LOAD(p) vec_xl(0, p)
|
|
@@ -962,28 +1119,45 @@ static inline void __lsx_f16x4_store(ggml_fp16_t * x, __m128 y) {
|
|
|
962
1119
|
#define GGML_F16_STEP GGML_F32_STEP
|
|
963
1120
|
#define GGML_F16_EPR GGML_F32_EPR
|
|
964
1121
|
|
|
965
|
-
static inline
|
|
1122
|
+
static inline float32x4_t __lzs_f16cx4_load(const ggml_fp16_t * x) {
|
|
1123
|
+
#if defined(__NNPA__)
|
|
1124
|
+
uint16x8_t v_x = vec_xl(0, (const ggml_fp16_t *)x);
|
|
1125
|
+
uint16x8_t v_xd = vec_convert_from_fp16(v_x, 0);
|
|
1126
|
+
return vec_extend_to_fp32_hi(v_xd, 0);
|
|
1127
|
+
#else
|
|
966
1128
|
float tmp[4];
|
|
967
1129
|
|
|
968
1130
|
for (int i = 0; i < 4; i++) {
|
|
969
|
-
tmp[i] =
|
|
1131
|
+
tmp[i] = GGML_CPU_FP16_TO_FP32(x[i]);
|
|
970
1132
|
}
|
|
971
1133
|
|
|
972
1134
|
// note: keep type-cast here to prevent compiler bugs
|
|
973
1135
|
// see: https://github.com/ggml-org/llama.cpp/issues/12846
|
|
974
1136
|
return vec_xl(0, (const float *)(tmp));
|
|
1137
|
+
#endif
|
|
975
1138
|
}
|
|
976
1139
|
|
|
977
|
-
static inline void __lzs_f16cx4_store(ggml_fp16_t * x,
|
|
1140
|
+
static inline void __lzs_f16cx4_store(ggml_fp16_t * x, float32x4_t v_y) {
|
|
1141
|
+
#if defined(__NNPA__)
|
|
1142
|
+
float32x4_t v_zero = vec_splats(0.0f);
|
|
1143
|
+
uint16x8_t v_xd = vec_round_from_fp32(v_y, v_zero, 0);
|
|
1144
|
+
uint16x8_t v_x = vec_convert_to_fp16(v_xd, 0);
|
|
1145
|
+
|
|
1146
|
+
x[0] = vec_extract(v_x, 0);
|
|
1147
|
+
x[1] = vec_extract(v_x, 1);
|
|
1148
|
+
x[2] = vec_extract(v_x, 2);
|
|
1149
|
+
x[3] = vec_extract(v_x, 3);
|
|
1150
|
+
#else
|
|
978
1151
|
float arr[4];
|
|
979
1152
|
|
|
980
1153
|
// note: keep type-cast here to prevent compiler bugs
|
|
981
1154
|
// see: https://github.com/ggml-org/llama.cpp/issues/12846
|
|
982
|
-
vec_xst(
|
|
1155
|
+
vec_xst(v_y, 0, (float *)(arr));
|
|
983
1156
|
|
|
984
1157
|
for (int i = 0; i < 4; i++) {
|
|
985
|
-
x[i] =
|
|
1158
|
+
x[i] = GGML_CPU_FP32_TO_FP16(arr[i]);
|
|
986
1159
|
}
|
|
1160
|
+
#endif
|
|
987
1161
|
}
|
|
988
1162
|
|
|
989
1163
|
#define GGML_F16_VEC GGML_F32x4
|
|
@@ -1004,3 +1178,7 @@ static inline void __lzs_f16cx4_store(ggml_fp16_t * x, __vector float y) {
|
|
|
1004
1178
|
#define GGML_F32_ARR (GGML_F32_STEP/GGML_F32_EPR)
|
|
1005
1179
|
#define GGML_F16_ARR (GGML_F16_STEP/GGML_F16_EPR)
|
|
1006
1180
|
#endif
|
|
1181
|
+
|
|
1182
|
+
#ifdef __cplusplus
|
|
1183
|
+
}
|
|
1184
|
+
#endif
|
|
@@ -37,35 +37,35 @@ void ggml_vec_dot_f32(int n, float * GGML_RESTRICT s, size_t bs, const float * G
|
|
|
37
37
|
for (int i = 0; i < np; i += ggml_f32_step) {
|
|
38
38
|
ax1 = GGML_F32_VEC_LOAD(x + i);
|
|
39
39
|
ay1 = GGML_F32_VEC_LOAD(y + i);
|
|
40
|
-
sum1 = GGML_F32_VEC_FMA(ax1, ay1
|
|
40
|
+
sum1 = GGML_F32_VEC_FMA(sum1, ax1, ay1);
|
|
41
41
|
|
|
42
42
|
ax2 = GGML_F32_VEC_LOAD(x + i + 1*ggml_f32_epr);
|
|
43
43
|
ay2 = GGML_F32_VEC_LOAD(y + i + 1*ggml_f32_epr);
|
|
44
|
-
sum2 = GGML_F32_VEC_FMA(ax2, ay2
|
|
44
|
+
sum2 = GGML_F32_VEC_FMA(sum2, ax2, ay2);
|
|
45
45
|
|
|
46
46
|
ax3 = GGML_F32_VEC_LOAD(x + i + 2*ggml_f32_epr);
|
|
47
47
|
ay3 = GGML_F32_VEC_LOAD(y + i + 2*ggml_f32_epr);
|
|
48
|
-
sum3 = GGML_F32_VEC_FMA(ax3, ay3
|
|
48
|
+
sum3 = GGML_F32_VEC_FMA(sum3, ax3, ay3);
|
|
49
49
|
|
|
50
50
|
ax4 = GGML_F32_VEC_LOAD(x + i + 3*ggml_f32_epr);
|
|
51
51
|
ay4 = GGML_F32_VEC_LOAD(y + i + 3*ggml_f32_epr);
|
|
52
|
-
sum4 = GGML_F32_VEC_FMA(ax4, ay4
|
|
52
|
+
sum4 = GGML_F32_VEC_FMA(sum4, ax4, ay4);
|
|
53
53
|
|
|
54
54
|
ax5 = GGML_F32_VEC_LOAD(x + i + 4*ggml_f32_epr);
|
|
55
55
|
ay5 = GGML_F32_VEC_LOAD(y + i + 4*ggml_f32_epr);
|
|
56
|
-
sum5 = GGML_F32_VEC_FMA(ax5, ay5
|
|
56
|
+
sum5 = GGML_F32_VEC_FMA(sum5, ax5, ay5);
|
|
57
57
|
|
|
58
58
|
ax6 = GGML_F32_VEC_LOAD(x + i + 5*ggml_f32_epr);
|
|
59
59
|
ay6 = GGML_F32_VEC_LOAD(y + i + 5*ggml_f32_epr);
|
|
60
|
-
sum6 = GGML_F32_VEC_FMA(ax6, ay6
|
|
60
|
+
sum6 = GGML_F32_VEC_FMA(sum6, ax6, ay6);
|
|
61
61
|
|
|
62
62
|
ax7 = GGML_F32_VEC_LOAD(x + i + 6*ggml_f32_epr);
|
|
63
63
|
ay7 = GGML_F32_VEC_LOAD(y + i + 6*ggml_f32_epr);
|
|
64
|
-
sum7 = GGML_F32_VEC_FMA(ax7, ay7
|
|
64
|
+
sum7 = GGML_F32_VEC_FMA(sum7, ax7, ay7);
|
|
65
65
|
|
|
66
66
|
ax8 = GGML_F32_VEC_LOAD(x + i + 7*ggml_f32_epr);
|
|
67
67
|
ay8 = GGML_F32_VEC_LOAD(y + i + 7*ggml_f32_epr);
|
|
68
|
-
sum8 = GGML_F32_VEC_FMA(ax8, ay8
|
|
68
|
+
sum8 = GGML_F32_VEC_FMA(sum8, ax8, ay8);
|
|
69
69
|
}
|
|
70
70
|
// leftovers
|
|
71
71
|
// Since 8 unrolls are done in above loop, leftovers lie in range [0, ggml_f32_step] which is handled in below loop
|
|
@@ -73,7 +73,7 @@ void ggml_vec_dot_f32(int n, float * GGML_RESTRICT s, size_t bs, const float * G
|
|
|
73
73
|
for (int i = np; i < np2; i += ggml_f32_epr) {
|
|
74
74
|
ax1 = GGML_F32_VEC_LOAD(x + i);
|
|
75
75
|
ay1 = GGML_F32_VEC_LOAD(y + i);
|
|
76
|
-
sum1 = GGML_F32_VEC_FMA(ax1, ay1
|
|
76
|
+
sum1 = GGML_F32_VEC_FMA(sum1, ax1, ay1);
|
|
77
77
|
}
|
|
78
78
|
// maximum number of leftover elements will be less that ggml_f32_epr. Apply predicated svmad on available elements only
|
|
79
79
|
if (np2 < n) {
|
|
@@ -219,11 +219,11 @@ void ggml_vec_dot_f16(int n, float * GGML_RESTRICT s, size_t bs, ggml_fp16_t * G
|
|
|
219
219
|
|
|
220
220
|
// leftovers
|
|
221
221
|
for (int i = np; i < n; ++i) {
|
|
222
|
-
sumf += (ggml_float)(
|
|
222
|
+
sumf += (ggml_float)(GGML_CPU_FP16_TO_FP32(x[i])*GGML_CPU_FP16_TO_FP32(y[i]));
|
|
223
223
|
}
|
|
224
224
|
#else
|
|
225
225
|
for (int i = 0; i < n; ++i) {
|
|
226
|
-
sumf += (ggml_float)(
|
|
226
|
+
sumf += (ggml_float)(GGML_CPU_FP16_TO_FP32(x[i])*GGML_CPU_FP16_TO_FP32(y[i]));
|
|
227
227
|
}
|
|
228
228
|
#endif
|
|
229
229
|
|
|
@@ -254,6 +254,30 @@ void ggml_vec_silu_f32(const int n, float * y, const float * x) {
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
|
|
257
|
+
void ggml_vec_swiglu_f32(const int n, float * y, const float * x, const float * g) {
|
|
258
|
+
int i = 0;
|
|
259
|
+
#if defined(__AVX512F__) && defined(__AVX512DQ__)
|
|
260
|
+
for (; i + 15 < n; i += 16) {
|
|
261
|
+
_mm512_storeu_ps(y + i, _mm512_mul_ps(ggml_v_silu(_mm512_loadu_ps(x + i)), _mm512_loadu_ps(g + i)));
|
|
262
|
+
}
|
|
263
|
+
#elif defined(__AVX2__) && defined(__FMA__)
|
|
264
|
+
for (; i + 7 < n; i += 8) {
|
|
265
|
+
_mm256_storeu_ps(y + i, _mm256_mul_ps(ggml_v_silu(_mm256_loadu_ps(x + i)), _mm256_loadu_ps(g + i)));
|
|
266
|
+
}
|
|
267
|
+
#elif defined(__SSE2__)
|
|
268
|
+
for (; i + 3 < n; i += 4) {
|
|
269
|
+
_mm_storeu_ps(y + i, _mm_mul_ps(ggml_v_silu(_mm_loadu_ps(x + i)), _mm_loadu_ps(g + i)));
|
|
270
|
+
}
|
|
271
|
+
#elif defined(__ARM_NEON) && defined(__aarch64__)
|
|
272
|
+
for (; i + 3 < n; i += 4) {
|
|
273
|
+
vst1q_f32(y + i, vmulq_f32(ggml_v_silu(vld1q_f32(x + i)), vld1q_f32(g + i)));
|
|
274
|
+
}
|
|
275
|
+
#endif
|
|
276
|
+
for (; i < n; ++i) {
|
|
277
|
+
y[i] = ggml_silu_f32(x[i]) * g[i];
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
257
281
|
ggml_float ggml_vec_soft_max_f32(const int n, float * y, const float * x, float max) {
|
|
258
282
|
int i = 0;
|
|
259
283
|
ggml_float sum = 0;
|