@@ -48,7 +48,7 @@ enum handcrafted_file_type {
48
48
HANDCRAFTED_DATA_CUSTOM_ALIGN = 810 + offset_has_data,
49
49
};
50
50
51
- std::string handcrafted_file_type_name (const enum handcrafted_file_type hft) {
51
+ static std::string handcrafted_file_type_name (const enum handcrafted_file_type hft) {
52
52
switch (hft) {
53
53
case HANDCRAFTED_HEADER_BAD_MAGIC: return " HEADER_BAD_MAGIC" ;
54
54
case HANDCRAFTED_HEADER_BAD_VERSION_1: return " HEADER_BAD_VERSION_1" ;
@@ -99,7 +99,7 @@ static bool expect_context_not_null(const enum handcrafted_file_type hft) {
99
99
100
100
typedef std::pair<enum ggml_type, std::array<int64_t , GGML_MAX_DIMS>> tensor_config_t ;
101
101
102
- std::vector<tensor_config_t > get_tensor_configs (std::mt19937 & rng) {
102
+ static std::vector<tensor_config_t > get_tensor_configs (std::mt19937 & rng) {
103
103
std::vector<tensor_config_t > tensor_configs;
104
104
tensor_configs.reserve (100 );
105
105
@@ -122,7 +122,7 @@ std::vector<tensor_config_t> get_tensor_configs(std::mt19937 & rng) {
122
122
return tensor_configs;
123
123
}
124
124
125
- std::vector<std::pair<enum gguf_type, enum gguf_type>> get_kv_types (std::mt19937 rng) {
125
+ static std::vector<std::pair<enum gguf_type, enum gguf_type>> get_kv_types (std::mt19937 rng) {
126
126
std::vector<std::pair<enum gguf_type, enum gguf_type>> kv_types;
127
127
kv_types.reserve (100 );
128
128
@@ -626,8 +626,6 @@ static bool handcrafted_check_tensor_data(const gguf_context * gguf_ctx, const u
626
626
627
627
bool ok = true ;
628
628
629
- const uint32_t alignment = GGUF_DEFAULT_ALIGNMENT;
630
-
631
629
for (int i = 0 ; i < int (tensor_configs.size ()); ++i) {
632
630
const ggml_type type = tensor_configs[i].first ;
633
631
const std::array<int64_t , GGML_MAX_DIMS> shape = tensor_configs[i].second ;
@@ -866,13 +864,13 @@ static struct random_gguf_context_result get_random_gguf_context(ggml_backend_t
866
864
case GGUF_TYPE_COUNT:
867
865
default : {
868
866
GGML_ABORT (" fatal error" );
869
- } break ;
867
+ }
870
868
}
871
869
} break ;
872
870
case GGUF_TYPE_COUNT:
873
871
default : {
874
872
GGML_ABORT (" fatal error" );
875
- } break ;
873
+ }
876
874
}
877
875
}
878
876
@@ -938,7 +936,7 @@ static bool all_kv_in_other(const gguf_context * ctx, const gguf_context * other
938
936
}
939
937
940
938
if (type == GGUF_TYPE_ARRAY) {
941
- const int arr_n = gguf_get_arr_n (ctx, id);
939
+ const size_t arr_n = gguf_get_arr_n (ctx, id);
942
940
if (arr_n != gguf_get_arr_n (other, idx_other)) {
943
941
ok = false ;
944
942
continue ;
@@ -953,7 +951,7 @@ static bool all_kv_in_other(const gguf_context * ctx, const gguf_context * other
953
951
if (type_arr == GGUF_TYPE_BOOL) {
954
952
const int8_t * data = reinterpret_cast <const int8_t *>(gguf_get_arr_data (ctx, id));
955
953
const int8_t * data_other = reinterpret_cast <const int8_t *>(gguf_get_arr_data (other, idx_other));
956
- for (int arr_i = 0 ; arr_i < arr_n; ++arr_i) {
954
+ for (size_t arr_i = 0 ; arr_i < arr_n; ++arr_i) {
957
955
if (bool (data[arr_i]) != bool (data_other[arr_i])) {
958
956
ok = false ;
959
957
}
@@ -962,7 +960,7 @@ static bool all_kv_in_other(const gguf_context * ctx, const gguf_context * other
962
960
}
963
961
964
962
if (type_arr == GGUF_TYPE_STRING) {
965
- for (int arr_i = 0 ; arr_i < arr_n; ++arr_i) {
963
+ for (size_t arr_i = 0 ; arr_i < arr_n; ++arr_i) {
966
964
const std::string str = gguf_get_arr_str (ctx, id, arr_i);
967
965
const std::string str_other = gguf_get_arr_str (other, idx_other, arr_i);
968
966
if (str != str_other) {
@@ -1033,6 +1031,12 @@ static bool same_tensor_data(const struct ggml_context * orig, const struct ggml
1033
1031
1034
1032
struct ggml_tensor * t_orig = ggml_get_first_tensor (orig);
1035
1033
struct ggml_tensor * t_read = ggml_get_first_tensor (read);
1034
+
1035
+ if (std::string (t_read->name ) != " GGUF tensor data binary blob" ) {
1036
+ return false ;
1037
+ }
1038
+ t_read = ggml_get_next_tensor (read, t_read);
1039
+
1036
1040
while (t_orig) {
1037
1041
if (!t_read) {
1038
1042
ok = false ;
@@ -1051,13 +1055,13 @@ static bool same_tensor_data(const struct ggml_context * orig, const struct ggml
1051
1055
}
1052
1056
1053
1057
t_orig = ggml_get_next_tensor (orig, t_orig);
1054
- t_read = ggml_get_next_tensor (orig , t_read);
1058
+ t_read = ggml_get_next_tensor (read , t_read);
1055
1059
}
1056
1060
if (t_read) {
1057
1061
ok = false ;
1058
1062
}
1059
1063
1060
- return true ;
1064
+ return ok ;
1061
1065
}
1062
1066
1063
1067
static std::pair<int , int > test_roundtrip (ggml_backend_dev_t dev, const unsigned int seed, const bool only_meta) {
0 commit comments