7
7
#include < vector>
8
8
#include < algorithm>
9
9
10
- #undef assert
11
- #define assert (__expr ) do { if (!(__expr)) { printf (" %s:%d (%s) %s\n " , __FILE__, __LINE__, __func__, #__expr); exit (1 ); } } while (0 )
12
10
13
11
void dump (const llama_token_data_array * candidates) {
14
12
for (size_t i = 0 ; i < candidates->size ; i++) {
@@ -32,9 +30,9 @@ void test_top_k(const std::vector<float> & probs,
32
30
33
31
llama_token_data_array candidates_p = { candidates.data (), candidates.size (), false };
34
32
llama_sample_softmax (nullptr , &candidates_p);
35
- // DUMP(&candidates_p);
33
+ DUMP (&candidates_p);
36
34
llama_sample_top_k (nullptr , &candidates_p, k);
37
- // DUMP(&candidates_p);
35
+ DUMP (&candidates_p);
38
36
39
37
assert (candidates_p.size == expected_probs.size ());
40
38
for (size_t i = 0 ; i < candidates_p.size ; i++) {
@@ -57,9 +55,9 @@ void test_top_p(const std::vector<float> & probs,
57
55
58
56
llama_token_data_array candidates_p = { candidates.data (), candidates.size (), false };
59
57
llama_sample_softmax (nullptr , &candidates_p);
60
- // DUMP(&candidates_p);
58
+ DUMP (&candidates_p);
61
59
llama_sample_top_p (nullptr , &candidates_p, p);
62
- // DUMP(&candidates_p);
60
+ DUMP (&candidates_p);
63
61
64
62
assert (candidates_p.size == expected_probs.size ());
65
63
for (size_t i = 0 ; i < candidates_p.size ; i++) {
@@ -80,9 +78,9 @@ void test_tfs(const std::vector<float> & probs,
80
78
}
81
79
82
80
llama_token_data_array candidates_p = { candidates.data (), candidates.size (), false };
83
- // DUMP(&candidates_p);
81
+ DUMP (&candidates_p);
84
82
llama_sample_tail_free (nullptr , &candidates_p, z);
85
- // DUMP(&candidates_p);
83
+ DUMP (&candidates_p);
86
84
87
85
assert (candidates_p.size == expected_probs.size ());
88
86
for (size_t i = 0 ; i < candidates_p.size ; i++) {
@@ -103,9 +101,9 @@ void test_typical(const std::vector<float> & probs,
103
101
}
104
102
105
103
llama_token_data_array candidates_p = { candidates.data (), candidates.size (), false };
106
- // DUMP(&candidates_p);
104
+ DUMP (&candidates_p);
107
105
llama_sample_typical (nullptr , &candidates_p, p);
108
- // DUMP(&candidates_p);
106
+ DUMP (&candidates_p);
109
107
110
108
assert (candidates_p.size == expected_probs.size ());
111
109
for (size_t i = 0 ; i < candidates_p.size ; i++) {
0 commit comments