Skip to content

Commit df36bce

Browse files
authored
eval-callback : stop on first NaN (#15320)
* eval-callback : stop on first NaN * cont : log error
1 parent f75b830 commit df36bce

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/eval-callback/eval-callback.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <cstdio>
88
#include <string>
99
#include <vector>
10+
#include <numeric>
1011

1112
/**
1213
* This the arbitrary data which will be passed to each callback.
@@ -77,6 +78,12 @@ static void ggml_print_tensor(uint8_t * data, ggml_type type, const int64_t * ne
7778
LOG(" ]\n");
7879
LOG(" sum = %f\n", sum);
7980
}
81+
82+
// TODO: make this abort configurable/optional?
83+
if (std::isnan(sum)) {
84+
LOG_ERR("encountered NaN - aborting\n");
85+
exit(0);
86+
}
8087
}
8188

8289
/**

0 commit comments

Comments
 (0)