2023-12-27 09:15:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Synchronize ggml changes to llama.cpp
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# $ cd /path/to/llama.cpp
|
2024-09-08 06:38:42 +00:00
|
|
|
# $ ./scripts/sync-ggml-am.sh -skip hash0,hash1,hash2... -C 3
|
2023-12-27 09:15:31 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
sd=$(dirname $0)
|
|
|
|
cd $sd/../
|
|
|
|
|
|
|
|
SRC_LLAMA=$(pwd)
|
|
|
|
SRC_GGML=$(cd ../ggml; pwd)
|
|
|
|
|
|
|
|
if [ ! -d $SRC_GGML ]; then
|
|
|
|
echo "ggml not found at $SRC_GGML"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
lc=$(cat $SRC_LLAMA/scripts/sync-ggml.last)
|
|
|
|
echo "Syncing ggml changes since commit $lc"
|
|
|
|
|
2024-01-14 09:08:09 +00:00
|
|
|
to_skip=""
|
2024-09-08 06:38:42 +00:00
|
|
|
|
|
|
|
# context for git patches in number of lines
|
|
|
|
ctx="8"
|
|
|
|
|
|
|
|
while [ "$1" != "" ]; do
|
|
|
|
case $1 in
|
|
|
|
-skip )
|
|
|
|
shift
|
|
|
|
to_skip=$1
|
|
|
|
;;
|
|
|
|
-C )
|
|
|
|
shift
|
|
|
|
ctx=$1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2024-01-14 09:08:09 +00:00
|
|
|
|
2023-12-27 09:15:31 +00:00
|
|
|
cd $SRC_GGML
|
|
|
|
|
2023-12-29 13:12:35 +00:00
|
|
|
git log --oneline $lc..HEAD
|
2024-01-03 09:25:54 +00:00
|
|
|
git log --oneline $lc..HEAD --reverse | grep -v "(llama/[0-9]*)" | cut -d' ' -f1 > $SRC_LLAMA/ggml-commits
|
2023-12-29 12:41:36 +00:00
|
|
|
|
|
|
|
if [ ! -s $SRC_LLAMA/ggml-commits ]; then
|
|
|
|
rm -v $SRC_LLAMA/ggml-commits
|
|
|
|
echo "No new commits"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f $SRC_LLAMA/ggml-src.patch ]; then
|
|
|
|
rm -v $SRC_LLAMA/ggml-src.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
while read c; do
|
2024-01-14 09:08:09 +00:00
|
|
|
if [ -n "$to_skip" ]; then
|
|
|
|
if [[ $to_skip == *"$c"* ]]; then
|
|
|
|
echo "Skipping $c"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-09-08 06:38:42 +00:00
|
|
|
git format-patch -U${ctx} -k $c~1..$c --stdout -- \
|
2024-06-26 15:33:02 +00:00
|
|
|
CMakeLists.txt \
|
|
|
|
src/CMakeLists.txt \
|
|
|
|
cmake/FindSIMD.cmake \
|
2023-12-29 12:41:36 +00:00
|
|
|
src/ggml*.h \
|
|
|
|
src/ggml*.c \
|
|
|
|
src/ggml*.cpp \
|
|
|
|
src/ggml*.m \
|
|
|
|
src/ggml*.metal \
|
|
|
|
src/ggml*.cu \
|
2024-08-08 11:56:52 +00:00
|
|
|
src/ggml-cann/* \
|
2024-04-07 13:08:12 +00:00
|
|
|
src/ggml-cuda/* \
|
2024-07-08 10:51:31 +00:00
|
|
|
src/ggml-sycl/* \
|
2024-08-04 16:13:25 +00:00
|
|
|
src/vulkan-shaders/* \
|
2024-06-26 15:33:02 +00:00
|
|
|
include/ggml*.h \
|
2023-12-29 12:41:36 +00:00
|
|
|
tests/test-opt.cpp \
|
|
|
|
tests/test-grad0.cpp \
|
|
|
|
tests/test-quantize-fns.cpp \
|
|
|
|
tests/test-quantize-perf.cpp \
|
|
|
|
tests/test-backend-ops.cpp \
|
2024-04-09 06:23:19 +00:00
|
|
|
LICENSE \
|
|
|
|
scripts/gen-authors.sh \
|
2023-12-29 12:41:36 +00:00
|
|
|
>> $SRC_LLAMA/ggml-src.patch
|
|
|
|
done < $SRC_LLAMA/ggml-commits
|
|
|
|
|
|
|
|
rm -v $SRC_LLAMA/ggml-commits
|
2023-12-27 09:15:31 +00:00
|
|
|
|
|
|
|
# delete files if empty
|
|
|
|
if [ ! -s $SRC_LLAMA/ggml-src.patch ]; then
|
|
|
|
rm -v $SRC_LLAMA/ggml-src.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $SRC_LLAMA
|
|
|
|
|
|
|
|
if [ -f $SRC_LLAMA/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-06-26 15:33:02 +00:00
|
|
|
# CMakelists.txt -> ggml/CMakeLists.txt
|
|
|
|
# src/CMakeLists.txt -> ggml/src/CMakeLists.txt
|
|
|
|
# cmake/FindSIMD.cmake -> ggml/cmake/FindSIMD.cmake
|
|
|
|
#
|
|
|
|
# src/ggml.c -> ggml/src/ggml.c
|
2024-07-27 14:19:35 +00:00
|
|
|
# src/ggml-aarch64.c -> ggml/src/ggml-aarch64.c
|
|
|
|
# src/ggml-aarch64.h -> ggml/src/ggml-aarch64.h
|
2024-06-26 15:33:02 +00:00
|
|
|
# src/ggml-alloc.c -> ggml/src/ggml-alloc.c
|
|
|
|
# src/ggml-backend-impl.h -> ggml/src/ggml-backend-impl.h
|
2024-10-02 23:49:47 +00:00
|
|
|
# src/ggml-backend.cpp -> ggml/src/ggml-backend.cpp
|
2024-08-08 11:56:52 +00:00
|
|
|
# src/ggml-cann/* -> ggml/src/ggml-cann/
|
|
|
|
# src/ggml-cann.cpp -> ggml/src/ggml-cann.cpp
|
2024-06-26 15:33:02 +00:00
|
|
|
# src/ggml-common.h -> ggml/src/ggml-common.h
|
|
|
|
# src/ggml-cuda/* -> ggml/src/ggml-cuda/
|
|
|
|
# src/ggml-cuda.cu -> ggml/src/ggml-cuda.cu
|
|
|
|
# src/ggml-impl.h -> ggml/src/ggml-impl.h
|
|
|
|
# src/ggml-kompute.cpp -> ggml/src/ggml-kompute.cpp
|
|
|
|
# src/ggml-metal.m -> ggml/src/ggml-metal.m
|
|
|
|
# src/ggml-quants.c -> ggml/src/ggml-quants.c
|
|
|
|
# src/ggml-quants.h -> ggml/src/ggml-quants.h
|
|
|
|
# src/ggml-rpc.cpp -> ggml/src/ggml-rpc.cpp
|
2024-07-08 10:51:31 +00:00
|
|
|
# src/ggml-sycl/* -> ggml/src/ggml-sycl/
|
2024-06-26 15:33:02 +00:00
|
|
|
# src/ggml-sycl.cpp -> ggml/src/ggml-sycl.cpp
|
|
|
|
# src/ggml-vulkan.cpp -> ggml/src/ggml-vulkan.cpp
|
2024-07-27 15:08:31 +00:00
|
|
|
# src/vulkan-shaders/* -> ggml/src/vulkan-shaders/
|
2024-06-26 15:33:02 +00:00
|
|
|
#
|
|
|
|
# include/ggml.h -> ggml/include/ggml.h
|
|
|
|
# include/ggml-alloc.h -> ggml/include/ggml-alloc.h
|
|
|
|
# include/ggml-backend.h -> ggml/include/ggml-backend.h
|
|
|
|
# include/ggml-blas.h -> ggml/include/ggml-blas.h
|
2024-08-08 11:56:52 +00:00
|
|
|
# include/ggml-cann.h -> ggml/include/ggml-cann.h
|
2024-06-26 15:33:02 +00:00
|
|
|
# include/ggml-cuda.h -> ggml/include/ggml-cuda.h
|
|
|
|
# include/ggml-kompute.h -> ggml/include/ggml-kompute.h
|
|
|
|
# include/ggml-metal.h -> ggml/include/ggml-metal.h
|
|
|
|
# include/ggml-rpc.h -> ggml/include/ggml-rpc.h
|
|
|
|
# include/ggml-sycl.h -> ggml/include/ggml-sycl.h
|
|
|
|
# include/ggml-vulkan.h -> ggml/include/ggml-vulkan.h
|
2023-12-27 09:15:31 +00:00
|
|
|
#
|
|
|
|
# tests/test-opt.cpp -> tests/test-opt.cpp
|
|
|
|
# tests/test-grad0.cpp -> tests/test-grad0.cpp
|
|
|
|
# tests/test-quantize-fns.cpp -> tests/test-quantize-fns.cpp
|
|
|
|
# tests/test-quantize-perf.cpp -> tests/test-quantize-perf.cpp
|
|
|
|
# tests/test-backend-ops.cpp -> tests/test-backend-ops.cpp
|
2024-04-09 06:23:19 +00:00
|
|
|
#
|
2024-06-26 15:33:02 +00:00
|
|
|
# LICENSE -> LICENSE
|
|
|
|
# scripts/gen-authors.sh -> scripts/gen-authors.sh
|
2023-12-27 09:15:31 +00:00
|
|
|
|
2024-06-26 20:25:22 +00:00
|
|
|
cat ggml-src.patch | sed -E \
|
|
|
|
-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' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml\.c/\1ggml\/src\/ggml.c/g' \
|
2024-07-27 14:19:35 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-aarch64\.c/\1ggml\/src\/ggml-aarch64.c/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-aarch64\.h/\1ggml\/src\/ggml-aarch64.h/g' \
|
2024-06-26 20:25:22 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-alloc\.c/\1ggml\/src\/ggml-alloc.c/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-backend-impl\.h/\1ggml\/src\/ggml-backend-impl.h/g' \
|
2024-10-02 23:49:47 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-backend\.cpp/\1ggml\/src\/ggml-backend.cpp/g' \
|
2024-08-08 11:56:52 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-cann\//\1ggml\/src\/ggml-cann\//g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-cann\.cpp/\1ggml\/src\/ggml-cann.cpp/g' \
|
2024-06-26 20:25:22 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-common\.h/\1ggml\/src\/ggml-common.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-cuda\//\1ggml\/src\/ggml-cuda\//g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-cuda\.cu/\1ggml\/src\/ggml-cuda.cu/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-impl\.h/\1ggml\/src\/ggml-impl.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-kompute\.cpp/\1ggml\/src\/ggml-kompute.cpp/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-metal\.m/\1ggml\/src\/ggml-metal.m/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-quants\.c/\1ggml\/src\/ggml-quants.c/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-quants\.h/\1ggml\/src\/ggml-quants.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-rpc\.cpp/\1ggml\/src\/ggml-rpc.cpp/g' \
|
2024-07-08 10:51:31 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-sycl\//\1ggml\/src\/ggml-sycl\//g' \
|
2024-06-26 20:25:22 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-sycl\.cpp/\1ggml\/src\/ggml-sycl.cpp/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/ggml-vulkan\.cpp/\1ggml\/src\/ggml-vulkan.cpp/g' \
|
2024-07-27 15:08:31 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)src\/vulkan-shaders\//\1ggml\/src\/vulkan-shaders\//g' \
|
2024-06-26 20:25:22 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml\.h/\1ggml\/include\/ggml.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-alloc\.h/\1ggml\/include\/ggml-alloc.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-backend\.h/\1ggml\/include\/ggml-backend.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-blas\.h/\1ggml\/include\/ggml-blas.h/g' \
|
2024-08-08 11:56:52 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-cann\.h/\1ggml\/include\/ggml-cann.h/g' \
|
2024-06-26 20:25:22 +00:00
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-cuda\.h/\1ggml\/include\/ggml-cuda.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-kompute\.h/\1ggml\/include\/ggml-kompute.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-metal\.h/\1ggml\/include\/ggml-metal.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-rpc\.h/\1ggml\/include\/ggml-rpc.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-sycl\.h/\1ggml\/include\/ggml-sycl.h/g' \
|
|
|
|
-e 's/([[:space:]]|[ab]\/)include\/ggml-vulkan\.h/\1ggml\/include\/ggml-vulkan.h/g' \
|
2024-08-08 11:40:12 +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-27 09:15:31 +00:00
|
|
|
> ggml-src.patch.tmp
|
|
|
|
mv ggml-src.patch.tmp ggml-src.patch
|
|
|
|
|
2024-09-08 06:38:42 +00:00
|
|
|
git am -C${ctx} ggml-src.patch
|
2023-12-27 09:15:31 +00:00
|
|
|
|
|
|
|
rm -v $SRC_LLAMA/ggml-src.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
# update last commit
|
|
|
|
cd $SRC_GGML
|
|
|
|
git log -1 --format=%H > $SRC_LLAMA/scripts/sync-ggml.last
|
|
|
|
|
|
|
|
echo "Done"
|
|
|
|
|
|
|
|
exit 0
|