Skip to content

Commit 6a4069e

Browse files
Fix big endian detection
Restrict it to gcc and clang. msvc should not accidentally enable this code.
1 parent fca1298 commit 6a4069e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/llama-vocab.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,7 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
17651765
const size_t n_precompiled_charsmap = gguf_get_arr_n(ctx, precompiled_charsmap_keyidx);
17661766
const char * pc = (const char *) gguf_get_arr_data(ctx, precompiled_charsmap_keyidx);
17671767
precompiled_charsmap.assign(pc, pc + n_precompiled_charsmap);
1768+
#if defined(__GNUC__)
17681769
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
17691770
// correct endiannes of data in precompiled_charsmap binary blob
17701771
uint32_t * xcda_blob_size = (uint32_t *) &precompiled_charsmap[0];
@@ -1775,6 +1776,7 @@ void llama_vocab::impl::load(llama_model_loader & ml, const LLM_KV & kv) {
17751776
for (size_t i = 0; i < xcda_array_size; ++i) {
17761777
xcda_array[i] = __builtin_bswap32(xcda_array[i]);
17771778
}
1779+
#endif
17781780
#endif
17791781
}
17801782
} else if (tokenizer_model == "rwkv") {

0 commit comments

Comments
 (0)