From f358dd5a1c332007ca5cd209fa486c732825c819 Mon Sep 17 00:00:00 2001 From: Gabe Goodhart Date: Thu, 26 Jun 2025 16:47:09 -0600 Subject: [PATCH] fix: Use mtmd_helper to correctly load the bitmap for the image Branch: GraniteFour Signed-off-by: Gabe Goodhart --- llama/llama.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llama/llama.go b/llama/llama.go index ecaa87199..ba1d1f2a4 100644 --- a/llama/llama.go +++ b/llama/llama.go @@ -14,6 +14,7 @@ package llama #include "ggml.h" #include "llama.h" #include "mtmd.h" +#include "mtmd-helper.h" #include "gguf.h" #include "sampling_ext.h" @@ -488,7 +489,7 @@ func (c *MtmdContext) NewEmbed(llamaContext *Context, data []byte) ([][]float32, defer C.mtmd_input_text_free(it) // Initialize a bitmap with the image data - bm := C.mtmd_bitmap_init(C.uint32_t(len(data)/3), C.uint32_t(1), (*C.uchar)(unsafe.Pointer(&data[0]))) + bm := C.mtmd_helper_bitmap_init_from_buf(c.c, (*C.uchar)(unsafe.Pointer(&data[0])), C.size_t(len(data))) defer C.mtmd_bitmap_free(bm) // Tokenize the image