Skip to content

Commit

Permalink
fix: use LM_GGML_USE_METAL to check ggml-metal not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Aug 10, 2023
1 parent d0858b1 commit 67f12ce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ios/RNLlamaContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ + (instancetype)initWithParams:(NSDictionary *)params {
NSString *reasonNoMetal = @"";
defaultParams.n_gpu_layers = 0;
if (params[@"n_gpu_layers"] && [params[@"n_gpu_layers"] intValue] > 0) {
#ifdef LM_GGML_USE_METAL
// Check ggml-metal availability
NSError * error = nil;
id<MTLDevice> device = MTLCreateSystemDefaultDevice();
Expand All @@ -43,6 +44,10 @@ + (instancetype)initWithParams:(NSDictionary *)params {
}
}
device = nil;
#else
reasonNoMetal = @"Metal is not enabled in this build";
isMetalEnabled = false;
#endif
}
if (params[@"n_batch"]) defaultParams.n_batch = [params[@"n_batch"] intValue];
if (params[@"use_mmap"]) defaultParams.use_mmap = [params[@"use_mmap"] boolValue];
Expand Down

0 comments on commit 67f12ce

Please sign in to comment.