]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
scripts : improve llama sync patch
authorGeorgi Gerganov <redacted>
Sun, 24 Dec 2023 13:49:12 +0000 (15:49 +0200)
committerGeorgi Gerganov <redacted>
Sun, 24 Dec 2023 13:56:47 +0000 (15:56 +0200)
scripts/sync-llama-am.sh

index 3d8b08f81c030503cf666b5e0c3998b5316ae17d..d876c8bde2f645eac11ac04520526a51c89d0de8 100755 (executable)
@@ -29,50 +29,93 @@ cd $SRC_LLAMA
 git log --oneline $lc..HEAD
 
 git format-patch $lc --stdout -- \
+    ggml*.h \
     ggml*.c \
     ggml*.cpp \
     ggml*.m \
     ggml*.metal \
     ggml*.cu \
-    tests/tests-opt.cpp \
-    tests/tests-grad0.cpp \
-    tests/tests-backend-ops.cpp \
+    tests/test-opt.cpp \
+    tests/test-grad0.cpp \
+    tests/test-quantize-fns.cpp \
+    tests/test-quantize-perf.cpp \
+    tests/test-backend-ops.cpp \
     > $SRC_GGML/llama-src.patch
 
-git format-patch $lc --stdout -- \
-    ggml*.h \
-    > $SRC_GGML/llama-inc.patch
-
 # delete files if empty
 if [ ! -s $SRC_GGML/llama-src.patch ]; then
     rm -v $SRC_GGML/llama-src.patch
 fi
 
-if [ ! -s $SRC_GGML/llama-inc.patch ]; then
-    rm -v $SRC_GGML/llama-inc.patch
-fi
-
 cd $SRC_GGML
 
 if [ -f $SRC_GGML/llama-src.patch ]; then
     # replace PR numbers
+    #
     # Subject: some text (#1234)
     # Subject: some text (llama/1234)
     cat llama-src.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (llama\/\2)/' > llama-src.patch.tmp
     mv llama-src.patch.tmp llama-src.patch
 
-    git am -p1 --directory src llama-src.patch
-
-    rm -v $SRC_GGML/llama-src.patch
-fi
-
-if [ -f $SRC_GGML/llama-inc.patch ]; then
-    cat llama-inc.patch | sed -e 's/^Subject: \(.*\) (#\([0-9]*\))/Subject: \1 (llama\/\2)/' > llama-inc.patch.tmp
-    mv llama-inc.patch.tmp llama-inc.patch
+    # replace filenames:
+    #
+    # ggml.c              -> src/ggml.c
+    # ggml-alloc.c        -> src/ggml-alloc.c
+    # ggml-backend-impl.h -> src/ggml-backend-impl.h
+    # ggml-backend.c      -> src/ggml-backend.c
+    # ggml-cuda.cu        -> src/ggml-cuda.cu
+    # ggml-cuda.h         -> src/ggml-cuda.h
+    # ggml-impl.h         -> src/ggml-impl.h
+    # ggml-metal.h        -> src/ggml-metal.h
+    # ggml-metal.m        -> src/ggml-metal.m
+    # ggml-metal.metal    -> src/ggml-metal.metal
+    # ggml-mpi.h          -> src/ggml-mpi.h
+    # ggml-mpi.c          -> src/ggml-mpi.c
+    # ggml-opencl.cpp     -> src/ggml-opencl.cpp
+    # ggml-opencl.h       -> src/ggml-opencl.h
+    # ggml-quants.c       -> src/ggml-quants.c
+    # ggml-quants.h       -> src/ggml-quants.h
+    # ggml.h              -> include/ggml/ggml.h
+    # ggml-alloc.h        -> include/ggml/ggml-alloc.h
+    # ggml-backend.h      -> include/ggml/ggml-backend.h
+    #
+    # 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
+
+    cat llama-src.patch | sed \
+        -e 's/\/ggml\.c/\/src\/ggml.c/' \
+        -e 's/\/ggml-alloc\.c/\/src\/ggml-alloc.c/' \
+        -e 's/\/ggml-backend-impl\.h/\/src\/ggml-backend-impl.h/' \
+        -e 's/\/ggml-backend\.c/\/src\/ggml-backend.c/' \
+        -e 's/\/ggml-cuda\.cu/\/src\/ggml-cuda.cu/' \
+        -e 's/\/ggml-cuda\.h/\/src\/ggml-cuda.h/' \
+        -e 's/\/ggml-impl\.h/\/src\/ggml-impl.h/' \
+        -e 's/\/ggml-metal\.h/\/src\/ggml-metal.h/' \
+        -e 's/\/ggml-metal\.m/\/src\/ggml-metal.m/' \
+        -e 's/\/ggml-metal\.metal/\/src\/ggml-metal.metal/' \
+        -e 's/\/ggml-mpi\.h/\/src\/ggml-mpi.h/' \
+        -e 's/\/ggml-mpi\.c/\/src\/ggml-mpi.c/' \
+        -e 's/\/ggml-opencl\.cpp/\/src\/ggml-opencl.cpp/' \
+        -e 's/\/ggml-opencl\.h/\/src\/ggml-opencl.h/' \
+        -e 's/\/ggml-quants\.c/\/src\/ggml-quants.c/' \
+        -e 's/\/ggml-quants\.h/\/src\/ggml-quants.h/' \
+        -e 's/\/ggml\.h/\/include\/ggml\/ggml.h/' \
+        -e 's/\/ggml-alloc\.h/\/include\/ggml\/ggml-alloc.h/' \
+        -e 's/\/ggml-backend\.h/\/include\/ggml\/ggml-backend.h/' \
+        -e 's/\/tests\/test-opt\.cpp/\/tests\/test-opt.cpp/' \
+        -e 's/\/tests\/test-grad0\.cpp/\/tests\/test-grad0.cpp/' \
+        -e 's/\/tests\/test-quantize-fns\.cpp/\/tests\/test-quantize-fns.cpp/' \
+        -e 's/\/tests\/test-quantize-perf\.cpp/\/tests\/test-quantize-perf.cpp/' \
+        -e 's/\/tests\/test-backend-ops\.cpp/\/tests\/test-backend-ops.cpp/' \
+        > llama-src.patch.tmp
+    mv llama-src.patch.tmp llama-src.patch
 
-    git am -p1 --directory include/ggml llama-inc.patch
+    git am llama-src.patch
 
-    rm -v $SRC_GGML/llama-inc.patch
+    rm -v $SRC_GGML/llama-src.patch
 fi
 
 # update last commit