Skip to content

Commit ce293d8

Browse files
committed
tests : fix compile warnings
ggml-ci
1 parent 72dc7bf commit ce293d8

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

tests/test-gguf.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ enum handcrafted_file_type {
4848
HANDCRAFTED_DATA_CUSTOM_ALIGN = 810 + offset_has_data,
4949
};
5050

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) {
5252
switch (hft) {
5353
case HANDCRAFTED_HEADER_BAD_MAGIC: return "HEADER_BAD_MAGIC";
5454
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) {
9999

100100
typedef std::pair<enum ggml_type, std::array<int64_t, GGML_MAX_DIMS>> tensor_config_t;
101101

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) {
103103
std::vector<tensor_config_t> tensor_configs;
104104
tensor_configs.reserve(100);
105105

@@ -122,7 +122,7 @@ std::vector<tensor_config_t> get_tensor_configs(std::mt19937 & rng) {
122122
return tensor_configs;
123123
}
124124

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) {
126126
std::vector<std::pair<enum gguf_type, enum gguf_type>> kv_types;
127127
kv_types.reserve(100);
128128

@@ -626,8 +626,6 @@ static bool handcrafted_check_tensor_data(const gguf_context * gguf_ctx, const u
626626

627627
bool ok = true;
628628

629-
const uint32_t alignment = GGUF_DEFAULT_ALIGNMENT;
630-
631629
for (int i = 0; i < int(tensor_configs.size()); ++i) {
632630
const ggml_type type = tensor_configs[i].first;
633631
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
866864
case GGUF_TYPE_COUNT:
867865
default: {
868866
GGML_ABORT("fatal error");
869-
} break;
867+
}
870868
}
871869
} break;
872870
case GGUF_TYPE_COUNT:
873871
default: {
874872
GGML_ABORT("fatal error");
875-
} break;
873+
}
876874
}
877875
}
878876

@@ -938,7 +936,7 @@ static bool all_kv_in_other(const gguf_context * ctx, const gguf_context * other
938936
}
939937

940938
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);
942940
if (arr_n != gguf_get_arr_n(other, idx_other)) {
943941
ok = false;
944942
continue;
@@ -953,7 +951,7 @@ static bool all_kv_in_other(const gguf_context * ctx, const gguf_context * other
953951
if (type_arr == GGUF_TYPE_BOOL) {
954952
const int8_t * data = reinterpret_cast<const int8_t *>(gguf_get_arr_data(ctx, id));
955953
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) {
957955
if (bool(data[arr_i]) != bool(data_other[arr_i])) {
958956
ok = false;
959957
}
@@ -962,7 +960,7 @@ static bool all_kv_in_other(const gguf_context * ctx, const gguf_context * other
962960
}
963961

964962
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) {
966964
const std::string str = gguf_get_arr_str(ctx, id, arr_i);
967965
const std::string str_other = gguf_get_arr_str(other, idx_other, arr_i);
968966
if (str != str_other) {
@@ -1057,7 +1055,7 @@ static bool same_tensor_data(const struct ggml_context * orig, const struct ggml
10571055
ok = false;
10581056
}
10591057

1060-
return true;
1058+
return ok;
10611059
}
10621060

10631061
static std::pair<int, int> test_roundtrip(ggml_backend_dev_t dev, const unsigned int seed, const bool only_meta) {

tests/test-sampling.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ static void test_penalties(
144144

145145
sampler_tester tester(probs, probs_expected);
146146

147-
const size_t n_vocab = probs.size();
148147
auto * sampler = llama_sampler_init_penalties(last_tokens.size(), repeat_penalty, alpha_frequency, alpha_presence);
149148

150149
for (size_t i = 0; i < last_tokens.size(); i++) {

0 commit comments

Comments
 (0)