Skip to content

Commit

Permalink
metal : allow env metal variable to override resource path (#1415)
Browse files Browse the repository at this point in the history
* Allow env variable to override resource path

* Update ggml-metal.m

---------

Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
  • Loading branch information
codesoda and ggerganov authored Nov 3, 2023
1 parent a8cee86 commit 592aed1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion ggml-metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ static void ggml_metal_log(enum ggml_log_level level, const char* format, ...){
} else {
GGML_METAL_LOG_INFO("%s: default.metallib not found, loading from source\n", __func__);

NSString * sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"];
NSString * sourcePath;
NSString * ggmlMetalPathResources = [[NSProcessInfo processInfo].environment objectForKey:@"GGML_METAL_PATH_RESOURCES"];
if (ggmlMetalPathResources) {
sourcePath = [ggmlMetalPathResources stringByAppendingPathComponent:@"ggml-metal.metal"];
} else {
sourcePath = [bundle pathForResource:@"ggml-metal" ofType:@"metal"];
}
if (sourcePath == nil) {
GGML_METAL_LOG_WARN("%s: error: could not use bundle path to find ggml-metal.metal, falling back to trying cwd\n", __func__);
sourcePath = @"ggml-metal.metal";
Expand Down

0 comments on commit 592aed1

Please sign in to comment.