From: Georgi Gerganov Date: Sun, 24 Dec 2023 13:49:12 +0000 (+0200) Subject: scripts : improve llama sync patch X-Git-Tag: upstream/0.0.1642~1165 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=3f6f696d9b4d1ae9e951dd0a824fb47c2472fd74;p=pkg%2Fggml%2Fsources%2Fggml scripts : improve llama sync patch --- diff --git a/scripts/sync-llama-am.sh b/scripts/sync-llama-am.sh index 3d8b08f8..d876c8bd 100755 --- a/scripts/sync-llama-am.sh +++ b/scripts/sync-llama-am.sh @@ -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