Skip to content

Commit 2075a66

Browse files
authored
metal : fix ggml_metal_supports_op for BF16 (#8021)
Currently the Metal backend does not support BF16. `ggml_metal_supports_op` was returning true in these cases, leading to a crash with models converted with `--leave-output-tensor`. This commit checks if the first few sources types are BF16 and returns false if that's the case.
1 parent ba58993 commit 2075a66

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ggml-metal.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,12 @@ static void ggml_metal_free(struct ggml_metal_context * ctx) {
735735
}
736736

737737
static bool ggml_metal_supports_op(const struct ggml_metal_context * ctx, const struct ggml_tensor * op) {
738+
for (size_t i = 0, n = 3; i < n; ++i) {
739+
if (op->src[i] != NULL && op->src[i]->type == GGML_TYPE_BF16) {
740+
return false;
741+
}
742+
}
743+
738744
switch (op->op) {
739745
case GGML_OP_UNARY:
740746
switch (ggml_get_unary_op(op)) {

0 commit comments

Comments
 (0)