@@ -31,12 +31,15 @@ float test_input_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
3131 {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 },
3232 // SQRT Kernel
3333 {1 , 4 , 9.6 , 16 , 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 , 225 , 256 , 289 , 324 , 361 , 400 , 441 , 484 , 529 , 576 , 625 , 676 , 729 , 784 , 841 , 900 , 961 , 1024 },
34+ // SQR Kernel
35+ {1 , 2.5 , 3 , 4 , 5.6 , 6 , 7 , 8 , 9.2 , 10 , 11 , 12 , 13 , 14 , 15.4 , 16 , 17 , 18 , 19 , 20 , 21.2 , 22 , 23 , 24 , 25 , 26 , 27 , 28 , 29 , 30 , 31 , 32 },
3436 // NEG Kernel
3537 {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 },
3638 // ABS Kernel
3739 {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 },
3840 // SIN Kernel
3941 {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+
4043};
4144float test_input_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
4245 // ADD KERNEL
@@ -50,6 +53,8 @@ float test_input_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
5053 // Below ROW value not used for Unary OPS-SQRT, NEG, ABS, SIN
5154 // SQRT KERNEL input not used
5255 {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 },
56+ // SQR KERNEL input not used
57+ {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 },
5358 // NEG KERNEL input not used
5459 {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 },
5560 // ABS KERNEL input not used
@@ -69,12 +74,15 @@ float test_result[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
6974 {1.0 , 2.0 , 2 , 0.5 , 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 },
7075 // SQRT Kernel
7176 {1 , 2 , 3.098387 , 4 , 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 },
77+ // SQR Kernel
78+ {1 , 6.25 , 9 , 16 , 31.36 , 36 , 49 , 64 , 84.64 , 100 , 121 , 144 , 169 , 196 , 237.16 , 256 , 289 , 324 , 361 , 400 , 449.44 , 484 , 529 , 576 , 625 , 676 , 729 , 784 , 841 , 900 , 961 , 1024 },
7279 // NEG Kernel
7380 {-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 },
7481 // ABS Kernel
7582 {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 },
7683 // SIN Kernel
7784 {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 }
85+
7886};
7987
8088float test_input_scale_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] = {
@@ -103,6 +111,12 @@ float test_input_scale_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
103111 4 , 8 , 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 , 0 ,
104112 4 , 8 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
105113 // SQRT KERNEL
114+ {1 , 1 , 1 , 1 , 1 , 1 , 1 , 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,12 @@ float test_input_scale_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
155169 2 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
156170 // Below ROW value not used for Unary OPS-SQRT, NEG, ABS, SIN
157171 // SQRT KERNEL input not used
172+ {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 ,
173+ 1 , 2 , 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 ,
174+ 1 , 2 , 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 ,
175+ 1 , 2 , 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 ,
176+ 1 , 2 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 },
177+ // SQR KERNEL input not used
158178 {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 ,
159179 1 , 2 , 1 , 1 , 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1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ,
232+ 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 },
233+ // SQR KERNEL
208234 {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 ,
209235 3 , 2 , 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 ,
210236 4 , 5 , 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 ,
@@ -398,6 +424,9 @@ static struct ggml_cgraph * build_graph(const simple_model& model, enum ggml_tsa
398424 case GGML_TSAVORITE_KERNEL_TYPE_SQRT:
399425 result = ggml_sqrt (ctx0, model.a );
400426 break ;
427+ case GGML_TSAVORITE_KERNEL_TYPE_SQR:
428+ result = ggml_sqr (ctx0, model.a );
429+ break ;
401430 case GGML_TSAVORITE_KERNEL_TYPE_NEG:
402431 result = ggml_neg (ctx0, model.a );
403432 break ;
@@ -451,6 +480,8 @@ enum ggml_tsavorite_kernel_type convert_testcase_to_ops_type (const char *testCa
451480 return GGML_TSAVORITE_KERNEL_TYPE_DIV;
452481 else if (!strcmp (testCase," sqrt" ))
453482 return GGML_TSAVORITE_KERNEL_TYPE_SQRT;
483+ else if (!strcmp (testCase," sqr" ))
484+ return GGML_TSAVORITE_KERNEL_TYPE_SQR;
454485 else if (!strcmp (testCase," neg" ))
455486 return GGML_TSAVORITE_KERNEL_TYPE_NEG;
456487 else if (!strcmp (testCase," abs" ))
@@ -462,6 +493,37 @@ enum ggml_tsavorite_kernel_type convert_testcase_to_ops_type (const char *testCa
462493 return GGML_TSAVORITE_KERNEL_TYPE_ADD;
463494}
464495
496+ const char * convert_ops_type_to_testcase (enum ggml_tsavorite_kernel_type ops_type) {
497+
498+ switch (ops_type) {
499+ case GGML_TSAVORITE_KERNEL_TYPE_ADD:
500+ return " add" ;
501+ case GGML_TSAVORITE_KERNEL_TYPE_SUB:
502+ return " sub" ;
503+ case GGML_TSAVORITE_KERNEL_TYPE_MULT:
504+ return " mult" ;
505+ case GGML_TSAVORITE_KERNEL_TYPE_DIV:
506+ return " div" ;
507+ case GGML_TSAVORITE_KERNEL_TYPE_SQRT:
508+ return " sqrt" ;
509+ case GGML_TSAVORITE_KERNEL_TYPE_SQR:
510+ return " sqr" ;
511+ case GGML_TSAVORITE_KERNEL_TYPE_NEG:
512+ return " neg" ;
513+ case GGML_TSAVORITE_KERNEL_TYPE_ABS:
514+ return " abs" ;
515+ case GGML_TSAVORITE_KERNEL_TYPE_SIN:
516+ return " sin" ;
517+ case GGML_TSAVORITE_KERNEL_TYPE_SIGMOID:
518+ return " sigmoid" ;
519+ case GGML_TSAVORITE_KERNEL_TYPE_SILU:
520+ return " silu" ;
521+ default :
522+ return " unknown" ;
523+ }
524+ }
525+
526+
465527int main (int argc, char *argv[]) {
466528 ggml_time_init ();
467529 bool test_case_flag = true ;
@@ -484,6 +546,7 @@ int main(int argc, char *argv[]) {
484546 ops_type = convert_testcase_to_ops_type (" add" );
485547 }
486548 if (ops_type == GGML_TSAVORITE_KERNEL_TYPE_SQRT ||
549+ ops_type == GGML_TSAVORITE_KERNEL_TYPE_SQR ||
487550 ops_type == GGML_TSAVORITE_KERNEL_TYPE_NEG ||
488551 ops_type == GGML_TSAVORITE_KERNEL_TYPE_ABS ||
489552 ops_type == GGML_TSAVORITE_KERNEL_TYPE_SIN)
@@ -551,7 +614,7 @@ int main(int argc, char *argv[]) {
551614
552615 // expected result:
553616
554- fprintf (stderr, " \n operation type: %d , num of elements %d \n " , ops_type, (int ) result->ne [0 ]);
617+ fprintf (stderr, " \n operation type: %s , num of elements %d \n " , convert_ops_type_to_testcase ( ops_type) , (int ) result->ne [0 ]);
555618
556619 fprintf (stderr, " \n compute is also done \n " );
557620 for (int i = 0 ; i < result->ne [0 ] /* cols */ ; i++) {
0 commit comments