Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/ggml/blob/master/scripts/sync-llama-am.sh # ggml [Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685) Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `ggml / scripts / sync-llama-am.sh` 167 lines ยท 5422 bytes Raw Blame History 1 #!/bin/bash 2 # 3 # Synchronize llama.cpp changes to ggml 4 # 5 # Usage: 6 # 7 # $ cd /path/to/ggml 8 # $ ./scripts/sync-llama-am.sh -skip hash0,hash1,hash2... -C 3 9 # 10 11 set -e 12 13 sd=$(dirname $0) 14 cd $sd/../ 15 16 SRC_GGML=$(pwd) 17 SRC_LLAMA=$(cd ../llama.cpp; pwd) 18 19 if [ ! -d $SRC_LLAMA ]; then 20 echo "llama.cpp not found at $SRC_LLAMA" 21 exit 1 22 fi 23 24 lc=$(cat $SRC_GGML/scripts/sync-llama.last) 25 echo "Syncing llama.cpp changes since commit $lc" 26 27 to_skip="" 28 29 # context for git patches in number of lines 30 ctx="8" 31 32 while [ "$1" != "" ]; do 33 case $1 in 34 -skip ) 35 shift 36 to_skip=$1 37 ;; 38 -C ) 39 shift 40 ctx=$1 41 ;; 42 esac 43 shift 44 done 45 46 cd $SRC_LLAMA 47 48 git log --oneline $lc..HEAD 49 git log --oneline $lc..HEAD --reverse | grep -v "(ggml/[0-9]*)" | grep -v "(whisper/[0-9]*)" | cut -d' ' -f1 > $SRC_GGML/llama-commits 50 51 if [ ! -s $SRC_GGML/llama-commits ]; then 52 rm -v $SRC_GGML/llama-commits 53 echo "No new commits" 54 exit 0 55 fi 56 57 if [ -f $SRC_GGML/llama-src.patch ]; then 58 rm -v $SRC_GGML/llama-src.patch 59 fi 60 61 while read c; do 62 if [ -n "$to_skip" ]; then 63 if [[ $to_skip == *"$c"* ]]; then 64 echo "Skipping $c" 65 continue 66 fi 67 fi 68 69 git format-patch -U${ctx} -k $c~1..$c --stdout -- \ 70 ggml/CMakeLists.txt \ 71 ggml/src/CMakeLists.txt \ 72 ggml/cmake/BuildTypes.cmake \ 73 ggml/cmake/GitVars.cmake \ 74 ggml/cmake/common.cmake \ 75 ggml/cmake/ggml-config.cmake.in \ 76 ggml/src/ggml-cpu/cmake/FindSIMD.cmake \ 77 ggml/src/ggml* \ 78 ggml/src/gguf* \ 79 ggml/include/ggml*.h \ 80 ggml/include/gguf*.h \ 81 tests/test-opt.cpp \ 82 tests/test-quantize-fns.cpp \ 83 tests/test-quantize-perf.cpp \ 84 tests/test-backend-ops.cpp \ 85 LICENSE \ 86 scripts/gen-authors.sh \ 87 >> $SRC_GGML/llama-src.patch 88 done < $SRC_GGML/llama-commits 89 90 rm -v $SRC_GGML/llama-commits 91 92 # delete files if empty 93 if [ ! -s $SRC_GGML/llama-src.patch ]; then 94 rm -v $SRC_GGML/llama-src.patch 95 fi 96 97 cd $SRC_GGML 98 99 if [ -f $SRC_GGML/llama-src.patch ]; then 100 # replace PR numbers 101 # 102 # Subject: some text (#1234) 103 # Subject: some text (llama/1234) 104 cat llama-src.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (llama\/\2)/' > llama-src.patch.tmp 105 mv llama-src.patch.tmp llama-src.patch 106 107 cat llama-src.patch | sed -e 's/^\(.*\) (#\([0-9]*\))$/\1 (llama\/\2)/' > llama-src.patch.tmp 108 mv llama-src.patch.tmp llama-src.patch 109 110 # replace filenames: 111 # 112 # ggml/CMakelists.txt -> CMakeLists.txt 113 # ggml/src/CMakelists.txt -> src/CMakeLists.txt 114 # 115 # ggml/cmake/BuildTypes.cmake -> cmake/BuildTypes.cmake 116 # ggml/cmake/GitVars.cmake -> cmake/GitVars.cmake 117 # ggml/cmake/common.cmake -> cmake/common.cmake 118 # ggml/cmake/ggml-config.cmake.in -> cmake/ggml-config.cmake.in 119 # ggml/src/ggml-cpu/cmake/FindSIMD.cmake -> src/ggml-cpu/cmake/FindSIMD.cmake 120 # 121 # ggml/src/ggml* -> src/ggml* 122 # ggml/src/gguf* -> src/gguf* 123 # 124 # ggml/include/ggml*.h -> include/ggml*.h 125 # ggml/include/gguf*.h -> include/gguf*.h 126 # 127 # tests/test-opt.cpp -> tests/test-opt.cpp 128 # tests/test-quantize-fns.cpp -> tests/test-quantize-fns.cpp 129 # tests/test-quantize-perf.cpp -> tests/test-quantize-perf.cpp 130 # tests/test-backend-ops.cpp -> tests/test-backend-ops.cpp 131 # 132 # LICENSE -> LICENSE 133 # scripts/gen-authors.sh -> scripts/gen-authors.sh 134 135 cat llama-src.patch | sed -E \ 136 -e 's/(^[[:space:]]| [ab]\/)ggml\/CMakeLists\.txt/\1CMakeLists.txt/g' \ 137 -e 's/(^[[:space:]]| [ab]\/)ggml\/src\/CMakeLists\.txt/\1src\/CMakeLists.txt/g' \ 138 -e 's/(^[[:space:]]| [ab]\/)ggml\/cmake\/BuildTypes\.cmake/\1cmake\/BuildTypes\.cmake/g' \ 139 -e 's/(^[[:space:]]| [ab]\/)ggml\/cmake\/GitVars\.cmake/\1cmake\/GitVars\.cmake/g' \ 140 -e 's/(^[[:space:]]| [ab]\/)ggml\/cmake\/common\.cmake/\1cmake\/common\.cmake/g' \ 141 -e 's/(^[[:space:]]| [ab]\/)ggml\/cmake\/ggml-config\.cmake\.in/\1cmake\/ggml-config\.cmake\.in/g' \ 142 -e 's/(^[[:space:]]| [ab]\/)ggml\/src\/ggml-cpu\/cmake\/FindSIMD\.cmake/\1src\/ggml-cpu\/cmake\/FindSIMD\.cmake/g' \ 143 -e 's/(^[[:space:]]| [ab]\/)ggml\/src\/ggml(.*)/\1src\/ggml\2/g' \ 144 -e 's/(^[[:space:]]| [ab]\/)ggml\/src\/gguf(.*)/\1src\/gguf\2/g' \ 145 -e 's/(^[[:space:]]| [ab]\/)ggml\/include\/ggml(.*)\.h/\1include\/ggml\2.h/g' \ 146 -e 's/(^[[:space:]]| [ab]\/)ggml\/include\/gguf(.*)\.h/\1include\/gguf\2.h/g' \ 147 -e 's/(^[[:space:]]| [ab]\/)tests\/test-opt\.cpp/\1tests\/test-opt.cpp/g' \ 148 -e 's/(^[[:space:]]| [ab]\/)tests\/test-quantize-fns\.cpp/\1tests\/test-quantize-fns.cpp/g' \ 149 -e 's/(^[[:space:]]| [ab]\/)tests\/test-quantize-perf\.cpp/\1tests\/test-quantize-perf.cpp/g' \ 150 -e 's/(^[[:space:]]| [ab]\/)tests\/test-backend-ops\.cpp/\1tests\/test-backend-ops.cpp/g' \ 151 -e 's/(^[[:space:]]| [ab]\/)LICENSE/\1LICENSE/g' \ 152 -e 's/(^[[:space:]]| [ab]\/)scripts\/gen-authors\.sh/\1scripts\/gen-authors.sh/g' \ 153 > llama-src.patch.tmp 154 mv llama-src.patch.tmp llama-src.patch 155 156 git am -C${ctx} llama-src.patch 157 158 rm -v $SRC_GGML/llama-src.patch 159 fi 160 161 # update last commit 162 cd $SRC_LLAMA 163 git log -1 --format=%H > $SRC_GGML/scripts/sync-llama.last 164 165 echo "Done" 166 167 exit 0