Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | #include "arm_math.h" |
2 | #include "matrix_test_data.h" |
||
3 | #include "type_abbrev.h" |
||
4 | |||
5 | /*--------------------------------------------------------------------------------*/ |
||
6 | /* Input/Output Buffers */ |
||
7 | /*--------------------------------------------------------------------------------*/ |
||
8 | |||
9 | MATRIX_TEST_BIGGEST_INPUT_TYPE matrix_output_fut_data[2*MATRIX_TEST_MAX_ELTS] = {0}; |
||
10 | MATRIX_TEST_BIGGEST_INPUT_TYPE matrix_output_ref_data[2*MATRIX_TEST_MAX_ELTS] = {0}; |
||
11 | MATRIX_TEST_BIGGEST_INPUT_TYPE matrix_output_scratch[MATRIX_TEST_MAX_ELTS] = {0}; |
||
12 | |||
13 | MATRIX_TEST_BIGGEST_INPUT_TYPE matrix_output_f32_fut[MATRIX_TEST_MAX_ELTS]; |
||
14 | MATRIX_TEST_BIGGEST_INPUT_TYPE matrix_output_f32_ref[MATRIX_TEST_MAX_ELTS]; |
||
15 | |||
16 | arm_matrix_instance_f32 matrix_output_fut = { |
||
17 | 0, |
||
18 | 0, |
||
19 | (float32_t *) &matrix_output_fut_data |
||
20 | }; |
||
21 | |||
22 | arm_matrix_instance_f32 matrix_output_ref = { |
||
23 | 0, |
||
24 | 0, |
||
25 | (float32_t *) &matrix_output_ref_data |
||
26 | }; |
||
27 | |||
28 | arm_matrix_instance_f64 matrix_output_fut64 = { |
||
29 | 0, |
||
30 | 0, |
||
31 | (float64_t *) &matrix_output_fut_data |
||
32 | }; |
||
33 | |||
34 | arm_matrix_instance_f64 matrix_output_ref64 = { |
||
35 | 0, |
||
36 | 0, |
||
37 | (float64_t *) &matrix_output_ref_data |
||
38 | }; |
||
39 | |||
40 | /*--------------------------------------------------------------------------------*/ |
||
41 | /* Data Buckets */ |
||
42 | /*--------------------------------------------------------------------------------*/ |
||
43 | |||
44 | /** |
||
45 | * Pool of random data to base matrix inputs from. |
||
46 | */ |
||
47 | float32_t matrix_f32_100_rand[100] = { |
||
48 | -45.0345569674258, -11.0261163038747, -14.6841428777929, |
||
49 | 0.0345569674258, -11.0261163038747, -14.6841428777929, |
||
50 | -20.3679194392227, 27.5712678608402, -12.1390617339732, |
||
51 | -19.8753669720509, 42.3379642103244, -23.7788252219155, |
||
52 | -23.7517765301667, 40.2716109915281, -25.8308714086167, |
||
53 | 32.1194040197959, 24.4692807074156, -1.32083675968276, |
||
54 | 31.1580458282477, -2.90766514824093, -6.97926086704160, |
||
55 | 10.2843089382083, 30.1014622769739, 44.4787189721646, |
||
56 | -9.60878544118853, -48.4596562348445, -31.1044984967456, |
||
57 | -6.41414114190809, 3.28255887994549, -26.9511839788442, |
||
58 | -31.5183679875864, 21.1215780433683, -47.0779722437854, |
||
59 | -0.913590753192006, -40.3545474831611, -45.6976198342192, |
||
60 | 18.6775433365315, -5.32162505701938, -14.9272896423117, |
||
61 | 34.4308792695389, 40.4880968679893, -27.8253265982760, |
||
62 | 42.8854139478045, -1.07473615999811, -36.8026707393665, |
||
63 | -33.1009970537296, -31.6488844262730, -19.3650527983443, |
||
64 | 43.9001561999887, -30.5235710432951, 47.9748378356085, |
||
65 | -38.2582349144194, 23.0330862855453, -16.2280590178623, |
||
66 | 44.2050590775485, 14.9115474956452, -13.1515403509664, |
||
67 | 0.850865538112700, 37.5942811492984, -27.4078219027601, |
||
68 | -6.11300268738968, -20.3324126781673, -1.13910261964209, |
||
69 | 40.0053846417662, 45.6134540229802, 23.1722385658670, |
||
70 | 12.5618560729690, 1.07715641721097, 5.01563428984222, |
||
71 | -32.9291952852141, -38.8880776559401, -18.1221698074118, |
||
72 | 7.85250610234389, -13.0753218879785, 7.52085950784656, |
||
73 | 14.7745963136307, 28.0227435151377, 31.7627708322262, |
||
74 | 12.2475086001227, -27.2335702183447, -24.1935304087933, |
||
75 | -7.58332402861928, -26.2716420228479, -38.8797244706213, |
||
76 | -44.0220457052844, -4.90762935690551, -41.8874231134215, |
||
77 | 29.4831416883453, 8.70447045314168, -6.43013158961009, |
||
78 | -9.12801538874479, 0.785828466111815, -4.11511718200689, |
||
79 | 28.0252068321138, -26.5220086627594, 4.70088922863450, |
||
80 | 42.9385970968730, 14.4318130193692, -29.2257707266972, |
||
81 | 46.3088539286913 |
||
82 | }; |
||
83 | |||
84 | float64_t matrix_f64_100_rand[100] = { |
||
85 | -45.0345569674258, -11.0261163038747, -14.6841428777929, |
||
86 | 0.0345569674258, -11.0261163038747, -14.6841428777929, |
||
87 | -20.3679194392227, 27.5712678608402, -12.1390617339732, |
||
88 | -19.8753669720509, 42.3379642103244, -23.7788252219155, |
||
89 | -23.7517765301667, 40.2716109915281, -25.8308714086167, |
||
90 | 32.1194040197959, 24.4692807074156, -1.32083675968276, |
||
91 | 31.1580458282477, -2.90766514824093, -6.97926086704160, |
||
92 | 10.2843089382083, 30.1014622769739, 44.4787189721646, |
||
93 | -9.60878544118853, -48.4596562348445, -31.1044984967456, |
||
94 | -6.41414114190809, 3.28255887994549, -26.9511839788442, |
||
95 | -31.5183679875864, 21.1215780433683, -47.0779722437854, |
||
96 | -0.913590753192006, -40.3545474831611, -45.6976198342192, |
||
97 | 18.6775433365315, -5.32162505701938, -14.9272896423117, |
||
98 | 34.4308792695389, 40.4880968679893, -27.8253265982760, |
||
99 | 42.8854139478045, -1.07473615999811, -36.8026707393665, |
||
100 | -33.1009970537296, -31.6488844262730, -19.3650527983443, |
||
101 | 43.9001561999887, -30.5235710432951, 47.9748378356085, |
||
102 | -38.2582349144194, 23.0330862855453, -16.2280590178623, |
||
103 | 44.2050590775485, 14.9115474956452, -13.1515403509664, |
||
104 | 0.850865538112700, 37.5942811492984, -27.4078219027601, |
||
105 | -6.11300268738968, -20.3324126781673, -1.13910261964209, |
||
106 | 40.0053846417662, 45.6134540229802, 23.1722385658670, |
||
107 | 12.5618560729690, 1.07715641721097, 5.01563428984222, |
||
108 | -32.9291952852141, -38.8880776559401, -18.1221698074118, |
||
109 | 7.85250610234389, -13.0753218879785, 7.52085950784656, |
||
110 | 14.7745963136307, 28.0227435151377, 31.7627708322262, |
||
111 | 12.2475086001227, -27.2335702183447, -24.1935304087933, |
||
112 | -7.58332402861928, -26.2716420228479, -38.8797244706213, |
||
113 | -44.0220457052844, -4.90762935690551, -41.8874231134215, |
||
114 | 29.4831416883453, 8.70447045314168, -6.43013158961009, |
||
115 | -9.12801538874479, 0.785828466111815, -4.11511718200689, |
||
116 | 28.0252068321138, -26.5220086627594, 4.70088922863450, |
||
117 | 42.9385970968730, 14.4318130193692, -29.2257707266972, |
||
118 | 46.3088539286913 |
||
119 | }; |
||
120 | |||
121 | MATRIX_TEST_BIGGEST_INPUT_TYPE matrix_zeros[MATRIX_TEST_MAX_ELTS] = {0}; |
||
122 | |||
123 | const float32_t matrix_f32_scale_values[MATRIX_MAX_COEFFS_LEN] = |
||
124 | { |
||
125 | 43.0264275639 , -17.0525215570 , -94.8488973910 , -8.1924989580 , |
||
126 | 7.2830326091 , 66.8368719314 , 33.9778190671 , 117.8652289772 , |
||
127 | -129.6077797465, -14.6420815368 , 18.0239223278 , 1.0000000000 , |
||
128 | 55.0375037651 , 1.8674609862 , 0.00000000000 , -33.5750364909 |
||
129 | }; |
||
130 | |||
131 | const q31_t matrix_q31_scale_values[MATRIX_MAX_COEFFS_LEN] = |
||
132 | { |
||
133 | 0x0201DC90, 0x211F0D7C, 0x80000000, 0xF573B824, |
||
134 | 0xE85ED05B, 0x311DFB52, 0x3529E750, 0x00000000, |
||
135 | 0x7FFFFFFF, 0x21FA525A, 0x0971FD45, 0x05547B68, |
||
136 | 0x270C6366, 0x06FDD5A6, 0xF7025315, 0xB1155A1E |
||
137 | }; |
||
138 | |||
139 | const q15_t matrix_q15_scale_values[MATRIX_MAX_COEFFS_LEN] = |
||
140 | { |
||
141 | 0x0201, 0x211F, 0x8000, 0xF573, |
||
142 | 0xE85E, 0x311D, 0x3529, 0x0000, |
||
143 | 0x7FFF, 0x21FA, 0x0971, 0x0554, |
||
144 | 0x270C, 0x06FD, 0xF702, 0xB115 |
||
145 | }; |
||
146 | |||
147 | const int32_t matrix_shift_values[MATRIX_MAX_SHIFTS_LEN] = |
||
148 | { |
||
149 | -16, -7, 0, 7, 16 |
||
150 | }; |
||
151 | |||
152 | /*--------------------------------------------------------------------------------*/ |
||
153 | /* Matrix Definitions */ |
||
154 | /*--------------------------------------------------------------------------------*/ |
||
155 | |||
156 | /** |
||
157 | * Define matrices by suffix (f32, q31, q15) for use in test cases. |
||
158 | * |
||
159 | * The rand1 and rand2 suffixes get their data from the same pool of random |
||
160 | * data, but their starting points differ by 1 element. |
||
161 | * |
||
162 | * Makes available: |
||
163 | * - matrix_`suffix`_1x1_rand1/2 |
||
164 | * - matrix_`suffix`_1x4_rand1/2 |
||
165 | * - matrix_`suffix`_2x4_rand1/2 |
||
166 | * - matrix_`suffix`_4x4_rand1/2 |
||
167 | */ |
||
168 | #define MATRIX_DEFINE_MATRICES(suffix) \ |
||
169 | arm_matrix_instance_##suffix matrix_##suffix##_1x1_rand1 = \ |
||
170 | {1, 1, (TYPE_FROM_ABBREV(suffix) *) matrix_f32_100_rand }; \ |
||
171 | arm_matrix_instance_##suffix matrix_##suffix##_1x1_rand2 = \ |
||
172 | {1, 1, (TYPE_FROM_ABBREV(suffix) *) (matrix_f32_100_rand+1)}; \ |
||
173 | arm_matrix_instance_##suffix matrix_##suffix##_1x1_zeros = \ |
||
174 | {1, 1, (TYPE_FROM_ABBREV(suffix) *) matrix_zeros}; \ |
||
175 | \ |
||
176 | arm_matrix_instance_##suffix matrix_##suffix##_1x4_rand1 = \ |
||
177 | {1, 4, (TYPE_FROM_ABBREV(suffix) *) matrix_f32_100_rand }; \ |
||
178 | arm_matrix_instance_##suffix matrix_##suffix##_1x4_rand2 = \ |
||
179 | {1, 4, (TYPE_FROM_ABBREV(suffix) *) (matrix_f32_100_rand+1)}; \ |
||
180 | arm_matrix_instance_##suffix matrix_##suffix##_1x4_zeros = \ |
||
181 | {1, 4, (TYPE_FROM_ABBREV(suffix) *) matrix_zeros}; \ |
||
182 | \ |
||
183 | arm_matrix_instance_##suffix matrix_##suffix##_2x4_rand1 = \ |
||
184 | {2, 4, (TYPE_FROM_ABBREV(suffix) *) matrix_f32_100_rand }; \ |
||
185 | arm_matrix_instance_##suffix matrix_##suffix##_2x4_rand2 = \ |
||
186 | {2, 4, (TYPE_FROM_ABBREV(suffix) *) (matrix_f32_100_rand+1)}; \ |
||
187 | arm_matrix_instance_##suffix matrix_##suffix##_2x4_zeros = \ |
||
188 | {2, 4, (TYPE_FROM_ABBREV(suffix) *) matrix_zeros}; \ |
||
189 | \ |
||
190 | arm_matrix_instance_##suffix matrix_##suffix##_4x4_rand1 = \ |
||
191 | {4, 4, (TYPE_FROM_ABBREV(suffix) *) matrix_f32_100_rand }; \ |
||
192 | arm_matrix_instance_##suffix matrix_##suffix##_4x4_rand2 = \ |
||
193 | {4, 4, (TYPE_FROM_ABBREV(suffix) *) (matrix_f32_100_rand+1)}; \ |
||
194 | arm_matrix_instance_##suffix matrix_##suffix##_4x4_zeros = \ |
||
195 | {4, 4, (TYPE_FROM_ABBREV(suffix) *) matrix_zeros} |
||
196 | |||
197 | MATRIX_DEFINE_MATRICES(f64); |
||
198 | MATRIX_DEFINE_MATRICES(f32); |
||
199 | MATRIX_DEFINE_MATRICES(q31); |
||
200 | MATRIX_DEFINE_MATRICES(q15); |
||
201 | |||
202 | /*--------------------------------------------------------------------------------*/ |
||
203 | /* Matrix-Input Arrays */ |
||
204 | /*--------------------------------------------------------------------------------*/ |
||
205 | |||
206 | /* Define Input #ARR_DESC_t by suffix. |
||
207 | * |
||
208 | * Taking inputs in parallel from the 'a' and 'b' arrays yields the following |
||
209 | * test cases: |
||
210 | * - 1x1 multiplication by zero |
||
211 | * - 1x1 multiplication between random numbers |
||
212 | * - 1x1 * 1x4 valid dimension interaction |
||
213 | * - 1x1 * 2x4 invalid dimension interaction |
||
214 | * - 2x4 * 4x4 larger valid dimension interaction |
||
215 | * - 4x4 * 4x4 larger valid dimension interaction |
||
216 | */ |
||
217 | #define MATRIX_DEFINE_INPUTS(suffix) \ |
||
218 | ARR_DESC_DEFINE(arm_matrix_instance_##suffix *, \ |
||
219 | matrix_##suffix##_a_inputs, \ |
||
220 | 6, \ |
||
221 | CURLY( \ |
||
222 | &matrix_##suffix##_1x1_rand1, \ |
||
223 | &matrix_##suffix##_1x1_rand1, \ |
||
224 | &matrix_##suffix##_1x1_rand1, \ |
||
225 | &matrix_##suffix##_1x1_rand1, \ |
||
226 | &matrix_##suffix##_2x4_rand1, \ |
||
227 | &matrix_##suffix##_4x4_rand1 \ |
||
228 | )); \ |
||
229 | \ |
||
230 | ARR_DESC_DEFINE(arm_matrix_instance_##suffix *, \ |
||
231 | matrix_##suffix##_b_inputs, \ |
||
232 | 6, \ |
||
233 | CURLY( \ |
||
234 | &matrix_##suffix##_1x1_zeros, \ |
||
235 | &matrix_##suffix##_1x1_rand2, \ |
||
236 | &matrix_##suffix##_1x4_rand2, \ |
||
237 | &matrix_##suffix##_2x4_rand2, \ |
||
238 | &matrix_##suffix##_4x4_rand2, \ |
||
239 | &matrix_##suffix##_4x4_rand2 \ |
||
240 | )); \ |
||
241 | \ |
||
242 | ARR_DESC_DEFINE(arm_matrix_instance_##suffix *, \ |
||
243 | matrix_##suffix##_invertible_inputs, \ |
||
244 | 4, \ |
||
245 | CURLY( \ |
||
246 | &matrix_##suffix##_1x1_rand1, \ |
||
247 | &matrix_##suffix##_1x1_rand2, \ |
||
248 | &matrix_##suffix##_4x4_rand1, \ |
||
249 | &matrix_##suffix##_4x4_rand2 \ |
||
250 | )) \ |
||
251 | |||
252 | MATRIX_DEFINE_INPUTS(f64); |
||
253 | MATRIX_DEFINE_INPUTS(f32); |
||
254 | MATRIX_DEFINE_INPUTS(q31); |
||
255 | MATRIX_DEFINE_INPUTS(q15); |