fix: use int8_t for GGUF bool array loading instead of platform-dependent bool (#1648)
Upstream: llama.cpp#21428. GGUF stores bools as 1-byte int8_t but the loader was casting through (const bool*) which has implementation-defined sizeof. Use explicit int8_t cast with != 0 normalization. Co-authored-by: Mark Alonzo <mark.alonzo@outlook.com>
This commit is contained in:
parent
eaf83865a1
commit
a42f898d35
|
|
@ -724,8 +724,8 @@ bool llama_model_loader::get_arr(const std::string & key, std::vector<T> & resul
|
|||
|
||||
result.resize(arr_info.length);
|
||||
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); });
|
||||
std::transform((const int8_t *)arr_info.data, (const int8_t *)arr_info.data + arr_info.length, result.begin(),
|
||||
[] (int8_t x) { return static_cast<T>(x != 0); });
|
||||
|
||||
} else {
|
||||
result.assign((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length);
|
||||
|
|
@ -762,8 +762,8 @@ bool llama_model_loader::get_arr(const std::string & key, std::array<T, N_MAX> &
|
|||
}
|
||||
|
||||
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); });
|
||||
std::transform((const int8_t *)arr_info.data, (const int8_t *)arr_info.data + arr_info.length, result.begin(),
|
||||
[] (int8_t x) { return static_cast<T>(x != 0); });
|
||||
} else {
|
||||
std::copy((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length, result.begin());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue