Skip to content

Commit a37748d

Browse files
committed
tests : free llama_sampling
1 parent fda1a97 commit a37748d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test-sampling.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static void test_top_k(const std::vector<float> & probs, const std::vector<float
3939
for (size_t i = 0; i < candidates_p.size; i++) {
4040
GGML_ASSERT(fabs(candidates_p.data[i].p - expected_probs[i]) < 1e-5);
4141
}
42+
43+
llama_sampling_free(smpl);
4244
}
4345

4446
static void test_top_p(const std::vector<float> & probs, const std::vector<float> & expected_probs, float p) {
@@ -62,6 +64,8 @@ static void test_top_p(const std::vector<float> & probs, const std::vector<float
6264
for (size_t i = 0; i < candidates_p.size; i++) {
6365
GGML_ASSERT(fabs(candidates_p.data[i].p - expected_probs[i]) < 1e-3);
6466
}
67+
68+
llama_sampling_free(smpl);
6569
}
6670

6771
static void test_tfs(const std::vector<float> & probs, const std::vector<float> & expected_probs, float z) {
@@ -84,6 +88,8 @@ static void test_tfs(const std::vector<float> & probs, const std::vector<float>
8488
for (size_t i = 0; i < candidates_p.size; i++) {
8589
GGML_ASSERT(fabs(candidates_p.data[i].p - expected_probs[i]) < 1e-3);
8690
}
91+
92+
llama_sampling_free(smpl);
8793
}
8894

8995
static void test_min_p(const std::vector<float> & probs, const std::vector<float> & expected_probs, float p) {
@@ -107,6 +113,8 @@ static void test_min_p(const std::vector<float> & probs, const std::vector<float
107113
for (size_t i = 0; i < candidates_p.size; i++) {
108114
GGML_ASSERT(fabs(candidates_p.data[i].p - expected_probs[i]) < 1e-3);
109115
}
116+
117+
llama_sampling_free(smpl);
110118
}
111119

112120
static void test_typical(const std::vector<float> & probs, const std::vector<float> & expected_probs, float p) {
@@ -129,6 +137,8 @@ static void test_typical(const std::vector<float> & probs, const std::vector<flo
129137
for (size_t i = 0; i < candidates_p.size; i++) {
130138
GGML_ASSERT(fabs(candidates_p.data[i].p - expected_probs[i]) < 1e-3);
131139
}
140+
141+
llama_sampling_free(smpl);
132142
}
133143

134144
static void test_repetition_penalties(
@@ -158,6 +168,8 @@ static void test_repetition_penalties(
158168
for (size_t i = 0; i < candidates_p.size; i++) {
159169
GGML_ASSERT(fabs(candidates_p.data[i].p - expected_probs[i]) < 1e-3);
160170
}
171+
172+
llama_sampling_free(smpl);
161173
}
162174

163175
static void test_sampler_queue(const size_t n_vocab, const std::string & samplers_sequence, const int top_k, const float top_p, const float min_p
@@ -241,6 +253,8 @@ static void test_sampler_queue(const size_t n_vocab, const std::string & sampler
241253

242254
printf("Sampler queue %3s OK with n_vocab=%05ld top_k=%05d top_p=%f min_p=%f\n",
243255
samplers_sequence.c_str(), n_vocab, top_k, top_p, min_p);
256+
257+
llama_sampling_free(smpl);
244258
}
245259

246260
int main(void) {

0 commit comments

Comments
 (0)