File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ function(llama_add_test source)
5
5
add_test (NAME ${TEST_TARGET} COMMAND $< TARGET_FILE:${TEST_TARGET} > ${ARGN} )
6
6
endfunction ()
7
7
8
+ llama_add_test (test -double-float.c )
8
9
llama_add_test (test -quantize.c )
9
10
llama_add_test (test -tokenizer-0.cpp ${CMAKE_CURRENT_SOURCE_DIR} /../models/ggml-vocab.bin )
Original file line number Diff line number Diff line change
1
+ // These tests may take a long time!
2
+ // They are to prove that conversion from double to float of various functions in ggml.c doesn't affect the result.
3
+ // This is done by checking all finite (non-NaN, non-infinite) floats.
4
+
5
+ #undef NDEBUG
6
+ #include <assert.h>
7
+ #include <math.h>
8
+ #include <stdint.h>
9
+
10
+ #pragma GCC diagnostic push
11
+ #pragma GCC diagnostic ignored "-Wdouble-promotion"
12
+
13
+ // ggml.c::quantize_row_q4_0_reference
14
+ inline static uint8_t round_orig (float v0 ) { return ((int8_t ) (round (v0 ))) + 8 ; }
15
+
16
+ #pragma GCC diagnostic pop
17
+
18
+ // ggml.c::quantize_row_q4_0_reference
19
+ inline static uint8_t round_float (float v0 ) { return (int8_t )roundf (v0 ) + 8 ; }
20
+
21
+ int main (void ) {
22
+ uint32_t x = UINT32_MAX ;
23
+ do {
24
+ float f = * (float * )& x ;
25
+ assert (!isfinite (f ) || (round_orig (f ) == round_float (f )));
26
+ } while (x -- );
27
+ }
You can’t perform that action at this time.
0 commit comments