CoolFace
Datasetpublic

echodict/llama.cpp

version https://git-lfs.github.com/spec/v1 oid sha256:cfc44b7ba25614df70e6b65e3341cae0310163bd32fd31a6b928a542df433faf size 30786

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes773downloads
sync-ggml-am.sh159 linesDownload Raw Back to scripts
1#!/usr/bin/env bash2#3# Synchronize ggml changes to llama.cpp4#5# Usage:6#7#   $ cd /path/to/llama.cpp8#   $ ./scripts/sync-ggml-am.sh -skip hash0,hash1,hash2... -C 39#10 11set -e12 13sd=$(dirname $0)14cd $sd/../15 16SRC_LLAMA=$(pwd)17SRC_GGML=$(cd ../ggml; pwd)18 19if [ ! -d $SRC_GGML ]; then20    echo "ggml not found at $SRC_GGML"21    exit 122fi23 24lc=$(cat $SRC_LLAMA/scripts/sync-ggml.last)25echo "Syncing ggml changes since commit $lc"26 27to_skip=""28 29# context for git patches in number of lines30ctx="8"31 32while [ "$1" != "" ]; do33    case $1 in34        -skip )35            shift36            to_skip=$137            ;;38        -C )39            shift40            ctx=$141            ;;42    esac43    shift44done45 46cd $SRC_GGML47 48git log --oneline $lc..HEAD49git log --oneline $lc..HEAD --reverse | grep -v "(llama/[0-9]*)" | cut -d' ' -f1 > $SRC_LLAMA/ggml-commits50 51if [ ! -s $SRC_LLAMA/ggml-commits ]; then52    rm -v $SRC_LLAMA/ggml-commits53    echo "No new commits"54    exit 055fi56 57if [ -f $SRC_LLAMA/ggml-src.patch ]; then58    rm -v $SRC_LLAMA/ggml-src.patch59fi60 61while read c; do62    if [ -n "$to_skip" ]; then63        if [[ $to_skip == *"$c"* ]]; then64            echo "Skipping $c"65            continue66        fi67    fi68 69    git format-patch -U${ctx} -k $c~1..$c --stdout -- \70        CMakeLists.txt \71        src/CMakeLists.txt \72        cmake/BuildTypes.cmake \73        cmake/GitVars.cmake \74        cmake/common.cmake \75        cmake/ggml-config.cmake.in \76        src/ggml-cpu/cmake/FindSIMD.cmake \77        src/ggml* \78        include/ggml*.h \79        include/gguf*.h \80        tests/test-opt.cpp \81        tests/test-quantize-fns.cpp \82        tests/test-quantize-perf.cpp \83        tests/test-backend-ops.cpp \84        LICENSE \85        scripts/gen-authors.sh \86        >> $SRC_LLAMA/ggml-src.patch87done < $SRC_LLAMA/ggml-commits88 89rm -v $SRC_LLAMA/ggml-commits90 91# delete files if empty92if [ ! -s $SRC_LLAMA/ggml-src.patch ]; then93    rm -v $SRC_LLAMA/ggml-src.patch94fi95 96cd $SRC_LLAMA97 98if [ -f $SRC_LLAMA/ggml-src.patch ]; then99    # replace PR numbers100    #101    # Subject: some text (#1234)102    # Subject: some text (ggml/1234)103    cat ggml-src.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (ggml\/\2)/' > ggml-src.patch.tmp104    mv ggml-src.patch.tmp ggml-src.patch105 106    cat ggml-src.patch | sed -e 's/^\(.*\) (#\([0-9]*\))$/\1 (ggml\/\2)/' > ggml-src.patch.tmp107    mv ggml-src.patch.tmp ggml-src.patch108 109    # replace filenames:110    #111    # CMakelists.txt       -> ggml/CMakeLists.txt112    # src/CMakeLists.txt   -> ggml/src/CMakeLists.txt113 114    # cmake/BuildTypes.cmake            -> ggml/cmake/BuildTypes.cmake115    # cmake/GitVars.cmake               -> ggml/cmake/GitVars.cmake116    # cmake/common.cmake                -> ggml/cmake/common.cmake117    # cmake/ggml-config.cmake.in        -> ggml/cmake/ggml-config.cmake.in118    # src/ggml-cpu/cmake/FindSIMD.cmake -> ggml/src/ggml-cpu/cmake/FindSIMD.cmake119    #120    # src/ggml* -> ggml/src/ggml*121    #122    # include/ggml*.h -> ggml/include/ggml*.h123    # include/gguf*.h -> ggml/include/gguf*.h124    #125    # tests/test*.cpp -> tests/126    #127    # LICENSE                -> LICENSE128    # scripts/gen-authors.sh -> scripts/gen-authors.sh129 130    cat ggml-src.patch | sed -E \131        -e 's/([[:space:]]| [ab]\/)CMakeLists.txt/\1ggml\/CMakeLists.txt/g' \132        -e 's/([[:space:]]| [ab]\/)src\/CMakeLists.txt/\1ggml\/src\/CMakeLists.txt/g' \133        -e 's/([[:space:]]| [ab]\/)cmake\/BuildTypes.cmake/\1ggml\/cmake\/BuildTypes.cmake/g' \134        -e 's/([[:space:]]| [ab]\/)cmake\/GitVars.cmake/\1ggml\/cmake\/GitVars.cmake/g' \135        -e 's/([[:space:]]| [ab]\/)cmake\/common.cmake/\1ggml\/cmake\/common.cmake/g' \136        -e 's/([[:space:]]| [ab]\/)cmake\/ggml-config.cmake.in/\1ggml\/cmake\/ggml-config.cmake.in/g' \137        -e 's/([[:space:]]| [ab]\/)src\/ggml-cpu\/cmake\/FindSIMD.cmake/\1ggml\/src\/ggml-cpu\/cmake\/FindSIMD.cmake/g' \138        -e 's/([[:space:]]| [ab]\/)src\/ggml(.*)/\1ggml\/src\/ggml\2/g' \139        -e 's/([[:space:]]| [ab]\/)include\/ggml(.*)\.h/\1ggml\/include\/ggml\2.h/g' \140        -e 's/([[:space:]]| [ab]\/)include\/gguf(.*)\.h/\1ggml\/include\/gguf\2.h/g' \141        -e 's/([[:space:]]| [ab]\/)tests\/(.*)\.cpp/\1tests\/\2.cpp/g' \142        -e 's/([[:space:]]| [ab]\/)LICENSE/\1LICENSE/g' \143        -e 's/([[:space:]]| [ab]\/)scripts\/gen-authors\.sh/\1scripts\/gen-authors.sh/g' \144        > ggml-src.patch.tmp145    mv ggml-src.patch.tmp ggml-src.patch146 147    git am -C${ctx} ggml-src.patch148 149    rm -v $SRC_LLAMA/ggml-src.patch150fi151 152# update last commit153cd $SRC_GGML154git log -1 --format=%H > $SRC_LLAMA/scripts/sync-ggml.last155 156echo "Done"157 158exit 0159