Skip to content

Commit f2f2838

Browse files
authored
metal : handle nil cv during pipeline creation (#16065)
ggml-ci
1 parent 62c3b64 commit f2f2838

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ggml/src/ggml-metal/ggml-metal-device.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,19 @@ ggml_metal_pipeline_t ggml_metal_library_compile_pipeline(ggml_metal_library_t l
327327

328328
GGML_LOG_DEBUG("%s: compiling pipeline: base = '%s', name = '%s'\n", __func__, base, name);
329329

330-
id<MTLFunction> mtl_function = [lib->obj newFunctionWithName:base_func constantValues:(cv ? cv->obj : nil) error:&error];
330+
id<MTLFunction> mtl_function;
331+
if (!cv) {
332+
mtl_function = [lib->obj newFunctionWithName:base_func];
333+
} else {
334+
mtl_function = [lib->obj newFunctionWithName:base_func constantValues:cv->obj error:&error];
335+
}
331336
if (!mtl_function) {
332337
ggml_critical_section_end();
333338

334339
GGML_LOG_ERROR("%s: error: failed to compile pipeline: base = '%s', name = '%s'\n", __func__, base, name);
335-
GGML_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
340+
if (error) {
341+
GGML_LOG_ERROR("%s: error: %s\n", __func__, [[error description] UTF8String]);
342+
}
336343

337344
return nil;
338345
}

0 commit comments

Comments
 (0)