summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJhen-Jie Hong <iainst0409@gmail.com>2023-08-17 04:09:03 +0800
committerGitHub <noreply@github.com>2023-08-16 23:09:03 +0300
commited53db86c3b0e0815331a96d7a379edb5e62472c (patch)
tree0fa06c72cb5292f8e8bc79396f69863e79d84465
parentfc8ef549e50087762a0b4f901cd74b2defcc6ae3 (diff)
metal : print error of load pipeline state (#2564)
* metal : print error of load pipeline state * metal : return null if load pipeline failed
-rw-r--r--ggml-metal.m9
1 files changed, 7 insertions, 2 deletions
diff --git a/ggml-metal.m b/ggml-metal.m
index 32c6e486..d23fff1d 100644
--- a/ggml-metal.m
+++ b/ggml-metal.m
@@ -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);