Team Ai
Apppublic

Xenobd/whisper.cpp

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
sync-ggml-am.sh152 linesDownload Raw Back to scripts
1#!/bin/bash2#3# Synchronize ggml changes to whisper.cpp4#5# Usage:6#7#   $ cd /path/to/whisper.cpp8#   $ ./scripts/sync-ggml-am.sh -skip hash0,hash1,hash2...9#10 11set -e12 13sd=$(dirname $0)14cd $sd/../15 16SRC_WHISPER=$(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_WHISPER/scripts/sync-ggml.last)25echo "Syncing ggml changes since commit $lc"26 27to_skip=""28if [ "$1" == "-skip" ]; then29    to_skip=$230fi31 32cd $SRC_GGML33 34git log --oneline $lc..HEAD35git log --oneline $lc..HEAD --reverse | grep -v "(whisper/[0-9]*)" | cut -d' ' -f1 > $SRC_WHISPER/ggml-commits36 37if [ ! -s $SRC_WHISPER/ggml-commits ]; then38    rm -v $SRC_WHISPER/ggml-commits39    echo "No new commits"40    exit 041fi42 43if [ -f $SRC_WHISPER/ggml-src.patch ]; then44    rm -v $SRC_WHISPER/ggml-src.patch45fi46 47while read c; do48    if [ -n "$to_skip" ]; then49        if [[ $to_skip == *"$c"* ]]; then50            echo "Skipping $c"51            continue52        fi53    fi54 55    git format-patch -k $c~1..$c --stdout -- \56        CMakeLists.txt \57        src/CMakeLists.txt \58        cmake/BuildTypes.cmake \59        cmake/GitVars.cmake \60        cmake/common.cmake \61        cmake/ggml-config.cmake.in \62        src/ggml-cpu/cmake/FindSIMD.cmake \63        src/ggml*.h \64        src/ggml* \65        include/ggml*.h \66        include/gguf*.h \67        examples/common.h \68        examples/common.cpp \69        examples/common-ggml.h \70        examples/common-ggml.cpp \71        LICENSE \72        scripts/gen-authors.sh \73        >> $SRC_WHISPER/ggml-src.patch74done < $SRC_WHISPER/ggml-commits75 76rm -v $SRC_WHISPER/ggml-commits77 78# delete files if empty79if [ ! -s $SRC_WHISPER/ggml-src.patch ]; then80    rm -v $SRC_WHISPER/ggml-src.patch81fi82 83cd $SRC_WHISPER84 85if [ -f $SRC_WHISPER/ggml-src.patch ]; then86    # replace PR numbers87    #88    # Subject: some text (#1234)89    # Subject: some text (ggml/1234)90    cat ggml-src.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (ggml\/\2)/' > ggml-src.patch.tmp91    mv ggml-src.patch.tmp ggml-src.patch92 93    cat ggml-src.patch | sed -e 's/^\(.*\) (#\([0-9]*\))$/\1 (ggml\/\2)/' > ggml-src.patch.tmp94    mv ggml-src.patch.tmp ggml-src.patch95 96    # replace filenames:97    #98    # CMakelists.txt       -> ggml/CMakeLists.txt99    # src/CMakeLists.txt   -> ggml/src/CMakeLists.txt100    #101    # cmake/BuildTypes.cmake            -> ggml/cmake/BuildTypes.cmake102    # cmake/GitVars.cmake               -> ggml/cmake/GitVars.cmake103    # cmake/common.cmake                -> ggml/cmake/common.cmake104    # cmake/ggml-config.cmake.in        -> ggml/cmake/ggml-config.cmake.in105    # src/ggml-cpu/cmake/FindSIMD.cmake -> ggml/src/ggml-cpu/cmake/FindSIMD.cmake106    #107    # src/ggml* -> ggml/src/ggml*.c108    #109    # include/ggml*.h -> ggml/include/ggml*.h110    # include/gguf*.h -> ggml/include/gguf*.h111    #112    # examples/common.h        -> examples/common.h113    # examples/common.cpp      -> examples/common.cpp114    # examples/common-ggml.h   -> examples/common-ggml.h115    # examples/common-ggml.cpp -> examples/common-ggml.cpp116    #117    # LICENSE                     -> LICENSE118    # ggml/scripts/gen-authors.sh -> scripts/gen-authors.sh119 120    cat ggml-src.patch | sed -E \121        -e 's/(^[[:space:]]| [ab]\/)CMakeLists.txt/\1ggml\/CMakeLists.txt/g' \122        -e 's/(^[[:space:]]| [ab]\/)src\/CMakeLists.txt/\1ggml\/src\/CMakeLists.txt/g' \123        -e 's/(^[[:space:]]| [ab]\/)cmake\/BuildTypes.cmake/\1ggml\/cmake\/BuildTypes.cmake/g' \124        -e 's/(^[[:space:]]| [ab]\/)cmake\/GitVars.cmake/\1ggml\/cmake\/GitVars.cmake/g' \125        -e 's/(^[[:space:]]| [ab]\/)cmake\/common.cmake/\1ggml\/cmake\/common.cmake/g' \126        -e 's/(^[[:space:]]| [ab]\/)cmake\/ggml-config.cmake.in/\1ggml\/cmake\/ggml-config.cmake.in/g' \127        -e 's/(^[[:space:]]| [ab]\/)src\/ggml-cpu\/cmake\/FindSIMD.cmake/\1ggml\/src\/ggml-cpu\/cmake\/FindSIMD.cmake/g' \128        -e 's/([[:space:]]| [ab]\/)src\/ggml(.*)/\1ggml\/src\/ggml\2/g' \129        -e 's/(^[[:space:]]| [ab]\/)include\/ggml(.*)\.h/\1ggml\/include\/ggml\2.h/g' \130        -e 's/(^[[:space:]]| [ab]\/)include\/gguf(.*)\.h/\1ggml\/include\/gguf\2.h/g' \131        -e 's/(^[[:space:]]| [ab]\/)examples\/common\.h/\1examples\/common.h/g' \132        -e 's/(^[[:space:]]| [ab]\/)examples\/common\.cpp/\1examples\/common.cpp/g' \133        -e 's/(^[[:space:]]| [ab]\/)examples\/common-ggml\.h/\1examples\/common-ggml.h/g' \134        -e 's/(^[[:space:]]| [ab]\/)examples\/common-ggml\.cpp/\1examples\/common-ggml.cpp/g' \135        -e 's/(^[[:space:]]| [ab]\/)LICENSE/\1LICENSE/g' \136        -e 's/(^[[:space:]]| [ab]\/)scripts\/gen-authors\.sh/\1scripts\/gen-authors.sh/g' \137        > ggml-src.patch.tmp138    mv ggml-src.patch.tmp ggml-src.patch139 140    git am ggml-src.patch141 142    rm -v $SRC_WHISPER/ggml-src.patch143fi144 145# update last commit146cd $SRC_GGML147git log -1 --format=%H > $SRC_WHISPER/scripts/sync-ggml.last148 149echo "Done"150 151exit 0152