1 #include "UnaryF16.h"
2 #include "Error.h"
3
4 /* Upper bound of maximum matrix dimension used by Python */
5 #define MAXMATRIXDIM 40
6
7 /*
8
9 Offset in input test pattern for matrix of dimension d * d.
10 Must be coherent with Python script Matrix.py
11
12 */
cholesky_offset(int d)13 static int cholesky_offset(int d)
14 {
15 int offset=14;
16 switch (d)
17 {
18 case 4:
19 offset = 14;
20 break;
21 case 8:
22 offset = 79;
23 break;
24 case 9:
25 offset = 143;
26 break;
27 case 15:
28 offset = 224;
29 break;
30 case 16:
31 offset = 449;
32 break;
33 default:
34 offset = 14;
35 break;
36 }
37
38 return(offset);
39 }
40
test_mat_scale_f16()41 void UnaryF16::test_mat_scale_f16()
42 {
43 arm_mat_scale_f16(&this->in1,0.5,&this->out);
44 }
45
test_mat_inverse_f16()46 void UnaryF16::test_mat_inverse_f16()
47 {
48 arm_mat_inverse_f16(&this->in1,&this->out);
49 }
50
test_mat_trans_f16()51 void UnaryF16::test_mat_trans_f16()
52 {
53 arm_mat_trans_f16(&this->in1,&this->out);
54 }
55
test_mat_cmplx_trans_f16()56 void UnaryF16::test_mat_cmplx_trans_f16()
57 {
58 arm_mat_cmplx_trans_f16(&this->in1,&this->out);
59 }
60
test_mat_add_f16()61 void UnaryF16::test_mat_add_f16()
62 {
63 arm_mat_add_f16(&this->in1,&this->in1,&this->out);
64 }
65
test_mat_sub_f16()66 void UnaryF16::test_mat_sub_f16()
67 {
68 arm_mat_sub_f16(&this->in1,&this->in1,&this->out);
69 }
70
test_mat_vec_mult_f16()71 void UnaryF16::test_mat_vec_mult_f16()
72 {
73 arm_mat_vec_mult_f16(&this->in1, vecp, outp);
74 }
75
test_mat_cholesky_dpo_f16()76 void UnaryF16::test_mat_cholesky_dpo_f16()
77 {
78 arm_mat_cholesky_f16(&this->in1,&this->out);
79 }
80
test_solve_upper_triangular_f16()81 void UnaryF16::test_solve_upper_triangular_f16()
82 {
83 arm_mat_solve_upper_triangular_f16(&this->in1,&this->in2,&this->out);
84 }
85
test_solve_lower_triangular_f16()86 void UnaryF16::test_solve_lower_triangular_f16()
87 {
88 arm_mat_solve_lower_triangular_f16(&this->in1,&this->in2,&this->out);
89 }
90
setUp(Testing::testID_t id,std::vector<Testing::param_t> & params,Client::PatternMgr * mgr)91 void UnaryF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
92 {
93
94
95 std::vector<Testing::param_t>::iterator it = params.begin();
96 this->nbr = *it++;
97 this->nbc = *it;
98
99 switch(id)
100 {
101 case TEST_MAT_VEC_MULT_F16_6:
102 input1.reload(UnaryF16::INPUTA_F16_ID,mgr,this->nbr*this->nbc);
103 vec.reload(UnaryF16::INPUTVEC1_F16_ID,mgr,this->nbc);
104 output.create(this->nbr,UnaryF16::OUT_F16_ID,mgr);
105 vecp=vec.ptr();
106 outp=output.ptr();
107
108 this->in1.numRows = this->nbr;
109 this->in1.numCols = this->nbc;
110 this->in1.pData = input1.ptr();
111 break;
112 case TEST_MAT_TRANS_F16_3:
113 input1.reload(UnaryF16::INPUTA_F16_ID,mgr,this->nbr*this->nbc);
114 output.create(this->nbr*this->nbc,UnaryF16::OUT_F16_ID,mgr);
115
116 this->out.numRows = this->nbc;
117 this->out.numCols = this->nbr;
118 this->out.pData = output.ptr();
119
120 this->in1.numRows = this->nbr;
121 this->in1.numCols = this->nbc;
122 this->in1.pData = input1.ptr();
123 break;
124 case TEST_MAT_CMPLX_TRANS_F16_7:
125 input1.reload(UnaryF16::INPUTAC_F16_ID,mgr,2*this->nbr*this->nbc);
126 output.create(2*this->nbr*this->nbc,UnaryF16::OUT_F16_ID,mgr);
127
128 this->out.numRows = this->nbc;
129 this->out.numCols = this->nbr;
130 this->out.pData = output.ptr();
131
132 this->in1.numRows = this->nbr;
133 this->in1.numCols = this->nbc;
134 this->in1.pData = input1.ptr();
135 break;
136
137 case TEST_MAT_CHOLESKY_DPO_F16_8:
138 {
139 int offset=14;
140 float16_t *p;
141 float16_t *aPtr;
142 input1.reload(UnaryF16::INPUTSCHOLESKY1_DPO_F16_ID,mgr);
143 output.create(this->nbc * this->nbr,UnaryF16::OUT_F16_ID,mgr);
144
145 a.create(this->nbr*this->nbc,UnaryF16::TMPA_F16_ID,mgr);
146
147 /* Offsets must be coherent with the sizes used in python script
148 Matrix.py for pattern generation */
149 offset=cholesky_offset(this->nbr);
150
151 p = input1.ptr();
152 aPtr = a.ptr();
153
154
155
156 memcpy(aPtr,p + offset,sizeof(float16_t)*this->nbr*this->nbr);
157
158 this->out.numRows = this->nbr;
159 this->out.numCols = this->nbc;
160 this->out.pData = output.ptr();
161
162 this->in1.numRows = this->nbr;
163 this->in1.numCols = this->nbc;
164 this->in1.pData = aPtr;
165
166
167
168 }
169 break;
170
171 case TEST_SOLVE_UPPER_TRIANGULAR_F16_9:
172 {
173 int offset=14;
174 float16_t *p;
175 float16_t *aPtr;
176 float16_t *bPtr;
177
178 input1.reload(UnaryF16::INPUT_UT_DPO_F16_ID,mgr);
179 input2.reload(UnaryF16::INPUT_RNDA_DPO_F16_ID,mgr);
180 output.create(this->nbc * this->nbr,UnaryF16::OUT_F16_ID,mgr);
181
182 a.create(this->nbr*this->nbc,UnaryF16::TMPA_F16_ID,mgr);
183 b.create(this->nbr*this->nbc,UnaryF16::TMPB_F16_ID,mgr);
184
185 /* Offsets must be coherent with the sizes used in python script
186 Matrix.py for pattern generation */
187 offset=cholesky_offset(this->nbr);
188
189 p = input1.ptr();
190 aPtr = a.ptr();
191 memcpy(aPtr,&p[offset],sizeof(float16_t)*this->nbr*this->nbr);
192
193 p = input2.ptr();
194 bPtr = b.ptr();
195 memcpy(bPtr,&p[offset],sizeof(float16_t)*this->nbr*this->nbr);
196
197 this->out.numRows = this->nbr;
198 this->out.numCols = this->nbc;
199 this->out.pData = output.ptr();
200
201 this->in1.numRows = this->nbr;
202 this->in1.numCols = this->nbc;
203 this->in1.pData = aPtr;
204
205 this->in2.numRows = this->nbr;
206 this->in2.numCols = this->nbc;
207 this->in2.pData = bPtr;
208 }
209 break;
210
211 case TEST_SOLVE_LOWER_TRIANGULAR_F16_10:
212 {
213 int offset=14;
214 float16_t *p;
215 float16_t *aPtr;
216 float16_t *bPtr;
217
218 input1.reload(UnaryF16::INPUT_LT_DPO_F16_ID,mgr);
219 input2.reload(UnaryF16::INPUT_RNDA_DPO_F16_ID,mgr);
220 output.create(this->nbc * this->nbr,UnaryF16::OUT_F16_ID,mgr);
221
222 a.create(this->nbr*this->nbc,UnaryF16::TMPA_F16_ID,mgr);
223 b.create(this->nbr*this->nbc,UnaryF16::TMPB_F16_ID,mgr);
224
225 /* Offsets must be coherent with the sizes used in python script
226 Matrix.py for pattern generation */
227 offset=cholesky_offset(this->nbr);
228
229 p = input1.ptr();
230 aPtr = a.ptr();
231 memcpy(aPtr,&p[offset],sizeof(float16_t)*this->nbr*this->nbr);
232
233 p = input2.ptr();
234 bPtr = b.ptr();
235 memcpy(bPtr,&p[offset],sizeof(float16_t)*this->nbr*this->nbr);
236
237 this->out.numRows = this->nbr;
238 this->out.numCols = this->nbc;
239 this->out.pData = output.ptr();
240
241 this->in1.numRows = this->nbr;
242 this->in1.numCols = this->nbc;
243 this->in1.pData = aPtr;
244
245 this->in2.numRows = this->nbr;
246 this->in2.numCols = this->nbc;
247 this->in2.pData = bPtr;
248 }
249 break;
250
251 default:
252 input1.reload(UnaryF16::INPUTA_F16_ID,mgr,this->nbr*this->nbc);
253 output.create(this->nbr*this->nbc,UnaryF16::OUT_F16_ID,mgr);
254
255 this->out.numRows = this->nbr;
256 this->out.numCols = this->nbc;
257 this->out.pData = output.ptr();
258
259 this->in1.numRows = this->nbr;
260 this->in1.numCols = this->nbc;
261 this->in1.pData = input1.ptr();
262 break;
263 }
264
265
266
267
268
269
270
271 }
272
tearDown(Testing::testID_t id,Client::PatternMgr * mgr)273 void UnaryF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
274 {
275 (void)id;
276 (void)mgr;
277 }
278