ggml : fix bf16 (#31609)

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
EugeoSynthesisThirtyTwoandYour Name authored and GitHub committed 2026-11-04 10:10:22 +02:00
1 parent 6900fb5ac8
commit 162e2bb2e4
2 files changed
+7 -8

No files matched your search

+4 -6
View File
@@ -485,27 +485,25 @@ void ggml_fp16_to_fp32_row(const ggml_fp16_t * x, float * y, int64_t n) {
}
void ggml_fp32_to_fp16_row(const float * x, ggml_fp16_t * y, int64_t n) {
int i = 0;
for (; i < n; ++i) {
for (int64_t i = 0; i < n; i++) {
y[i] = GGML_FP32_TO_FP16(x[i]);
}
}
void ggml_bf16_to_fp32_row(const ggml_bf16_t * x, float * y, int64_t n) {
int i = 0;
for (; i < n; ++i) {
for (int64_t i = 0; i < n; i++) {
y[i] = GGML_BF16_TO_FP32(x[i]);
}
}
void ggml_fp32_to_bf16_row_ref(const float * x, ggml_bf16_t * y, int64_t n) {
for (int i = 0; i < n; i++) {
for (int64_t i = 0; i < n; i++) {
y[i] = ggml_compute_fp32_to_bf16(x[i]);
}
}
void ggml_fp32_to_bf16_row(const float * x, ggml_bf16_t * y, int64_t n) {
int i = 0;
int64_t i = 0;
#if defined(__AVX512BF16__)
// subnormals are flushed to zero on this platform
for (; i + 32 <= n; i += 32) {
+3 -2
View File
@@ -182,6 +182,8 @@ struct lora_merge_ctx {
ggml_type get_out_tensor_type(struct ggml_tensor * t) {
if (t->type == GGML_TYPE_F32) {
return GGML_TYPE_F32;
} else if (t->type == GGML_TYPE_BF16) {
return GGML_TYPE_BF16;
} else {
return GGML_TYPE_F16;
}
@@ -409,8 +411,7 @@ struct lora_merge_ctx {
static void print_usage(int, char ** argv) {
printf("\nexample usage:\n");
printf("\n %s -m base-model.gguf --lora lora-file.gguf -o merged-model-f16.gguf\n", argv[0]);
printf("\nNOTE: output model is F16\n");
printf("\n %s -m base-model.gguf --lora lora-file.gguf -o merged-model.gguf\n", argv[0]);
printf("\n");
}