Skip to content

Commit a3a88fc

Browse files
authored
fix: avoid crash loading LoRAs with bf16 weights (#1077)
1 parent 8823dc4 commit a3a88fc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ggml_extend.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,10 +1400,14 @@ __STATIC_INLINE__ void ggml_ext_backend_tensor_get_and_sync(ggml_backend_t backe
14001400
}
14011401

14021402
__STATIC_INLINE__ float ggml_ext_backend_tensor_get_f32(ggml_tensor* tensor) {
1403-
GGML_ASSERT(tensor->type == GGML_TYPE_F32 || tensor->type == GGML_TYPE_F16 || tensor->type == GGML_TYPE_I32);
1403+
GGML_ASSERT(tensor->type == GGML_TYPE_F32 || tensor->type == GGML_TYPE_F16 || tensor->type == GGML_TYPE_I32 || tensor->type == GGML_TYPE_BF16);
14041404
float value;
14051405
if (tensor->type == GGML_TYPE_F32) {
14061406
ggml_backend_tensor_get(tensor, &value, 0, sizeof(value));
1407+
} else if (tensor->type == GGML_TYPE_BF16) {
1408+
ggml_bf16_t bf16_value;
1409+
ggml_backend_tensor_get(tensor, &bf16_value, 0, sizeof(bf16_value));
1410+
value = ggml_bf16_to_fp32(bf16_value);
14071411
} else if (tensor->type == GGML_TYPE_F16) {
14081412
ggml_fp16_t f16_value;
14091413
ggml_backend_tensor_get(tensor, &f16_value, 0, sizeof(f16_value));

0 commit comments

Comments
 (0)