ggerganov / ggml

Tensor library for machine learning
MIT License
11.31k stars 1.06k forks source link

GGUF files not portable depending on sizeof(enum ggml_type) #1038

Open JohannesGaessler opened 22 hours ago

JohannesGaessler commented 22 hours ago

GGUF files store an enum ggml_type for each ggml_tensor. The file reads and writes of this type are of size sizeof(enum ggml_type) bytes. To my knowledge the underlying datatype for enums is int so this is not portable if the size of int varies (though it should be 4 bytes on most platforms).

slaren commented 22 hours ago

The same applies to sizeof(bool). Additionally sizeof(float) and sizeof(double) may vary if __STDC_IEC_559__ is not defined. In practice it is not likely to cause issues in the supported platforms, but it would be good to fix it.