ggml
[Ported from github.com/ggml-org/ggml] docs : sync ggml_type enum in gguf.md (#1685)
Brought by drakestapleton
ggml / scripts / sync-whisper-am.sh
| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Synchronize whisper.cpp changes to ggml |
| 4 | # |
| 5 | # Usage: |
| 6 | # |
| 7 | # $ cd /path/to/ggml |
| 8 | # $ ./scripts/sync-whisper-am.sh -skip hash0,hash1,hash2... |
| 9 | # |
| 10 | |
| 11 | set -e |
| 12 | |
| 13 | sd=$(dirname $0) |
| 14 | cd $sd/../ |
| 15 | |
| 16 | SRC_GGML=$(pwd) |
| 17 | SRC_WHISPER=$(cd ../whisper.cpp; pwd) |
| 18 | |
| 19 | if [ ! -d $SRC_WHISPER ]; then |
| 20 | echo "whisper.cpp not found at $SRC_WHISPER" |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | lc=$(cat $SRC_GGML/scripts/sync-whisper.last) |
| 25 | echo "Syncing whisper.cpp changes since commit $lc" |
| 26 | |
| 27 | to_skip="" |
| 28 | if [ "$1" == "-skip" ]; then |
| 29 | to_skip=$2 |
| 30 | fi |
| 31 | |
| 32 | cd $SRC_WHISPER |
| 33 | |
| 34 | git log --oneline $lc..HEAD |
| 35 | git log --oneline $lc..HEAD --reverse | grep -v "(ggml/[0-9]*)" | grep -v "(llama/[0-9]*)" | cut -d' ' -f1 > $SRC_GGML/whisper-commits |
| 36 | |
| 37 | if [ ! -s $SRC_GGML/whisper-commits ]; then |
| 38 | rm -v $SRC_GGML/whisper-commits |
| 39 | echo "No new commits" |
| 40 | exit 0 |
| 41 | fi |
| 42 | |
| 43 | if [ -f $SRC_GGML/whisper-src.patch ]; then |
| 44 | rm -v $SRC_GGML/whisper-src.patch |
| 45 | fi |
| 46 | |
| 47 | while read c; do |
| 48 | if [ -n "$to_skip" ]; then |
| 49 | if [[ $to_skip == *"$c"* ]]; then |
| 50 | echo "Skipping $c" |
| 51 | continue |
| 52 | fi |
| 53 | fi |
| 54 | |
| 55 | git format-patch -k $c~1..$c --stdout -- \ |
| 56 | ggml/CMakeLists.txt \ |
| 57 | ggml/src/CMakeLists.txt \ |
| 58 | ggml/cmake/FindSIMD.cmake \ |
| 59 | ggml/src/ggml* \ |
| 60 | ggml/src/gguf* \ |
| 61 | ggml/include/ggml*.h \ |
| 62 | ggml/include/gguf*.h \ |
| 63 | examples/common-ggml.h \ |
| 64 | examples/common-ggml.cpp \ |
| 65 | LICENSE \ |
| 66 | scripts/gen-authors.sh \ |
| 67 | >> $SRC_GGML/whisper-src.patch |
| 68 | done < $SRC_GGML/whisper-commits |
| 69 | |
| 70 | rm -v $SRC_GGML/whisper-commits |
| 71 | |
| 72 | # delete files if empty |
| 73 | if [ ! -s $SRC_GGML/whisper-src.patch ]; then |
| 74 | rm -v $SRC_GGML/whisper-src.patch |
| 75 | fi |
| 76 | |
| 77 | cd $SRC_GGML |
| 78 | |
| 79 | if [ -f $SRC_GGML/whisper-src.patch ]; then |
| 80 | # replace PR numbers |
| 81 | # |
| 82 | # Subject: some text (#1234) |
| 83 | # Subject: some text (whisper/1234) |
| 84 | cat whisper-src.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (whisper\/\2)/' > whisper-src.patch.tmp |
| 85 | mv whisper-src.patch.tmp whisper-src.patch |
| 86 | |
| 87 | cat whisper-src.patch | sed -e 's/^\(.*\) (#\([0-9]*\))$/\1 (whisper\/\2)/' > whisper-src.patch.tmp |
| 88 | mv whisper-src.patch.tmp whisper-src.patch |
| 89 | |
| 90 | # replace filenames: |
| 91 | # |
| 92 | # ggml/CMakelists.txt -> CMakeLists.txt |
| 93 | # ggml/src/CMakelists.txt -> src/CMakeLists.txt |
| 94 | # ggml/cmake/FindSIMD.cmake -> cmake/FindSIMD.cmake |
| 95 | # |
| 96 | # ggml/src/ggml* -> src/ggml* |
| 97 | # ggml/src/gguf* -> src/gguf* |
| 98 | # |
| 99 | # ggml/include/ggml*.h -> include/ggml*.h |
| 100 | # ggml/include/gguf*.h -> include/gguf*.h |
| 101 | # |
| 102 | # examples/common.h -> examples/common.h |
| 103 | # examples/common.cpp -> examples/common.cpp |
| 104 | # examples/common-ggml.h -> examples/common-ggml.h |
| 105 | # examples/common-ggml.cpp -> examples/common-ggml.cpp |
| 106 | # |
| 107 | # LICENSE -> LICENSE |
| 108 | # scripts/gen-authors.sh -> scripts/gen-authors.sh |
| 109 | |
| 110 | cat whisper-src.patch | sed -E \ |
| 111 | -e 's/\/ggml\/CMakeLists\.txt/\/CMakeLists.txt/g' \ |
| 112 | -e 's/\/ggml\/src\/CMakeLists\.txt/\/src\/CMakeLists.txt/g' \ |
| 113 | -e 's/\/ggml\/cmake\/FindSIMD\.cmake/\/cmake\/FindSIMD.cmake/g' \ |
| 114 | -e 's/\/ggml\/src\/ggml(.*)/\/src\/ggml\1/g' \ |
| 115 | -e 's/\/ggml\/src\/gguf(.*)/\/src\/gguf\1/g' \ |
| 116 | -e 's/\/ggml\/include\/ggml(.*)\.h/\/include\/ggml\1.h/g' \ |
| 117 | -e 's/\/ggml\/include\/gguf(.*)\.h/\/include\/gguf\1.h/g' \ |
| 118 | -e 's/\/examples\/common\.h/\/examples\/common.h/g' \ |
| 119 | -e 's/\/examples\/common\.cpp/\/examples\/common.cpp/g' \ |
| 120 | -e 's/\/examples\/common-ggml\.h/\/examples\/common-ggml.h/g' \ |
| 121 | -e 's/\/examples\/common-ggml\.cpp/\/examples\/common-ggml.cpp/g' \ |
| 122 | -e 's/\/LICENSE/\/LICENSE/g' \ |
| 123 | -e 's/\/scripts\/gen-authors\.sh/\/scripts\/gen-authors.sh/g' \ |
| 124 | > whisper-src.patch.tmp |
| 125 | mv whisper-src.patch.tmp whisper-src.patch |
| 126 | |
| 127 | git am whisper-src.patch |
| 128 | |
| 129 | rm -v $SRC_GGML/whisper-src.patch |
| 130 | fi |
| 131 | |
| 132 | # update last commit |
| 133 | cd $SRC_WHISPER |
| 134 | git log -1 --format=%H > $SRC_GGML/scripts/sync-whisper.last |
| 135 | |
| 136 | echo "Done" |
| 137 | |
| 138 | exit 0 |