From 67f12ce0e1e7b03cfa1da35d9f30664e97155a2d Mon Sep 17 00:00:00 2001 From: jhen Date: Fri, 11 Aug 2023 07:03:32 +0800 Subject: [PATCH] fix: use LM_GGML_USE_METAL to check ggml-metal not enabled --- ios/RNLlamaContext.mm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ios/RNLlamaContext.mm b/ios/RNLlamaContext.mm index 2a279dc2..d01f168f 100644 --- a/ios/RNLlamaContext.mm +++ b/ios/RNLlamaContext.mm @@ -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 device = MTLCreateSystemDefaultDevice(); @@ -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];