ggml : fix bf16 (#31609)

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
EugeoSynthesisThirtyTwo 2026-11-04 09:10:22 +01:00 • committed by GitHub
parent 6900fb5ac8
commit 162e2bb2e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 8 deletions

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) {

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");
}