2023-12-29 09:30:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Synchronize ggml changes to whisper.cpp
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# $ cd /path/to/whisper.cpp
|
2024-04-09 17:12:17 +00:00
|
|
|
# $ ./scripts/sync-ggml-am.sh -skip hash0,hash1,hash2...
|
2023-12-29 09:30:47 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
sd=$(dirname $0)
|
|
|
|
cd $sd/../
|
|
|
|
|
|
|
|
SRC_WHISPER=$(pwd)
|
|
|
|
SRC_GGML=$(cd ../ggml; pwd)
|
|
|
|
|
|
|
|
if [ ! -d $SRC_GGML ]; then
|
|
|
|
echo "ggml not found at $SRC_GGML"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-09 17:12:17 +00:00
|
|
|
lc=$(cat $SRC_WHISPER/scripts/sync-ggml.last)
|
2023-12-29 09:30:47 +00:00
|
|
|
echo "Syncing ggml changes since commit $lc"
|
|
|
|
|
2024-01-14 08:53:19 +00:00
|
|
|
to_skip=""
|
|
|
|
if [ "$1" == "-skip" ]; then
|
|
|
|
to_skip=$2
|
|
|
|
fi
|
|
|
|
|
2023-12-29 09:30:47 +00:00
|
|
|
cd $SRC_GGML
|
|
|
|
|
|
|
|
git log --oneline $lc..HEAD
|
2024-01-03 09:42:42 +00:00
|
|
|
git log --oneline $lc..HEAD --reverse | grep -v "(whisper/[0-9]*)" | cut -d' ' -f1 > $SRC_WHISPER/ggml-commits
|
2023-12-29 09:30:47 +00:00
|
|
|
|
2023-12-29 13:00:46 +00:00
|
|
|
if [ ! -s $SRC_WHISPER/ggml-commits ]; then
|
|
|
|
rm -v $SRC_WHISPER/ggml-commits
|
|
|
|
echo "No new commits"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $SRC_WHISPER/ggml-src.patch ]; then
|
|
|
|
rm -v $SRC_WHISPER/ggml-src.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
while read c; do
|
2024-01-14 08:53:19 +00:00
|
|
|
if [ -n "$to_skip" ]; then
|
|
|
|
if [[ $to_skip == *"$c"* ]]; then
|
|
|
|
echo "Skipping $c"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-12-29 13:00:46 +00:00
|
|
|
git format-patch -k $c~1..$c --stdout -- \
|
2024-06-26 16:34:09 +00:00
|
|
|
CMakeLists.txt \
|
|
|
|
src/CMakeLists.txt \
|
|
|
|
cmake/FindSIMD.cmake \
|
2023-12-29 13:00:46 +00:00
|
|
|
src/ggml*.h \
|
|
|
|
src/ggml*.c \
|
|
|
|
src/ggml*.cpp \
|
|
|
|
src/ggml*.m \
|
|
|
|
src/ggml*.metal \
|
|
|
|
src/ggml*.cu \
|
2024-10-31 20:13:24 +00:00
|
|
|
src/ggml-amx/* \
|
2024-08-08 19:58:13 +00:00
|
|
|
src/ggml-cann/* \
|
2024-04-07 13:10:44 +00:00
|
|
|
src/ggml-cuda/* \
|
2024-07-08 10:48:14 +00:00
|
|
|
src/ggml-sycl/* \
|
2024-08-20 08:27:12 +00:00
|
|
|
src/vulkan-shaders/* \
|
2024-06-26 16:34:09 +00:00
|
|
|
include/ggml*.h \
|
2024-01-03 09:42:42 +00:00
|
|
|
examples/common.h \
|
|
|
|
examples/common.cpp \
|
|
|
|
examples/common-ggml.h \
|
|
|
|
examples/common-ggml.cpp \
|
2024-04-09 17:25:50 +00:00
|
|
|
LICENSE \
|
|
|
|
scripts/gen-authors.sh \
|
2023-12-29 13:00:46 +00:00
|
|
|
>> $SRC_WHISPER/ggml-src.patch
|
|
|
|
done < $SRC_WHISPER/ggml-commits
|
|
|
|
|
|
|
|
rm -v $SRC_WHISPER/ggml-commits
|
2023-12-29 09:30:47 +00:00
|
|
|
|
|
|
|
# delete files if empty
|
|
|
|
if [ ! -s $SRC_WHISPER/ggml-src.patch ]; then
|
|
|
|
rm -v $SRC_WHISPER/ggml-src.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $SRC_WHISPER
|
|
|
|
|
|
|
|
if [ -f $SRC_WHISPER/ggml-src.patch ]; then
|
|
|
|
# replace PR numbers
|
|
|
|
#
|
|
|
|
# Subject: some text (#1234)
|
|
|
|
# Subject: some text (ggml/1234)
|
|
|
|
cat ggml-src.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (ggml\/\2)/' > ggml-src.patch.tmp
|
|
|
|
mv ggml-src.patch.tmp ggml-src.patch
|
|
|
|
|
|
|
|
cat ggml-src.patch | sed -e 's/^\(.*\) (#\([0-9]*\))$/\1 (ggml\/\2)/' > ggml-src.patch.tmp
|
|
|
|
mv ggml-src.patch.tmp ggml-src.patch
|
|
|
|
|
|
|
|
# replace filenames:
|
|
|
|
#
|
2024-09-24 10:27:33 +00:00
|
|
|
# CMakelists.txt -> ggml/CMakeLists.txt
|
|
|
|
# src/CMakeLists.txt -> ggml/src/CMakeLists.txt
|
|
|
|
# cmake/FindSIMD.cmake -> ggml/cmake/FindSIMD.cmake
|
2024-06-26 16:34:09 +00:00
|
|
|
#
|
2024-11-15 06:34:49 +00:00
|
|
|
# src/ggml*.c -> ggml/src/ggml*.c
|
|
|
|
# src/ggml*.cpp -> ggml/src/ggml*.cpp
|
|
|
|
# src/ggml*.h -> ggml/src/ggml*.h
|
|
|
|
# src/ggml*.cu -> ggml/src/ggml*.cu
|
|
|
|
# src/ggml*.m -> ggml/src/ggml*.m
|
2024-10-31 20:13:24 +00:00
|
|
|
# src/ggml-amx/* -> ggml/src/ggml-amx/
|
2024-08-08 19:58:13 +00:00
|
|
|
# src/ggml-cann/* -> ggml/src/ggml-cann/
|
2024-06-26 16:34:09 +00:00
|
|
|
# src/ggml-cuda/* -> ggml/src/ggml-cuda/
|
2024-07-08 10:48:14 +00:00
|
|
|
# src/ggml-sycl/* -> ggml/src/ggml-sycl/*
|
2024-08-08 11:00:51 +00:00
|
|
|
# src/vulkan-shaders/* -> ggml/src/vulkan-shaders/*
|
2024-06-26 16:34:09 +00:00
|
|
|
#
|
2024-11-15 06:34:49 +00:00
|
|
|
# include/ggml*.h -> ggml/include/ggml*.h
|
2023-12-29 09:30:47 +00:00
|
|
|
#
|
2024-09-24 10:27:33 +00:00
|
|
|
# examples/common.h -> examples/common.h
|
|
|
|
# examples/common.cpp -> examples/common.cpp
|
|
|
|
# examples/common-ggml.h -> examples/common-ggml.h
|
|
|
|
# examples/common-ggml.cpp -> examples/common-ggml.cpp
|
2024-04-09 17:25:50 +00:00
|
|
|
#
|
|
|
|
# LICENSE -> LICENSE
|
|
|
|
# ggml/scripts/gen-authors.sh -> scripts/gen-authors.sh
|
2023-12-29 09:30:47 +00:00
|
|
|
|
2024-06-26 20:20:19 +00:00
|
|
|
cat ggml-src.patch | sed -E \
|
2024-08-08 11:00:51 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)CMakeLists.txt/\1ggml\/CMakeLists.txt/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/CMakeLists.txt/\1ggml\/src\/CMakeLists.txt/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)cmake\/FindSIMD.cmake/\1ggml\/cmake\/FindSIMD.cmake/g' \
|
2024-11-15 06:34:49 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml(.*)\.c/\1ggml\/src\/ggml\2.c/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml(.*)\.cpp/\1ggml\/src\/ggml\2.cpp/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml(.*)\.h/\1ggml\/src\/ggml\2.h/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml(.*)\.cu/\1ggml\/src\/ggml\2.cu/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml(.*)\.m/\1ggml\/src\/ggml\2.m/g' \
|
2024-10-31 20:13:24 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml-amx\//\1ggml\/src\/ggml-amx\//g' \
|
2024-08-08 19:58:13 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml-cann\//\1ggml\/src\/ggml-cann\//g' \
|
2024-08-08 11:00:51 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml-cuda\//\1ggml\/src\/ggml-cuda\//g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml-kompute\.cpp/\1ggml\/src\/ggml-kompute.cpp/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/ggml-sycl\//\1ggml\/src\/ggml-sycl\//g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)src\/vulkan-shaders\//\1ggml\/src\/vulkan-shaders\//g' \
|
2024-11-15 06:34:49 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)include\/ggml(.*)\.h/\1ggml\/include\/ggml\2.h/g' \
|
2024-08-08 11:00:51 +00:00
|
|
|
-e 's/(^[[:space:]]|[ab]\/)examples\/common\.h/\1examples\/common.h/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)examples\/common\.cpp/\1examples\/common.cpp/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)examples\/common-ggml\.h/\1examples\/common-ggml.h/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)examples\/common-ggml\.cpp/\1examples\/common-ggml.cpp/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)LICENSE/\1LICENSE/g' \
|
|
|
|
-e 's/(^[[:space:]]|[ab]\/)scripts\/gen-authors\.sh/\1scripts\/gen-authors.sh/g' \
|
2023-12-29 09:30:47 +00:00
|
|
|
> ggml-src.patch.tmp
|
|
|
|
mv ggml-src.patch.tmp ggml-src.patch
|
|
|
|
|
|
|
|
git am ggml-src.patch
|
|
|
|
|
|
|
|
rm -v $SRC_WHISPER/ggml-src.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
# update last commit
|
|
|
|
cd $SRC_GGML
|
2024-04-09 17:12:17 +00:00
|
|
|
git log -1 --format=%H > $SRC_WHISPER/scripts/sync-ggml.last
|
2023-12-29 09:30:47 +00:00
|
|
|
|
|
|
|
echo "Done"
|
|
|
|
|
|
|
|
exit 0
|