Skip to content

Commit

Permalink
metal : use SWIFT_PACKAGE def instead of define GGML_SWIFT
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Oct 7, 2023
1 parent 1b88cba commit b569ddb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.gcno
*.gcda
*.dot
*.metallib
.DS_Store
.build/
.cache/
Expand Down
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ let resources: [Resource] = [
let additionalSources: [String] = ["ggml-metal.m"]
let additionalSettings: [CSetting] = [
.unsafeFlags(["-fno-objc-arc"]),
.define("GGML_SWIFT"),
.define("GGML_USE_METAL")
]
#else
let platforms: [SupportedPlatform]? = nil
let exclude: [String] = ["ggml-metal.metal"]
let resources: [String] = []
let resources: [Resource] = []
let additionalSources: [String] = []
let additionalSettings: [CSetting] = []
#endif
Expand Down
6 changes: 3 additions & 3 deletions ggml-metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static void ggml_metal_log(enum ggml_log_level level, const char* format, ...){
// load library
{
NSBundle * bundle = nil;
#ifdef GGML_SWIFT
#ifdef SWIFT_PACKAGE
bundle = SWIFTPM_MODULE_BUNDLE;
#else
bundle = [NSBundle bundleForClass:[GGMLMetalClass class]];
Expand All @@ -204,7 +204,7 @@ static void ggml_metal_log(enum ggml_log_level level, const char* format, ...){
GGML_METAL_LOG_INFO("%s: loading '%s'\n", __func__, [sourcePath UTF8String]);
NSString * src = [NSString stringWithContentsOfFile:sourcePath encoding:NSUTF8StringEncoding error:&error];
if (error) {
GGML_METAL_LOG_INFO("%s: error: %s\n", __func__, [[error description] UTF8String]);
GGML_METAL_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
return NULL;
}

Expand All @@ -217,7 +217,7 @@ static void ggml_metal_log(enum ggml_log_level level, const char* format, ...){
}

if (error) {
GGML_METAL_LOG_INFO("%s: error: %s\n", __func__, [[error description] UTF8String]);
GGML_METAL_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
return NULL;
}
}
Expand Down

0 comments on commit b569ddb

Please sign in to comment.