model-loader : support bool array sliding window pattern (#18850)

This commit is contained in:
Sigbjørn Skjæret
2026-01-15 10:12:46 +01:00
committed by GitHub
parent ec997b4f2b
commit 2a13180100
+8
View File
@@ -2,6 +2,7 @@
#include "ggml.h" #include "ggml.h"
#include <algorithm>
#include <array> #include <array>
#include <cinttypes> #include <cinttypes>
#include <cstring> #include <cstring>
@@ -344,6 +345,7 @@ namespace GGUFMeta {
GGUFMeta::GKV<GGUFMeta::ArrayInfo>::get_kv(ctx, kid); GGUFMeta::GKV<GGUFMeta::ArrayInfo>::get_kv(ctx, kid);
switch (arr_info.gt) { switch (arr_info.gt) {
case GGUF_TYPE_BOOL:
case GGUF_TYPE_UINT32: case GGUF_TYPE_UINT32:
case GGUF_TYPE_INT32: GGML_ASSERT((std::is_same<T, int32_t>::value) || case GGUF_TYPE_INT32: GGML_ASSERT((std::is_same<T, int32_t>::value) ||
(std::is_same<T, uint32_t>::value)); break; (std::is_same<T, uint32_t>::value)); break;
@@ -364,9 +366,15 @@ namespace GGUFMeta {
const T value = gguf_get_arr_str(ctx, kid, i); const T value = gguf_get_arr_str(ctx, kid, i);
result[i] = value; result[i] = value;
} }
} else {
if (arr_info.gt == GGUF_TYPE_BOOL) {
std::transform((const bool *)arr_info.data, (const bool *)arr_info.data + arr_info.length, result.begin(), [](bool x) {
return static_cast<T>(x);
});
} else { } else {
std::copy((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length, result.begin()); std::copy((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length, result.begin());
} }
}
return true; return true;
} }