Skip to content

Commit

Permalink
Add late_abort option for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saharNooby committed Nov 12, 2023
1 parent 8622083 commit 8828869
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
9 changes: 8 additions & 1 deletion tests/assertions.inc
Expand Up @@ -3,12 +3,19 @@

#include <math.h>

bool late_abort = false;
bool must_abort = false;

#define ASSERT(x, ...) {\
if (!(x)) {\
fprintf(stderr, "*** Assertion failed ***\n");\
fprintf(stderr, __VA_ARGS__);\
fprintf(stderr, "\n%s:%d\n", __FILE__, __LINE__);\
abort();\
if (late_abort) {\
must_abort = true;\
} else {\
abort();\
}\
}\
}

Expand Down
2 changes: 0 additions & 2 deletions tests/logit_difference_validator.inc
Expand Up @@ -67,7 +67,6 @@ void test_model(const char * version, const char * format, const float * expecte

fprintf(stderr, "Serial difference sum: %f, expected %f\n", diff_sum, max_diff);

// When something breaks, difference would be way more than 10
ASSERT(fabsf(diff_sum) <= fabsf(max_diff) + 0.01F, "Too big serial difference %f, expected no more than %f", (double) diff_sum, (double) max_diff);

// ---
Expand All @@ -83,7 +82,6 @@ void test_model(const char * version, const char * format, const float * expecte

fprintf(stderr, "Sequence difference sum: %f, expected %f\n", diff_sum, max_diff);

// When something breaks, difference would be way more than 10
ASSERT(fabsf(diff_sum) <= fabsf(max_diff) + 0.01F, "Too big sequence difference %f, expected no more than %f", (double) diff_sum, (double) max_diff);

// ---
Expand Down
8 changes: 7 additions & 1 deletion tests/test_tiny_rwkv.c
Expand Up @@ -10,6 +10,8 @@
#define FORMAT_COUNT 7

int main(void) {
late_abort = true;

fprintf(stderr, "System info: %s\n", rwkv_get_system_info_string());

// Silences the overly verbose output during quantization.
Expand Down Expand Up @@ -87,7 +89,7 @@ int main(void) {
+000.065571F, // Q8_0
// 5v1
+119.471931F, // Q4_0
-027.862976F, // Q4_1
-008.245888F, // Q4_1
-159.870956F, // Q5_0
-039.117004F, // Q5_1
-000.962695F, // Q8_0
Expand Down Expand Up @@ -138,5 +140,9 @@ int main(void) {
free(expected_logits);
}

if (must_abort) {
abort();
}

return 0;
}

0 comments on commit 8828869

Please sign in to comment.