From dade596677b7c285f3cbdf661e47b8508a2ee447 Mon Sep 17 00:00:00 2001 From: Jhen Date: Wed, 25 Oct 2023 10:33:17 +0800 Subject: [PATCH] fix: rename metal resource for avoid conflict with whisper.rn --- cpp/{ggml-metal.metal => ggml-metal-llama.metal} | 0 cpp/ggml-metal.m | 2 +- scripts/bootstrap.sh | 3 ++- scripts/ggml-metal.m.patch | 11 +++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) rename cpp/{ggml-metal.metal => ggml-metal-llama.metal} (100%) create mode 100644 scripts/ggml-metal.m.patch diff --git a/cpp/ggml-metal.metal b/cpp/ggml-metal-llama.metal similarity index 100% rename from cpp/ggml-metal.metal rename to cpp/ggml-metal-llama.metal diff --git a/cpp/ggml-metal.m b/cpp/ggml-metal.m index b1336b9..ba7e743 100644 --- a/cpp/ggml-metal.m +++ b/cpp/ggml-metal.m @@ -208,7 +208,7 @@ static void lm_ggml_metal_log(enum lm_ggml_log_level level, const char* format, } else { LM_GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__); - NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"]; + NSString * sourcePath = [bundle pathForResource:@"ggml-metal-llama" ofType:@"metal"]; LM_GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]); NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error]; if (error) { diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 5c7b98a..6a310a0 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -12,7 +12,7 @@ cp ./llama.cpp/ggml.h ./cpp/ggml.h cp ./llama.cpp/ggml.c ./cpp/ggml.c cp ./llama.cpp/ggml-metal.h ./cpp/ggml-metal.h cp ./llama.cpp/ggml-metal.m ./cpp/ggml-metal.m -cp ./llama.cpp/ggml-metal.metal ./cpp/ggml-metal.metal +cp ./llama.cpp/ggml-metal.metal ./cpp/ggml-metal-llama.metal cp ./llama.cpp/ggml-alloc.h ./cpp/ggml-alloc.h cp ./llama.cpp/ggml-alloc.c ./cpp/ggml-alloc.c cp ./llama.cpp/ggml-backend.h ./cpp/ggml-backend.h @@ -69,3 +69,4 @@ yarn example # Apply patch patch -p0 -d ./cpp < ./scripts/log.h.patch patch -p0 -d ./cpp < ./scripts/llama.cpp.patch +patch -p0 -d ./cpp < ./scripts/ggml-metal.m.patch diff --git a/scripts/ggml-metal.m.patch b/scripts/ggml-metal.m.patch new file mode 100644 index 0000000..ea1c549 --- /dev/null +++ b/scripts/ggml-metal.m.patch @@ -0,0 +1,11 @@ +--- ggml-metal.m.orig 2023-10-25 10:31:15 ++++ ggml-metal.m 2023-10-25 10:31:37 +@@ -208,7 +208,7 @@ + } else { + LM_GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__); + +- NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"]; ++ NSString * sourcePath = [bundle pathForResource:@"ggml-metal-llama" ofType:@"metal"]; + LM_GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]); + NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error]; + if (error) {