Skip to content

Commit 85a2b0f

Browse files
committed
Add quantized logistic function and tests
1 parent 94e368f commit 85a2b0f

File tree

6 files changed

+591
-2
lines changed

6 files changed

+591
-2
lines changed

TESTS/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ package_add_test_with_libraries(test_quant_fully_connect_2 operators/test_quant_
5757
package_add_test_with_libraries(test_fully_connect operators/test_fully_connected utensor operators "${PROJECT_DIR}/test-data/")
5858
package_add_test_with_libraries(test_sq_conv2d operators/test_sq_conv2d utensor operators "${PROJECT_DIR}/test-data/")
5959
package_add_test_with_libraries(test_sq_softmax operators/test_sq_softmax utensor operators "${PROJECT_DIR}/test-data/")
60+
package_add_test_with_libraries(test_sq_logistic operators/test_sq_logistic utensor operators "${PROJECT_DIR}/test-data/")
6061

6162
# Includes
6263
package_add_test_with_libraries(test_top_include library/test_top_include utensor library "${PROJECT_DIR}/test-data/")
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#ifndef constants_sq_logistic_hpp
2+
#define constants_sq_logistic_hpp
3+
static const float s_ref_in_0_f[64] = {
4+
38.21641, 44.148315, -9.235587, -10.72204, 10.255991, 14.93122, 11.685471, -5.6057963, 45.68708, 7.379328,
5+
-5.2336965, 30.250887, 0.9088242, 18.735996, 19.140287, 42.20882, 44.626972, 1.1773365, -7.730872, -3.4272451,
6+
42.279247, -16.710936, -12.063282, 6.1039624, 45.45102, 16.827833, 43.943653, 36.65412, 21.362074, -7.162497,
7+
14.681322, 47.16887, 30.183512, 1.6348583, 31.633001, 0.61317295, 18.846144, 7.2212234, 32.13548, 1.6201469,
8+
16.15742, -13.4391365, 27.938215, 7.4763412, 5.2526464, 5.618852, 46.169067, 4.150903, 11.664121, 3.5938363,
9+
22.670412, 41.570786, -13.721234, 11.2070875, 13.190311, 41.920567, 7.775186, 37.41595, -14.394706, 43.890495,
10+
-0.39190316, 5.2998395, 6.3880844, 16.261568
11+
};
12+
13+
14+
static const float s_ref_out_0_f[64] = {
15+
1.0, 1.0, 9.74834e-05, 2.208352e-05, 0.99996483, 0.9999997, 0.9999916, 0.003663063, 1.0, 0.9993764,
16+
0.0053055286, 1.0, 0.7127595, 1.0, 1.0, 1.0, 1.0, 0.76446855, 0.000438869, 0.031454742,
17+
1.0, 1.4901161e-07, 5.7816505e-06, 0.9977709, 1.0, 1.0, 1.0, 1.0, 1.0, 0.00077447295,
18+
0.9999996, 1.0, 1.0, 0.8368341, 1.0, 0.64866424, 1.0, 0.9992696, 1.0, 0.8348154,
19+
0.99999994, 1.4007092e-06, 1.0, 0.999434, 0.99479353, 0.9963844, 1.0, 0.9844941, 0.9999914, 0.973243,
20+
1.0, 1.0, 1.0430813e-06, 0.9999864, 0.9999981, 1.0, 0.99958014, 1.0, 5.662441e-07, 1.0,
21+
0.40325925, 0.99503237, 0.9983213, 0.99999994
22+
};
23+
24+
static const int8_t s_ref_in_0_q[64] = {
25+
102, 118, -24, -28, 27, 40, 31, -15, 123, 19,
26+
-14, 81, 2, 50, 51, 113, 120, 3, -20, -9,
27+
113, -44, -32, 16, 122, 45, 118, 98, 57, -19,
28+
39, 127, 81, 4, 85, 1, 50, 19, 86, 4,
29+
43, -36, 75, 20, 14, 15, 124, 11, 31, 9,
30+
61, 111, -36, 30, 35, 112, 20, 100, -38, 118,
31+
-1, 14, 17, 43
32+
};
33+
static const int32_t s_ref_in_0_f_zp = 0;
34+
static const float s_ref_in_0_f_scale = 0.37140841746893455;
35+
36+
static const int32_t s_out_0_q_zp = -128;
37+
static const float s_out_0_q_scale = 0.00390625;
38+
39+
static const float s_ref_out_0_q[64] = {
40+
1.0, 1.0, 9.74834e-05, 2.208352e-05, 0.99996483, 0.9999997, 0.9999916, 0.003663063, 1.0, 0.9993764,
41+
0.0053055286, 1.0, 0.7127595, 1.0, 1.0, 1.0, 1.0, 0.76446855, 0.000438869, 0.031454742,
42+
1.0, 1.4901161e-07, 5.7816505e-06, 0.9977709, 1.0, 1.0, 1.0, 1.0, 1.0, 0.00077447295,
43+
0.9999996, 1.0, 1.0, 0.8368341, 1.0, 0.64866424, 1.0, 0.9992696, 1.0, 0.8348154,
44+
0.99999994, 1.4007092e-06, 1.0, 0.999434, 0.99479353, 0.9963844, 1.0, 0.9844941, 0.9999914, 0.973243,
45+
1.0, 1.0, 1.0430813e-06, 0.9999864, 0.9999981, 1.0, 0.99958014, 1.0, 5.662441e-07, 1.0,
46+
0.40325925, 0.99503237, 0.9983213, 0.99999994
47+
};
48+
static const int32_t s_ref_out_0_f_zp = -128;
49+
static const float s_ref_out_0_f_scale = 0.00390625;
50+
51+
static const float s_ref_in_1_f[64] = {
52+
48.989845, 26.604435, 5.990834, 32.58223, 36.208256, 37.97967, -10.076509, -3.515773, 16.797853, 5.8578806,
53+
33.274353, -11.712736, 41.14031, 0.5064808, 47.012436, 37.141174, 45.728832, 20.342632, 26.523817, -8.258652,
54+
0.97376907, 45.645737, 13.878764, -13.495044, 8.760527, 42.039684, 22.831106, 10.821521, 3.3460023, 1.8303334,
55+
47.013123, 25.859995, 48.066174, -4.759532, 1.1003804, -10.458439, 32.412266, 29.107628, 5.692208, -19.87011,
56+
45.177193, 1.1996313, 27.196676, 22.037457, 38.970276, -8.658141, 13.390983, -19.579308, 36.54308, 2.8827503,
57+
40.687233, -2.0065455, -13.564358, 13.109717, 3.602125, 3.5016487, 32.44309, 42.722305, 29.111279, 38.75185,
58+
41.066547, -0.7091453, 42.54009, 30.257603
59+
};
60+
61+
static const float s_ref_out_1_f[64] = {
62+
1.0, 1.0, 0.9975047, 1.0, 1.0, 1.0, 4.211068e-05, 0.028866768, 1.0, 0.99715084,
63+
1.0, 8.225441e-06, 1.0, 0.6239811, 1.0, 1.0, 1.0, 1.0, 1.0, 0.00025901198,
64+
0.72587013, 1.0, 0.99999905, 1.3411045e-06, 0.99984324, 1.0, 1.0, 0.99998, 0.96597373, 0.86180145,
65+
1.0, 1.0, 1.0, 0.008496761, 0.7503314, 2.8699636e-05, 1.0, 1.0, 0.99663925, 0.0,
66+
1.0, 0.7684592, 1.0, 1.0, 1.0, 0.00017368793, 0.99999857, 0.0, 1.0, 0.94698715,
67+
1.0, 0.1185174, 1.2814999e-06, 0.999998, 0.97345793, 0.9707347, 1.0, 1.0, 1.0, 1.0,
68+
1.0, 0.32978773, 1.0, 1.0
69+
};
70+
71+
72+
static const int8_t s_ref_in_1_q[64] = {
73+
127, 68, 15, 84, 93, 98, -26, -9, 43, 15,
74+
86, -30, 106, 1, 121, 96, 118, 52, 68, -21,
75+
2, 118, 35, -34, 22, 108, 59, 28, 8, 4,
76+
121, 67, 124, -12, 2, -27, 84, 75, 14, -51,
77+
117, 3, 70, 57, 101, -22, 34, -50, 94, 7,
78+
105, -5, -35, 33, 9, 9, 84, 110, 75, 100,
79+
106, -1, 110, 78
80+
};
81+
static const int32_t s_ref_in_1_f_zp = 0;
82+
static const float s_ref_in_1_f_scale = 0.3857468131958969;
83+
84+
static const float s_ref_out_1_q[64] = {
85+
1.0, 1.0, 0.9975047, 1.0, 1.0, 1.0, 4.211068e-05, 0.028866768, 1.0, 0.99715084,
86+
1.0, 8.225441e-06, 1.0, 0.6239811, 1.0, 1.0, 1.0, 1.0, 1.0, 0.00025901198,
87+
0.72587013, 1.0, 0.99999905, 1.3411045e-06, 0.99984324, 1.0, 1.0, 0.99998, 0.96597373, 0.86180145,
88+
1.0, 1.0, 1.0, 0.008496761, 0.7503314, 2.8699636e-05, 1.0, 1.0, 0.99663925, 0.0,
89+
1.0, 0.7684592, 1.0, 1.0, 1.0, 0.00017368793, 0.99999857, 0.0, 1.0, 0.94698715,
90+
1.0, 0.1185174, 1.2814999e-06, 0.999998, 0.97345793, 0.9707347, 1.0, 1.0, 1.0, 1.0,
91+
1.0, 0.32978773, 1.0, 1.0
92+
};
93+
static const int32_t s_ref_out_1_f_zp = -128;
94+
static const float s_ref_out_1_f_scale = 0.00390625;
95+
96+
static const int32_t s_out_1_q_zp = -128;
97+
static const float s_out_1_q_scale = 0.00390625;
98+
99+
static const float s_ref_in_2_f[64] = {
100+
-7.8759017, 27.45546, -12.991614, 47.06656, 13.491683, -11.63206, 38.016396, 48.083485, 49.966454, 36.62208,
101+
-0.03025741, 29.35857, 3.2600143, 3.30339, 37.078815, 27.576075, 35.261627, 26.020609, 6.5544925, 16.895555,
102+
38.827454, 29.746199, 13.123264, 20.23211, 40.522594, 47.4929, -16.592787, 38.785873, -11.803616, 16.433107,
103+
35.526306, 5.066841, 10.632341, -1.4094672, 11.036616, 6.0398107, 33.222374, 0.527816, 7.3680344, 34.496075,
104+
-14.733833, 2.796944, -18.372396, 38.971165, -12.912945, 43.003944, -12.064758, 20.417824, -13.70869, 15.338315,
105+
15.809604, 1.8192297, 25.436161, 47.87969, 29.468935, 17.451424, -14.857416, -0.7582926, 2.2868428, 18.126755,
106+
-9.894022, -18.973011, -18.20048, 39.790924
107+
};
108+
109+
static const float s_ref_out_2_f[64] = {
110+
0.00037965178, 1.0, 2.2947788e-06, 1.0, 0.9999987, 8.85129e-06, 1.0, 1.0, 1.0, 1.0,
111+
0.49243623, 1.0, 0.9630313, 0.96454495, 1.0, 1.0, 1.0, 1.0, 0.9985783, 1.0,
112+
1.0, 1.0, 0.99999803, 1.0, 1.0, 1.0, 5.9604645e-08, 1.0, 7.4505806e-06, 0.9999999,
113+
1.0, 0.9937372, 0.99997586, 0.19631812, 0.9999839, 0.9976237, 1.0, 0.6289736, 0.99936926, 1.0,
114+
3.2782555e-07, 0.9425105, 0.0, 1.0, 2.4437904e-06, 1.0, 5.751848e-06, 1.0, 1.1026859e-06, 0.99999976,
115+
0.9999998, 0.86047363, 1.0, 1.0, 1.0, 0.9999999, 2.682209e-07, 0.31901708, 0.9077815, 1.0,
116+
5.0485134e-05, 0.0, 0.0, 1.0
117+
};
118+
119+
120+
static const int8_t s_ref_in_2_q[64] = {
121+
-20, 69, -33, 119, 34, -29, 96, 122, 127, 93,
122+
0, 74, 8, 8, 94, 70, 89, 66, 16, 42,
123+
98, 75, 33, 51, 102, 120, -42, 98, -30, 41,
124+
90, 12, 27, -3, 28, 15, 84, 1, 18, 87,
125+
-37, 7, -46, 99, -32, 109, -30, 51, -34, 38,
126+
40, 4, 64, 121, 74, 44, -37, -1, 5, 46,
127+
-25, -48, -46, 101
128+
};
129+
static const int32_t s_ref_in_2_f_zp = 0;
130+
static const float s_ref_in_2_f_scale = 0.39343664214367;
131+
132+
static const float s_ref_out_2_q[64] = {
133+
0.00037965178, 1.0, 2.2947788e-06, 1.0, 0.9999987, 8.85129e-06, 1.0, 1.0, 1.0, 1.0,
134+
0.49243623, 1.0, 0.9630313, 0.96454495, 1.0, 1.0, 1.0, 1.0, 0.9985783, 1.0,
135+
1.0, 1.0, 0.99999803, 1.0, 1.0, 1.0, 5.9604645e-08, 1.0, 7.4505806e-06, 0.9999999,
136+
1.0, 0.9937372, 0.99997586, 0.19631812, 0.9999839, 0.9976237, 1.0, 0.6289736, 0.99936926, 1.0,
137+
3.2782555e-07, 0.9425105, 0.0, 1.0, 2.4437904e-06, 1.0, 5.751848e-06, 1.0, 1.1026859e-06, 0.99999976,
138+
0.9999998, 0.86047363, 1.0, 1.0, 1.0, 0.9999999, 2.682209e-07, 0.31901708, 0.9077815, 1.0,
139+
5.0485134e-05, 0.0, 0.0, 1.0
140+
};
141+
static const int32_t s_ref_out_2_f_zp = -128;
142+
static const float s_ref_out_2_f_scale = 0.00390625;
143+
144+
static const int32_t s_out_2_q_zp = -128;
145+
static const float s_out_2_q_scale = 0.00390625;
146+
147+
static const float s_ref_in_3_f[64] = {
148+
43.60187, 33.188847, 38.235893, 32.58848, 30.65001, -8.635649, -16.53064, 13.540903, 30.489208, 38.59805,
149+
-0.9898079, 16.788382, -11.503799, -10.3041525, 32.31753, 27.225357, -19.667141, -7.051834, -19.00694, 49.150593,
150+
-16.07778, -12.692768, 45.22566, -0.3176205, 30.96428, 16.251833, 33.655052, 35.4756, 11.569794, 13.106046,
151+
15.678767, -9.208017, 49.919308, 32.672363, 11.440487, 5.251054, 47.32433, 0.30926538, 31.179955, 46.77346,
152+
-0.78774875, 18.20263, 24.676334, -5.5216165, 31.623657, 24.188272, 23.866428, 11.774495, 5.4973693, 34.101925,
153+
-19.193853, 43.189182, 41.832115, -17.066278, -8.796113, 30.688868, -13.911111, -1.056367, 24.810232, 37.642353,
154+
-8.666822, 29.723299, -9.634566, -8.07385
155+
};
156+
157+
158+
static const float s_ref_out_3_f[64] = {
159+
1.0, 1.0, 1.0, 1.0, 1.0, 0.00017762184, 8.940697e-08, 0.99999875, 1.0, 1.0,
160+
0.27095005, 1.0, 1.0043383e-05, 3.3527613e-05, 1.0, 1.0, 0.0, 0.0008651018, 0.0, 1.0,
161+
1.4901161e-07, 3.0696392e-06, 1.0, 0.42125577, 1.0, 0.99999994, 1.0, 1.0, 0.9999905, 0.99999803,
162+
0.9999999, 0.00010025501, 1.0, 1.0, 0.9999893, 0.9947853, 1.0, 0.57670593, 1.0, 1.0,
163+
0.3126523, 1.0, 1.0, 0.003983438, 1.0, 1.0, 1.0, 0.9999924, 0.99591917, 1.0,
164+
0.0, 1.0, 1.0, 1.1920929e-07, 0.00015127659, 1.0, 8.6426735e-07, 0.25800434, 1.0, 1.0,
165+
0.00017222762, 1.0, 6.54757e-05, 0.00031152368
166+
};
167+
168+
static const int8_t s_ref_in_3_q[64] = {
169+
110, 84, 97, 82, 77, -21, -42, 34, 77, 98,
170+
-2, 42, -29, -26, 82, 69, -50, -17, -48, 125,
171+
-40, -32, 115, 0, 78, 41, 85, 90, 29, 33,
172+
39, -23, 127, 83, 29, 13, 120, 0, 79, 118,
173+
-2, 46, 62, -14, 80, 61, 60, 29, 13, 86,
174+
-48, 109, 106, -43, -22, 78, -35, -2, 63, 95,
175+
-22, 75, -24, -20
176+
};
177+
static const int32_t s_ref_in_3_f_zp = 0;
178+
static const float s_ref_in_3_f_scale = 0.3930654150294507;
179+
180+
static const int32_t s_out_3_q_zp = -128;
181+
static const float s_out_3_q_scale = 0.00390625;
182+
183+
static const float s_ref_out_3_q[64] = {
184+
1.0, 1.0, 1.0, 1.0, 1.0, 0.00017762184, 8.940697e-08, 0.99999875, 1.0, 1.0,
185+
0.27095005, 1.0, 1.0043383e-05, 3.3527613e-05, 1.0, 1.0, 0.0, 0.0008651018, 0.0, 1.0,
186+
1.4901161e-07, 3.0696392e-06, 1.0, 0.42125577, 1.0, 0.99999994, 1.0, 1.0, 0.9999905, 0.99999803,
187+
0.9999999, 0.00010025501, 1.0, 1.0, 0.9999893, 0.9947853, 1.0, 0.57670593, 1.0, 1.0,
188+
0.3126523, 1.0, 1.0, 0.003983438, 1.0, 1.0, 1.0, 0.9999924, 0.99591917, 1.0,
189+
0.0, 1.0, 1.0, 1.1920929e-07, 0.00015127659, 1.0, 8.6426735e-07, 0.25800434, 1.0, 1.0,
190+
0.00017222762, 1.0, 6.54757e-05, 0.00031152368
191+
};
192+
static const int32_t s_ref_out_3_f_zp = -128;
193+
static const float s_ref_out_3_f_scale = 0.00390625;
194+
195+
#endif

0 commit comments

Comments
 (0)