From ba421dd04ea4a878d0085ad093222f996afc1a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Sat, 18 Jan 2025 09:49:47 +0100 Subject: [PATCH] gguf-test: tensor data comparison --- ggml/src/gguf.cpp | 4 ++++ tests/test-gguf.cpp | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/ggml/src/gguf.cpp b/ggml/src/gguf.cpp index 655ed600a..ab13669c5 100644 --- a/ggml/src/gguf.cpp +++ b/ggml/src/gguf.cpp @@ -648,6 +648,10 @@ struct gguf_context * gguf_init_from_file_impl(FILE * file, struct gguf_init_par ok = ok && data != nullptr; + if (ok) { + ggml_set_name(data, "GGUF tensor data binary blob"); + } + // read the binary blob with the tensor data ok = ok && gr.read(data->data, ctx->size); diff --git a/tests/test-gguf.cpp b/tests/test-gguf.cpp index 2e39b5c1a..6ed696328 100644 --- a/tests/test-gguf.cpp +++ b/tests/test-gguf.cpp @@ -1031,6 +1031,12 @@ static bool same_tensor_data(const struct ggml_context * orig, const struct ggml struct ggml_tensor * t_orig = ggml_get_first_tensor(orig); struct ggml_tensor * t_read = ggml_get_first_tensor(read); + + if (std::string(t_read->name) != "GGUF tensor data binary blob") { + return false; + } + t_read = ggml_get_next_tensor(read, t_read); + while (t_orig) { if (!t_read) { ok = false;