Skip to content

Commit 592aed1

Browse files
codesodaggerganov
andauthored
metal : allow env metal variable to override resource path (#1415)
* Allow env variable to override resource path * Update ggml-metal.m --------- Co-authored-by: Georgi Gerganov <[email protected]>
1 parent a8cee86 commit 592aed1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ggml-metal.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,13 @@ static void ggml_metal_log(enum ggml_log_level level, const char* format, ...){
210210
} else {
211211
GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__);
212212

213-
NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"];
213+
NSString * sourcePath;
214+
NSString * ggmlMetalPathResources = [[NSProcessInfo processInfo].environment objectForKey:@"GGML_METAL_PATH_RESOURCES"];
215+
if (ggmlMetalPathResources) {
216+
sourcePath = [ggmlMetalPathResources stringByAppendingPathComponent:@"ggml-metal.metal"];
217+
} else {
218+
sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"];
219+
}
214220
if (sourcePath == nil) {
215221
GGML_METAL_LOG_WARN("%s: error: could not use bundle path to find ggml-metal.metal, falling back to trying cwd\n", __func__);
216222
sourcePath = @"ggml-metal.metal";

0 commit comments

Comments
 (0)