@@ -38,11 +38,8 @@ float test_input_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
3838 // ABS Kernel
3939 {1.1 , -4.4 , 10 , -5 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , -23 , 24 , 25 , -26 , 27 , -28 , 29 , -30 , 31 , -32.6 },
4040 // SIN Kernel
41- {1.1 , 4.4 , 10 , 5 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 20 , 20 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32.6 },
42- // SIGMOID Kernel need to fix not tested
43- {1.1 , 4.4 , 10 , 5 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 20 , 20 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32.6 },
44- // SILU Kernel
45- {-16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 }
41+ {1.1 , 4.4 , 10 , 5 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 20 , 20 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32.6 }
42+
4643};
4744float test_input_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
4845 // ADD KERNEL
@@ -63,11 +60,7 @@ float test_input_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
6360 // ABS KERNEL input not used
6461 {1.1 , 2.2 , 5 , 10 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
6562 // SIN Kernel input not used
66- {1.1 , 2.2 , 5 , 10 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
67- // SIGMOID Kernel not used
68- {1.1 , 4.4 , 10 , 5 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 20 , 20 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32.6 },
69- // SILU Kernel not used
70- {-16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 }
63+ {1.1 , 2.2 , 5 , 10 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 }
7164};
7265
7366float test_result[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
@@ -88,11 +81,7 @@ float test_result[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
8881 // ABS Kernel
8982 {1.1 , 4.4 , 10 , 5 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32.6 },
9083 // SIN Kernel
91- {0.891207 , -0.951602 , -0.544021 , -0.958924 , -0.958924 , -0.279416 , 0.656987 , 0.989358 , 0.412118 , -0.544021 , -0.999990 , -0.536573 , 0.420167 , 0.990607 , 0.650288 , -0.287903 , -0.961398 , -0.750987 , 0.149877 , 0.912945 , 0.912945 , 0.912945 , -0.846220 , -0.905578 , -0.132352 , 0.762559 , 0.956376 , 0.270906 , -0.663634 , -0.988032 , -0.404039 , 0.926149 },
92- // SIGMOID Kernel not tested
93- {0.891207 , -0.951602 , -0.544021 , -0.958924 , -0.958924 , -0.279416 , 0.656987 , 0.989358 , 0.412118 , -0.544021 , -0.999990 , -0.536573 , 0.420167 , 0.990607 , 0.650288 , -0.287903 , -0.961398 , -0.750987 , 0.149877 , 0.912945 , 0.912945 , 0.912945 , -0.846220 , -0.905578 , -0.132352 , 0.762559 , 0.956376 , 0.270906 , -0.663634 , -0.988032 , -0.404039 , 0.926149 },
94- // SILU Kernel
95- {-0.000002 , -0.000005 , -0.000012 , -0.000029 , -0.000074 , -0.000184 , -0.000454 , -0.001111 , -0.002683 , -0.006377 , -0.014836 , -0.033464 , -0.071945 , -0.142278 , -0.238406 , -0.268941 , 0.000000 , 0.731059 , 1.761594 , 2.857722 , 3.928055 , 4.966536 , 5.985164 , 6.993623 , 7.997317 , 8.998889 , 9.999546 , 10.999816 , 11.999926 , 12.999971 , 13.999988 , 14.999995 }
84+ {0.891207 , -0.951602 , -0.544021 , -0.958924 , -0.958924 , -0.279416 , 0.656987 , 0.989358 , 0.412118 , -0.544021 , -0.999990 , -0.536573 , 0.420167 , 0.990607 , 0.650288 , -0.287903 , -0.961398 , -0.750987 , 0.149877 , 0.912945 , 0.912945 , 0.912945 , -0.846220 , -0.905578 , -0.132352 , 0.762559 , 0.956376 , 0.270906 , -0.663634 , -0.988032 , -0.404039 , 0.926149 }
9685
9786};
9887
@@ -150,15 +139,7 @@ float test_input_scale_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
150139 -9 , 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
151140 -16 , 25 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
152141 -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
153- -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
154- // SIGMOID KERNEL need to fix input data
155- {-1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
156- -9 , 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
157- -16 , 25 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
158- -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
159- -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
160- // SILU KERNEL
161- {-16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , -16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , -16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , -16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , 0.0 , 1.0 , 2.0 , 3.0 }
142+ -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }
162143};
163144
164145float test_input_scale_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] = {
@@ -216,15 +197,7 @@ float test_input_scale_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
216197 -9 , 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
217198 -16 , 25 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
218199 -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
219- -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
220- // SIGMOID KERNEL input not used
221- {-1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
222- -9 , 4 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
223- -16 , 25 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
224- -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
225- -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
226- // SILU KERNEL input not used
227- {-16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , -16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , -16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , -16.0 , -15.0 , -14.0 , -13.0 , -12.0 , -11.0 , -10.0 , -9.0 , -8.0 , -7.0 , -6.0 , -5.0 , -4.0 , -3.0 , -2.0 , -1.0 , 0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0 , 10.0 , 11.0 , 12.0 , 13.0 , 14.0 , 15.0 , 0.0 , 1.0 , 2.0 , 3.0 }
200+ -1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 }
228201};
229202float test_result_scale[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] = {
230203 // ADD KERNEL
@@ -290,25 +263,7 @@ float test_result_scale[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
290263 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
291264 -0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
292265 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
293- 0.841471 , 0.841471 , 0.841471 },
294- // SIGMOID KERNEL, result need to change
295- {-0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
296- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
297- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
298- -0.412118 ,-0.756802 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
299- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
300- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
301- 0.287903 ,-0.132352 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
302- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
303- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
304- -0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
305- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
306- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
307- -0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
308- 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 , 0.841471 ,
309- 0.841471 , 0.841471 , 0.841471 },
310- // SILU KERNEL
311- {-0.000002, -0.000005, -0.000012, -0.000029, -0.000074, -0.000184, -0.000454, -0.001111, -0.002683, -0.006377, -0.014836, -0.033464, -0.071945, -0.142278, -0.238406, -0.268941, 0.000000, 0.731059, 1.761594, 2.857722, 3.928055, 4.966536, 5.985164, 6.993623, 7.997317, 8.998889, 9.999546, 10.999816, 11.999926, 12.999971, 13.999988, 14.999995, -0.000002, -0.000005, -0.000012, -0.000029, -0.000074, -0.000184, -0.000454, -0.001111, -0.002683, -0.006377, -0.014836, -0.033464, -0.071945, -0.142278, -0.238406, -0.268941, 0.000000, 0.731059, 1.761594, 2.857722, 3.928055, 4.966536, 5.985164, 6.993623, 7.997317, 8.998889, 9.999546, 10.999816, 11.999926, 12.999971, 13.999988, 14.999995, -0.000002, -0.000005, -0.000012, -0.000029, -0.000074, -0.000184, -0.000454, -0.001111, -0.002683, -0.006377, -0.014836, -0.033464, -0.071945, -0.142278, -0.238406, -0.268941, 0.000000, 0.731059, 1.761594, 2.857722, 3.928055, 4.966536, 5.985164, 6.993623, 7.997317, 8.998889, 9.999546, 10.999816, 11.999926, 12.999971, 13.999988, 14.999995, -0.000002, -0.000005, -0.000012, -0.000029, -0.000074, -0.000184, -0.000454, -0.001111, -0.002683, -0.006377, -0.014836, -0.033464, -0.071945, -0.142278, -0.238406, -0.268941, 0.000000, 0.731059, 1.761594, 2.857722, 3.928055, 4.966536, 5.985164, 6.993623, 7.997317, 8.998889, 9.999546, 10.999816, 11.999926, 12.999971, 13.999988, 14.999995, 0.000000, 0.731059, 1.761594, 2.857722}
266+ 0.841471 , 0.841471 , 0.841471 }
312267};
313268
314269// This is a simple model with two tensors a and b
@@ -334,20 +289,26 @@ static void ggml_log_callback_default(ggml_log_level level, const char * text, v
334289 fflush (stderr);
335290}
336291
337-
338- // --- FLOAT COMPARATOR
339292static bool ggml_tsi_compare_two_float (float a, float b) {
340- // For very small values, use absolute error
341- if (fabsf (a) < 1e-2f && fabsf (b) < 1e-2f ) {
342- return fabsf (a - b) < 1e-6f ; // Accept up to 1e-6 difference for small values
293+ float epsilon = 1e-5 ;
294+ float absA = abs (a);
295+ float absB = abs (b);
296+ float diff = abs (a - b);
297+ float minV = std::numeric_limits<float >::min ();
298+ float maxV = std::numeric_limits<float >::max ();
299+
300+ if (a == b) { // shortcut, handles infinities
301+ return true ;
302+ } else if (a == 0 || b == 0 || (absA + absB < minV)) {
303+ // a or b is zero or both are extremely close to it
304+ // relative error is less meaningful here
305+ return diff < (epsilon * minV);
343306 }
344- // For larger values, use relative error
345- const float epsilon = 1e-4f ;
346- float diff = fabsf (a - b);
347- float max_val = fmaxf (fabsf (a), fabsf (b));
348- return diff < epsilon * max_val;
307+ // use relative error
308+ return diff /std::min ((absA + absB), maxV) < epsilon;
349309}
350310
311+
351312static bool load_model (simple_model & model, float * a, float * b, enum ggml_type data_type, int elements_A, int elements_B) {
352313 ggml_log_set (ggml_log_callback_default, nullptr );
353314
@@ -475,12 +436,6 @@ static struct ggml_cgraph * build_graph(const simple_model& model, enum ggml_tsa
475436 case GGML_TSAVORITE_KERNEL_TYPE_SIN:
476437 result = ggml_sin (ctx0, model.a );
477438 break ;
478- case GGML_TSAVORITE_KERNEL_TYPE_SIGMOID:
479- result = ggml_sigmoid (ctx0, model.a );
480- break ;
481- case GGML_TSAVORITE_KERNEL_TYPE_SILU:
482- result = ggml_silu (ctx0, model.a );
483- break ;
484439 default :
485440 ggml_free (ctx0);
486441 fprintf (stderr, " \n Non Supported Operation \n " );
@@ -533,10 +488,6 @@ enum ggml_tsavorite_kernel_type convert_testcase_to_ops_type (const char *testCa
533488 return GGML_TSAVORITE_KERNEL_TYPE_ABS;
534489 else if (!strcmp (testCase," sin" ))
535490 return GGML_TSAVORITE_KERNEL_TYPE_SIN;
536- else if (!strcmp (testCase," sigmoid" ))
537- return GGML_TSAVORITE_KERNEL_TYPE_SIGMOID;
538- else if (!strcmp (testCase," silu" ))
539- return GGML_TSAVORITE_KERNEL_TYPE_SILU;
540491
541492 fprintf (stderr, " \n un-supported test case %s hence running default test case which is add operation \n " , testCase);
542493 return GGML_TSAVORITE_KERNEL_TYPE_ADD;
@@ -572,8 +523,6 @@ const char* convert_ops_type_to_testcase(enum ggml_tsavorite_kernel_type ops_typ
572523 }
573524}
574525
575- // --- TEST HARNESS DEBUG BLOCK ---
576- #define DEBUG_COMPARE 1
577526
578527int main (int argc, char *argv[]) {
579528 ggml_time_init ();
@@ -600,9 +549,7 @@ int main(int argc, char *argv[]) {
600549 ops_type == GGML_TSAVORITE_KERNEL_TYPE_SQR ||
601550 ops_type == GGML_TSAVORITE_KERNEL_TYPE_NEG ||
602551 ops_type == GGML_TSAVORITE_KERNEL_TYPE_ABS ||
603- ops_type == GGML_TSAVORITE_KERNEL_TYPE_SIN ||
604- ops_type == GGML_TSAVORITE_KERNEL_TYPE_SIGMOID ||
605- ops_type == GGML_TSAVORITE_KERNEL_TYPE_SILU)
552+ ops_type == GGML_TSAVORITE_KERNEL_TYPE_SIN)
606553 num_of_input_tensors = NUM_INPUT_URINARY_TENSORS;
607554 else
608555 num_of_input_tensors = NUM_INPUT_TENSORS;
@@ -671,13 +618,6 @@ int main(int argc, char *argv[]) {
671618
672619 fprintf (stderr, " \n compute is also done \n " );
673620 for (int i = 0 ; i < result->ne [0 ] /* cols */ ; i++) {
674-
675- #if DEBUG_COMPARE
676- uint32_t bits_expected, bits_actual;
677- memcpy (&bits_expected, &result_data[ops_type][i], sizeof (float ));
678- memcpy (&bits_actual, &out_data[i], sizeof (float ));
679- fprintf (stderr, " Index %d: expected bits %08x, actual bits %08x\n " , i, bits_expected, bits_actual);
680- #endif
681621 if (ggml_tsi_compare_two_float (out_data[i], result_data[ops_type][i])) {
682622 continue ;
683623 }
0 commit comments