diff --git a/ggml-metal.o b/ggml-metal.o new file mode 100644 index 00000000..00e044d8 Binary files /dev/null and b/ggml-metal.o differ diff --git a/llama/README.md b/llama/README.md index d7004086..a19d9c31 100644 --- a/llama/README.md +++ b/llama/README.md @@ -47,7 +47,7 @@ Install the [CUDA toolkit v11.3.1](https://developer.nvidia.com/cuda-11-3-1-down Build `ggml-cuda.dll`: ```shell -./cuda.sh +./build_cuda.sh ``` Then build the package with the `cuda` tag: @@ -63,7 +63,7 @@ Install [ROCm 5.7.1](https://rocm.docs.amd.com/en/docs-5.7.1/) and [Strawberry P Then, build `ggml-hipblas.dll`: ```shell -./hipblas.sh +./build_hipblas.sh ``` Then build the package with the `rocm` tag: diff --git a/llama/cuda.sh b/llama/build_cuda.sh similarity index 100% rename from llama/cuda.sh rename to llama/build_cuda.sh diff --git a/llama/hipblas.sh b/llama/build_hipblas.sh similarity index 100% rename from llama/hipblas.sh rename to llama/build_hipblas.sh diff --git a/llama/sync.sh b/scripts/sync_llama.sh similarity index 85% rename from llama/sync.sh rename to scripts/sync_llama.sh index 9e76672a..ef5a304a 100755 --- a/llama/sync.sh +++ b/scripts/sync_llama.sh @@ -3,8 +3,13 @@ # Set the source directory src_dir=$1 +if [ -z "$src_dir" ]; then + echo "Usage: $0 LLAMA_CPP_DIR" + exit 1 +fi + # Set the destination directory (current directory) -dst_dir="." +dst_dir=./llama # llama.cpp cp $src_dir/unicode.cpp $dst_dir/unicode.cpp @@ -40,20 +45,20 @@ cp $src_dir/ggml-cuda/*.cu $dst_dir/ggml-cuda/ cp $src_dir/ggml-cuda/*.cuh $dst_dir/ggml-cuda/ # apply patches -for patch in patches/*.patch; do +for patch in $dst_dir/patches/*.patch; do git apply "$patch" done # add license sha1=$(git -C $src_dir rev-parse @) -tempdir=$(mktemp) +TEMP_LICENSE=$(mktemp) cleanup() { - rm -f $tempdir + rm -f $TEMP_LICENSE } trap cleanup 0 -cat <$tempdir +cat <$TEMP_LICENSE /** * llama.cpp - git $sha1 * @@ -67,13 +72,13 @@ for IN in $dst_dir/*.{c,h,cpp,m,metal,cu}; do continue fi TMP=$(mktemp) - cat $tempdir $IN >$TMP + cat $TEMP_LICENSE $IN >$TMP mv $TMP $IN done # ggml-metal -sed -i '' '1s;^;//go:build darwin,arm64\n\n;' ggml-metal.m -sed -e '/#include "ggml-common.h"/r ggml-common.h' -e '/#include "ggml-common.h"/d' < ggml-metal.metal > temp.metal +sed -i '' '1s;^;// go:build darwin,arm64\n\n;' $dst_dir/ggml-metal.m +sed -e '/#include "ggml-common.h"/r ggml-common.h' -e '/#include "ggml-common.h"/d' < $dst_dir/ggml-metal.metal > temp.metal TEMP_ASSEMBLY=$(mktemp) echo ".section __DATA, __ggml_metallib" > $TEMP_ASSEMBLY echo ".globl _ggml_metallib_start" >> $TEMP_ASSEMBLY