Skip to content

Commit f571806

Browse files
Windows test fix
1 parent 4ab7bb7 commit f571806

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tests/test-sampling.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#include "llama.h"
2-
#include <assert.h>
3-
#include <math.h>
2+
#include "ggml.h"
3+
#include <cassert>
4+
#include <cmath>
45
#include <numeric>
56
#include <cassert>
67
#include <iostream>
78
#include <vector>
89
#include <algorithm>
910

10-
#undef assert
11-
#define assert(__expr) do { if (!(__expr)) { printf("%s:%d (%s) %s\n", __FILE__, __LINE__, __func__, #__expr); exit(1); } } while(0)
1211

1312
void dump(const llama_token_data_array * candidates) {
1413
for (size_t i = 0; i < candidates->size; i++) {
@@ -32,9 +31,9 @@ void test_top_k(const std::vector<float> & probs,
3231

3332
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
3433
llama_sample_softmax(nullptr, &candidates_p);
35-
// DUMP(&candidates_p);
34+
DUMP(&candidates_p);
3635
llama_sample_top_k(nullptr, &candidates_p, k);
37-
// DUMP(&candidates_p);
36+
DUMP(&candidates_p);
3837

3938
assert(candidates_p.size == expected_probs.size());
4039
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -57,9 +56,9 @@ void test_top_p(const std::vector<float> & probs,
5756

5857
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
5958
llama_sample_softmax(nullptr, &candidates_p);
60-
// DUMP(&candidates_p);
59+
DUMP(&candidates_p);
6160
llama_sample_top_p(nullptr, &candidates_p, p);
62-
// DUMP(&candidates_p);
61+
DUMP(&candidates_p);
6362

6463
assert(candidates_p.size == expected_probs.size());
6564
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -80,9 +79,9 @@ void test_tfs(const std::vector<float> & probs,
8079
}
8180

8281
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
83-
// DUMP(&candidates_p);
82+
DUMP(&candidates_p);
8483
llama_sample_tail_free(nullptr, &candidates_p, z);
85-
// DUMP(&candidates_p);
84+
DUMP(&candidates_p);
8685

8786
assert(candidates_p.size == expected_probs.size());
8887
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -103,9 +102,9 @@ void test_typical(const std::vector<float> & probs,
103102
}
104103

105104
llama_token_data_array candidates_p = { candidates.data(), candidates.size(), false };
106-
// DUMP(&candidates_p);
105+
DUMP(&candidates_p);
107106
llama_sample_typical(nullptr, &candidates_p, p);
108-
// DUMP(&candidates_p);
107+
DUMP(&candidates_p);
109108

110109
assert(candidates_p.size == expected_probs.size());
111110
for (size_t i = 0; i < candidates_p.size; i++) {
@@ -172,6 +171,8 @@ void test_frequency_presence_penalty(
172171
}
173172

174173
int main(void) {
174+
ggml_time_init();
175+
175176
test_top_k({0.1, 0.2, 0.3, 0.4}, {0.4}, 1);
176177
test_top_k({0.1, 0.2, 0.3, 0.4}, {0.4, 0.3, 0.2}, 3);
177178

0 commit comments

Comments
 (0)