Skip to content

Commit 4d419c0

Browse files
author
Dinesh Reddy
committed
-Addressed PR review comments
Signed-off-by: Dinesh Reddy <dreddy@ws02.tsavoritesi.net>
1 parent 1ca8835 commit 4d419c0

File tree

2 files changed

+55
-4
lines changed

2 files changed

+55
-4
lines changed

examples/simple/simple-backend-tsi.cpp

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ float test_input_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
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},
3434
//SQR Kernel
35-
{1, 2, 3, 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},
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},
3636
//NEG Kernel
3737
{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},
3838
//ABS Kernel
@@ -53,6 +53,8 @@ float test_input_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
5353
//Below ROW value not used for Unary OPS-SQRT, NEG, ABS, SIN
5454
//SQRT KERNEL input not used
5555
{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},
5658
//NEG KERNEL input not used
5759
{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},
5860
//ABS KERNEL input not used
@@ -73,7 +75,7 @@ float test_result[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS] = {
7375
//SQRT Kernel
7476
{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},
7577
//SQR Kernel
76-
{1, 4, 9, 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},
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},
7779
//NEG Kernel
7880
{-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},
7981
//ABS Kernel
@@ -109,6 +111,12 @@ float test_input_scale_1[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
109111
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,
110112
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},
111113
//SQRT KERNEL
114+
{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,
115+
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,
116+
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,
117+
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,
118+
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},
119+
//SQR KERNEL
112120
{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,
113121
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,
114122
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,
@@ -161,6 +169,12 @@ float test_input_scale_2[GGML_TSAVORITE_KERNEL_TYPE_COUNT][NUM_ELEMENTS_SCALE] =
161169
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},
162170
//Below ROW value not used for Unary OPS-SQRT, NEG, ABS, SIN
163171
//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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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
229+
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,
230+
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,
231+
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,
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
214234
{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,
215235
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,
216236
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,
@@ -473,6 +493,37 @@ enum ggml_tsavorite_kernel_type convert_testcase_to_ops_type (const char *testCa
473493
return GGML_TSAVORITE_KERNEL_TYPE_ADD;
474494
}
475495

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+
476527
int main(int argc, char *argv[]) {
477528
ggml_time_init();
478529
bool test_case_flag = true;
@@ -563,7 +614,7 @@ int main(int argc, char *argv[]) {
563614

564615
// expected result:
565616

566-
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]);
567618

568619
fprintf(stderr, "\n compute is also done \n");
569620
for (int i = 0; i < result->ne[0] /* cols */; i++) {

tsi-pkg-build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fi
6767
cat > ./${TSI_GGML_BUNDLE_INSTALL_DIR}/ggml.sh << EOL
6868
#!/bin/bash
6969
export LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:\$(pwd)
70-
tsi_kernels=("add" "sub" "mult" "div" "abs" "inv" "neg" "sin" "sqrt" "sigmoid" "silu")
70+
tsi_kernels=("add" "sub" "mult" "div" "abs" "inv" "neg" "sin" "sqrt" "sqr" "sigmoid" "silu")
7171
7272
for kernel in "\${tsi_kernels[@]}"; do
7373
mkdir -p ${TSI_BLOB_INSTALL_DIR}/txe_\$kernel

0 commit comments

Comments
 (0)