]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
metal : print error of load pipeline state (#2564)
authorJhen-Jie Hong <redacted>
Wed, 16 Aug 2023 20:09:03 +0000 (04:09 +0800)
committerGitHub <redacted>
Wed, 16 Aug 2023 20:09:03 +0000 (23:09 +0300)
* metal : print error of load pipeline state

* metal : return null if load pipeline failed

ggml-metal.m

index 32c6e486985ffc95829d39dc9fdafd195f67b08b..d23fff1dde8503bd6ce309f00efb92a5cfeab2a9 100644 (file)
@@ -163,10 +163,15 @@ struct ggml_metal_context * ggml_metal_init(int n_cb) {
 
     // load kernels
     {
+        NSError * error = nil;
 #define GGML_METAL_ADD_KERNEL(name) \
         ctx->function_##name = [ctx->library newFunctionWithName:@"kernel_"#name]; \
-        ctx->pipeline_##name = [ctx->device newComputePipelineStateWithFunction:ctx->function_##name error:nil]; \
-        fprintf(stderr, "%s: loaded %-32s %16p\n", __func__, "kernel_"#name, (void *) ctx->pipeline_##name);
+        ctx->pipeline_##name = [ctx->device newComputePipelineStateWithFunction:ctx->function_##name error:&error]; \
+        fprintf(stderr, "%s: loaded %-32s %16p\n", __func__, "kernel_"#name, (void *) ctx->pipeline_##name); \
+        if (error) { \
+            fprintf(stderr, "%s: load pipeline error: %s\n", __func__, [[error description] UTF8String]); \
+            return NULL; \
+        }
 
         GGML_METAL_ADD_KERNEL(add);
         GGML_METAL_ADD_KERNEL(add_row);