-
Notifications
You must be signed in to change notification settings - Fork 2
/
ultranet.cpp
613 lines (532 loc) · 19.8 KB
/
ultranet.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
// #define DEBUG
#ifndef __SYNTHESIS__
#include <iostream>
#include <fstream>
using namespace std;
#endif
#include <stdint.h>
#include <ap_int.h>
#include <hls_video.h>
#include "ultranet.h"
#include "stream_tools.h"
#include "function.h"
#include "sliding_window_unit.h"
#include "matrix_vector_unit.h"
#include "config.h"
#include "param.h"
#include "conv2d.h"
#include "pool2d.h"
#include "bn_qrelu2d.h"
void stream_to_mat (hls::stream<ap_uint<24> >&in,
hls::Mat<IN_IMAGE_HEIGHT, IN_IMAGE_WIDTH, HLS_8UC3> & raw_img) {
for (int i=0; i<IN_IMAGE_HEIGHT; i++) {
#pragma HLS loop_tripcount min=120 max=360
for (int j=0; j<IN_IMAGE_WIDTH; j++) {
#pragma HLS loop_tripcount min=320 max=640
#pragma HLS pipeline II = 1
hls::Scalar<3, ap_uint<8> > pix;
ap_uint<24> in_data = in.read();
for (unsigned int p=0; p < 3; p ++) {
pix.val[p] = in_data(8*p+7, 8*p);
}
raw_img << pix;
}
}
}
void mat_to_stream (hls::Mat<RESIZE_IMAGE_HEIGHT, RESIZE_IMAGE_WIDTH, HLS_8UC3> & resize_img,
hls::stream<ap_uint<24> > & out ) {
for (int i=0; i<RESIZE_IMAGE_HEIGHT; i++) {
#pragma HLS loop_tripcount min=120 max=360
for (int j=0; j<RESIZE_IMAGE_WIDTH; j++) {
#pragma HLS loop_tripcount min=320 max=640
#pragma HLS pipeline II = 1
hls::Scalar<3, ap_uint<8> > pix;
resize_img >> pix;
ap_uint<24> out_data;
for (unsigned int p=0; p < 3; p ++) {
out_data(8*p+7, 8*p) = pix.val[p];
}
out.write(out_data);
}
}
}
void resize(hls::stream<ap_uint<24> > &in, hls::stream<ap_uint<24> > & out) {
#pragma HLS dataflow
hls::Mat<IN_IMAGE_HEIGHT, IN_IMAGE_WIDTH, HLS_8UC3> raw_img;
#pragma HLS STREAM variable=raw_img depth=128 dim=1
hls::Mat<RESIZE_IMAGE_HEIGHT, RESIZE_IMAGE_WIDTH, HLS_8UC3> resize_img;
#pragma HLS STREAM variable=resize_img depth=128 dim=1
stream_to_mat(in, raw_img);
// hls::Resize(raw_img, resize_img, HLS_INTER_LINEAR);
hls::Resize_opr_linear(raw_img, resize_img);
mat_to_stream(resize_img, out);
}
void resize_batch(hls::stream<ap_uint<24> > &in, hls::stream<ap_uint<24> > & out, unsigned int reps) {
for (unsigned int rep=0; rep < reps; rep ++) {
#pragma HLS loop_tripcount min=1 max=1
resize(in, out);
}
}
// function used to dump per-layer results
#ifndef __SYNTHESIS__
template<unsigned H, unsigned W, unsigned C, unsigned B>
void dump_results(
hls::stream<ap_uint<C * B> > &result_in_stream,
hls::stream<ap_uint<C * B> > &result_continue,
ap_uint<B> result_dump[H][W][C]
) {
for (size_t i = 0; i < H * W; i++) {
#pragma HLS loop_tripcount min=180*320 max=360*640
ap_uint<C * B> in = result_in_stream.read();
result_continue.write(in);
for (size_t ch = 0; ch < C; ch++) {
ap_uint<B> val = in(B * (ch+1) - 1, B*ch);
size_t h = i / W;
size_t w = i % W;
result_dump[h][w][ch] = val;
}
}
}
#endif
void do_compute(
#ifndef __SYNTHESIS__
// ap_uint<CONV_0_IN_BIT> before_resize[IN_IMAGE_HEIGHT][IN_IMAGE_WIDTH][3],
// ap_uint<CONV_0_IN_BIT> after_resize[RESIZE_IMAGE_HEIGHT][RESIZE_IMAGE_WIDTH][3],
// ap_uint<CONV_0_OUT_BIT> conv0_out[CONV_0_OFM_ROW][CONV_0_OFM_COL][CONV_0_OFM_CH],
// ap_uint<CONV_0_OUT_BIT> pool0_out[CONV_1_IFM_ROW][CONV_1_IFM_COL][CONV_1_IFM_CH],
// ap_uint<CONV_1_OUT_BIT> conv1_out[CONV_1_OFM_ROW][CONV_1_OFM_COL][CONV_1_OFM_CH],
// ap_uint<CONV_1_OUT_BIT> pool1_out[CONV_2_IFM_ROW][CONV_2_IFM_COL][CONV_2_IFM_CH],
// ap_uint<CONV_2_OUT_BIT> conv2_out[CONV_2_OFM_ROW][CONV_2_OFM_COL][CONV_2_OFM_CH],
// ap_uint<CONV_2_OUT_BIT> pool2_out[CONV_3_IFM_ROW][CONV_3_IFM_COL][CONV_3_IFM_CH],
// ap_uint<CONV_3_OUT_BIT> conv3_out[CONV_3_OFM_ROW][CONV_3_OFM_COL][CONV_3_OFM_CH],
// ap_uint<CONV_3_OUT_BIT> pool3_out[CONV_4_IFM_ROW][CONV_4_IFM_COL][CONV_4_IFM_CH],
// ap_uint<CONV_4_OUT_BIT> conv4_out[CONV_4_OFM_ROW][CONV_4_OFM_COL][CONV_4_OFM_CH],
// ap_uint<CONV_5_OUT_BIT> conv5_out[CONV_5_OFM_ROW][CONV_5_OFM_COL][CONV_5_OFM_CH],
// ap_uint<CONV_6_OUT_BIT> conv6_out[CONV_6_OFM_ROW][CONV_6_OFM_COL][CONV_6_OFM_CH],
// ap_uint<CONV_7_OUT_BIT> conv7_out[CONV_7_OFM_ROW][CONV_7_OFM_COL][CONV_7_OFM_CH],
#endif
stream<my_ap_axis >& in,
stream<my_ap_axis >& out,
const unsigned int reps
) {
#pragma HLS DATAFLOW
// hls::stream<ap_uint<128> > in_stream_extract("in_stream_extract");
// #pragma HLS STREAM variable=in_stream_extract depth=16 dim=1
// hls::stream<ap_uint<128 * 3> > in_stream0("in_stream0");
// #pragma HLS STREAM variable=in_stream0 depth=16 dim=1
hls::stream<ap_uint<64> > in_stream_extract("in_stream_extract");
#pragma HLS STREAM variable=in_stream_extract depth=16 dim=1
hls::stream<ap_uint<64 * 3> > in_stream0("in_stream0");
#pragma HLS STREAM variable=in_stream0 depth=16 dim=1
hls::stream<ap_uint<CONV_0_IN_BIT * CONV_0_IFM_CH> > in_stream1("in_stream1");
#pragma HLS STREAM variable=in_stream1 depth=16 dim=1
hls::stream<ap_uint<CONV_0_IN_BIT * CONV_0_IFM_CH> > in_stream2("in_stream2");
#pragma HLS STREAM variable=in_stream2 depth=16 dim=1
hls::stream<ap_uint<CONV_0_OUT_BIT * CONV_0_OFM_CH> > conv_0_out("conv_0_out");
#pragma HLS STREAM variable=conv_0_out depth=128 dim=1
hls::stream<ap_uint<CONV_0_OUT_BIT * CONV_0_OFM_CH> > pool_0_out("pool_0_out");
#pragma HLS STREAM variable=pool_0_out depth=128 dim=1
hls::stream<ap_uint<CONV_1_OUT_BIT * CONV_1_OFM_CH> > conv_1_out("conv_1_out");
#pragma HLS STREAM variable=conv_1_out depth=128 dim=1
hls::stream<ap_uint<CONV_1_OUT_BIT * CONV_1_OFM_CH> > pool_1_out("pool_1_out");
#pragma HLS STREAM variable=pool_1_out depth=128 dim=1
hls::stream<ap_uint<CONV_2_OUT_BIT * CONV_2_OFM_CH> > conv_2_out("conv_2_out");
#pragma HLS STREAM variable=conv_2_out depth=128 dim=1
hls::stream<ap_uint<CONV_2_OUT_BIT * CONV_2_OFM_CH> > pool_2_out("pool_2_out");
#pragma HLS STREAM variable=pool_2_out depth=128 dim=1
hls::stream<ap_uint<CONV_3_OUT_BIT * CONV_3_OFM_CH> > conv_3_out("conv_3_out");
#pragma HLS STREAM variable=conv_3_out depth=128 dim=1
hls::stream<ap_uint<CONV_3_OUT_BIT * CONV_3_OFM_CH> > pool_3_out("pool_3_out");
#pragma HLS STREAM variable=pool_3_out depth=128 dim=1
hls::stream<ap_uint<CONV_4_OUT_BIT * CONV_4_OFM_CH> > conv_4_out("conv_4_out");
#pragma HLS STREAM variable=conv_4_out depth=128 dim=1
hls::stream<ap_uint<CONV_5_OUT_BIT * CONV_5_OFM_CH> > conv_5_out("conv_5_out");
#pragma HLS STREAM variable=conv_5_out depth=128 dim=1
hls::stream<ap_uint<CONV_6_OUT_BIT * CONV_6_OFM_CH> > conv_6_out("conv_6_out");
#pragma HLS STREAM variable=conv_6_out depth=128 dim=1
hls::stream<ap_uint<CONV_7_OUT_BIT * CONV_7_OFM_CH> > conv_7_out("conv_7_out");
#pragma HLS STREAM variable=conv_7_out depth=128 dim=1
hls::stream<ap_uint<CONV_8_IN_BIT * CONV_8_SIMD> > conv_8_in("conv_8_in");
#pragma HLS STREAM variable=conv_8_in depth=64 dim=1
hls::stream<ap_uint<32 * CONV_8_PE> > conv_8_out("conv_8_out");
#pragma HLS STREAM variable=conv_8_out depth=64 dim=1
// #ifndef __SYNTHESIS__
// hls::stream<ap_uint<CONV_0_IN_BIT * CONV_0_IFM_CH> > in_stream1_dup("in_stream1_dup");
// hls::stream<ap_uint<CONV_0_IN_BIT * CONV_0_IFM_CH> > in_stream2_dup("in_stream2_dup");
// hls::stream<ap_uint<CONV_0_OUT_BIT * CONV_0_OFM_CH> > conv_0_out_dup("conv_0_out_dup");
// hls::stream<ap_uint<CONV_0_OUT_BIT * CONV_0_OFM_CH> > pool_0_out_dup("pool_0_out_dup");
// hls::stream<ap_uint<CONV_1_OUT_BIT * CONV_1_OFM_CH> > conv_1_out_dup("conv_1_out_dup");
// hls::stream<ap_uint<CONV_1_OUT_BIT * CONV_1_OFM_CH> > pool_1_out_dup("pool_1_out_dup");
// hls::stream<ap_uint<CONV_2_OUT_BIT * CONV_2_OFM_CH> > conv_2_out_dup("conv_2_out_dup");
// hls::stream<ap_uint<CONV_2_OUT_BIT * CONV_2_OFM_CH> > pool_2_out_dup("pool_2_out_dup");
// hls::stream<ap_uint<CONV_3_OUT_BIT * CONV_3_OFM_CH> > conv_3_out_dup("conv_3_out_dup");
// hls::stream<ap_uint<CONV_3_OUT_BIT * CONV_3_OFM_CH> > pool_3_out_dup("pool_3_out_dup");
// hls::stream<ap_uint<CONV_4_OUT_BIT * CONV_4_OFM_CH> > conv_4_out_dup("conv_4_out_dup");
// hls::stream<ap_uint<CONV_5_OUT_BIT * CONV_5_OFM_CH> > conv_5_out_dup("conv_5_out_dup");
// hls::stream<ap_uint<CONV_6_OUT_BIT * CONV_6_OFM_CH> > conv_6_out_dup("conv_6_out_dup");
// hls::stream<ap_uint<CONV_7_OUT_BIT * CONV_7_OFM_CH> > conv_7_out_dup("conv_7_out_dup");
// #endif
// const unsigned int num_per_rep = IN_IMAGE_HEIGHT * IN_IMAGE_WIDTH * 3 * 4 / 64;
// ExtractPixels<128, num_per_rep> (in, in_stream_extract, reps);
// StreamingDataWidthConverter_Batch<128, 128 * 3, num_per_rep>(in_stream_extract, in_stream0, reps);
// StreamingDataWidthConverter_Batch<128 * 3, CONV_0_IN_BIT * CONV_0_IFM_CH, num_per_rep / 3> (in_stream0, in_stream1, reps);
const unsigned int num_per_rep = IN_IMAGE_HEIGHT * IN_IMAGE_WIDTH * 3 * 8 / 64;
ExtractPixels<64, num_per_rep> (in, in_stream_extract, reps);
StreamingDataWidthConverter_Batch<64, 64 * 3, num_per_rep>(in_stream_extract, in_stream0, reps);
StreamingDataWidthConverter_Batch<64 * 3, CONV_0_IN_BIT * CONV_0_IFM_CH, num_per_rep / 3> (in_stream0, in_stream1, reps);
#ifndef __SYNTHESIS__
cout << "in_stream1 size " << in_stream1.size() << endl;
// dump_results<IN_IMAGE_HEIGHT, IN_IMAGE_WIDTH, 3, CONV_0_IN_BIT>(in_stream1, in_stream1_dup, before_resize);
#endif
resize_batch(
#ifndef __SYNTHESIS__
in_stream1_dup,
#else
in_stream1,
#endif
in_stream2, reps);
#ifndef __SYNTHESIS__
cout << "in_stream2 size " << in_stream2.size() << endl;
// dump_results<RESIZE_IMAGE_HEIGHT, RESIZE_IMAGE_WIDTH, 3, CONV_0_IN_BIT>(in_stream2, in_stream2_dup, after_resize);
#endif
#ifndef __SYNTHESIS__
// ofstream ofs("xcel_conv0_optrace.log");
#endif
// conv3x3_bn_act_optrace<
conv3x3_bn_act<
CONV_0_IFM_ROW,
CONV_0_IFM_COL,
CONV_0_IFM_CH,
CONV_0_IN_BIT,
CONV_0_OFM_CH,
CONV_0_OUT_BIT,
CONV_0_W_BIT,
32,
CONV_0_INC_BIT,
CONV_0_BIAS_BIT,
CONV_0_SIMD,
CONV_0_PE,
CONV_0_L_SHIFT
>(
in_stream2,
conv_0_w,
conv_0_inc,
conv_0_bias,
conv_0_out,
reps
// ofs
);
#ifndef __SYNTHESIS__
// ofs.close();
cout << "conv_0_out size " << conv_0_out.size() << endl;
// dump_results<CONV_0_OFM_ROW, CONV_0_OFM_COL, CONV_0_OFM_CH, CONV_0_OUT_BIT>(conv_0_out, conv_0_out_dup, conv0_out);
#endif
max_pool2d<
2,
CONV_0_OFM_ROW,
CONV_0_OFM_COL,
CONV_0_OFM_CH,
CONV_0_OUT_BIT
>(
conv_0_out,
pool_0_out,
reps
);
#ifndef __SYNTHESIS__
cout << "pool_0_out size " << pool_0_out.size() << endl;
// dump_results<CONV_1_IFM_ROW, CONV_1_IFM_COL, CONV_1_IFM_CH, CONV_0_OUT_BIT>(pool_0_out, pool_0_out_dup, pool0_out);
#endif
conv3x3_bn_act<
CONV_1_IFM_ROW,
CONV_1_IFM_COL,
CONV_1_IFM_CH,
CONV_1_IN_BIT,
CONV_1_OFM_CH,
CONV_1_OUT_BIT,
CONV_1_W_BIT,
32,
CONV_1_INC_BIT,
CONV_1_BIAS_BIT,
CONV_1_SIMD,
CONV_1_PE,
CONV_1_L_SHIFT
>(
pool_0_out,
conv_1_w,
conv_1_inc,
conv_1_bias,
conv_1_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_1_out size " << conv_1_out.size() << endl;
// dump_results<CONV_1_OFM_ROW, CONV_1_OFM_COL, CONV_1_OFM_CH, CONV_1_OUT_BIT>(conv_1_out, conv_1_out_dup, conv1_out);
#endif
max_pool2d<
2,
CONV_1_OFM_ROW,
CONV_1_OFM_COL,
CONV_1_OFM_CH,
CONV_1_OUT_BIT
>(
conv_1_out,
pool_1_out,
reps
);
#ifndef __SYNTHESIS__
cout << "pool_1_out size " << pool_1_out.size() << endl;
// dump_results<CONV_2_IFM_ROW, CONV_2_IFM_COL, CONV_2_IFM_CH, CONV_1_OUT_BIT>(pool_1_out, pool_1_out_dup, pool1_out);
#endif
conv3x3_bn_act<
CONV_2_IFM_ROW,
CONV_2_IFM_COL,
CONV_2_IFM_CH,
CONV_2_IN_BIT,
CONV_2_OFM_CH,
CONV_2_OUT_BIT,
CONV_2_W_BIT,
32,
CONV_2_INC_BIT,
CONV_2_BIAS_BIT,
CONV_2_SIMD,
CONV_2_PE,
CONV_2_L_SHIFT
>(
pool_1_out,
conv_2_w,
conv_2_inc,
conv_2_bias,
conv_2_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_2_out size " << conv_2_out.size() << endl;
// dump_results<CONV_2_OFM_ROW, CONV_2_OFM_COL, CONV_2_OFM_CH, CONV_2_OUT_BIT>(conv_2_out, conv_2_out_dup, conv2_out);
#endif
max_pool2d<
2,
CONV_2_OFM_ROW,
CONV_2_OFM_COL,
CONV_2_OFM_CH,
CONV_2_OUT_BIT
>(
conv_2_out,
pool_2_out,
reps
);
#ifndef __SYNTHESIS__
cout << "pool_2_out size " << pool_2_out.size() << endl;
// dump_results<CONV_3_IFM_ROW, CONV_3_IFM_COL, CONV_3_IFM_CH, CONV_2_OUT_BIT>(pool_2_out, pool_2_out_dup, pool2_out);
#endif
conv3x3_bn_act<
CONV_3_IFM_ROW,
CONV_3_IFM_COL,
CONV_3_IFM_CH,
CONV_3_IN_BIT,
CONV_3_OFM_CH,
CONV_3_OUT_BIT,
CONV_3_W_BIT,
32,
CONV_3_INC_BIT,
CONV_3_BIAS_BIT,
CONV_3_SIMD,
CONV_3_PE,
CONV_3_L_SHIFT
>(
pool_2_out,
conv_3_w,
conv_3_inc,
conv_3_bias,
conv_3_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_3_out size " << conv_3_out.size() << endl;
// dump_results<CONV_3_OFM_ROW, CONV_3_OFM_COL, CONV_3_OFM_CH, CONV_3_OUT_BIT>(conv_3_out, conv_3_out_dup, conv3_out);
#endif
max_pool2d<
2,
CONV_3_OFM_ROW,
CONV_3_OFM_COL,
CONV_3_OFM_CH,
CONV_3_OUT_BIT
>(
conv_3_out,
pool_3_out,
reps
);
#ifndef __SYNTHESIS__
cout << "pool_3_out size " << pool_3_out.size() << endl;
// dump_results<CONV_4_IFM_ROW, CONV_4_IFM_COL, CONV_4_IFM_CH, CONV_3_OUT_BIT>(pool_3_out, pool_3_out_dup, pool3_out);
#endif
conv3x3_bn_act<
CONV_4_IFM_ROW,
CONV_4_IFM_COL,
CONV_4_IFM_CH,
CONV_4_IN_BIT,
CONV_4_OFM_CH,
CONV_4_OUT_BIT,
CONV_4_W_BIT,
32,
CONV_4_INC_BIT,
CONV_4_BIAS_BIT,
CONV_4_SIMD,
CONV_4_PE,
CONV_4_L_SHIFT
>(
pool_3_out,
conv_4_w,
conv_4_inc,
conv_4_bias,
conv_4_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_4_out size " << conv_4_out.size() << endl;
// dump_results<CONV_4_OFM_ROW, CONV_4_OFM_COL, CONV_4_OFM_CH, CONV_4_OUT_BIT>(conv_4_out, conv_4_out_dup, conv4_out);
#endif
conv3x3_bn_act<
CONV_5_IFM_ROW,
CONV_5_IFM_COL,
CONV_5_IFM_CH,
CONV_5_IN_BIT,
CONV_5_OFM_CH,
CONV_5_OUT_BIT,
CONV_5_W_BIT,
32,
CONV_5_INC_BIT,
CONV_5_BIAS_BIT,
CONV_5_SIMD,
CONV_5_PE,
CONV_5_L_SHIFT
>(
conv_4_out,
conv_5_w,
conv_5_inc,
conv_5_bias,
conv_5_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_5_out size " << conv_5_out.size() << endl;
// dump_results<CONV_5_OFM_ROW, CONV_5_OFM_COL, CONV_5_OFM_CH, CONV_5_OUT_BIT>(conv_5_out, conv_5_out_dup, conv5_out);
#endif
conv3x3_bn_act<
CONV_6_IFM_ROW,
CONV_6_IFM_COL,
CONV_6_IFM_CH,
CONV_6_IN_BIT,
CONV_6_OFM_CH,
CONV_6_OUT_BIT,
CONV_6_W_BIT,
32,
CONV_6_INC_BIT,
CONV_6_BIAS_BIT,
CONV_6_SIMD,
CONV_6_PE,
CONV_6_L_SHIFT
>(
conv_5_out,
conv_6_w,
conv_6_inc,
conv_6_bias,
conv_6_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_6_out size " << conv_6_out.size() << endl;
// dump_results<CONV_6_OFM_ROW, CONV_6_OFM_COL, CONV_6_OFM_CH, CONV_6_OUT_BIT>(conv_6_out, conv_6_out_dup, conv6_out);
#endif
conv3x3_bn_act<
CONV_7_IFM_ROW,
CONV_7_IFM_COL,
CONV_7_IFM_CH,
CONV_7_IN_BIT,
CONV_7_OFM_CH,
CONV_7_OUT_BIT,
CONV_7_W_BIT,
32,
CONV_7_INC_BIT,
CONV_7_BIAS_BIT,
CONV_7_SIMD,
CONV_7_PE,
CONV_7_L_SHIFT
>(
conv_6_out,
conv_7_w,
conv_7_inc,
conv_7_bias,
conv_7_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_7_out size " << conv_7_out.size() << endl;
// dump_results<CONV_7_OFM_ROW, CONV_7_OFM_COL, CONV_7_OFM_CH, CONV_7_OUT_BIT>(conv_7_out, conv_7_out_dup, conv7_out);
#endif
StreamingDataWidthConverter_Batch<
CONV_7_OFM_CH * CONV_7_OUT_BIT,
CONV_8_IN_BIT * CONV_8_SIMD,
CONV_7_OFM_ROW * CONV_7_OFM_COL
>(
conv_7_out,
conv_8_in,
reps
);
conv1x1 <
CONV_8_IFM_ROW,
CONV_8_IFM_COL,
CONV_8_IFM_CH,
CONV_8_IN_BIT,
CONV_8_OFM_CH,
CONV_8_W_BIT,
32,
CONV_8_SIMD,
CONV_8_PE
>(
conv_8_in,
conv_8_w,
conv_8_out,
reps
);
#ifndef __SYNTHESIS__
cout << "conv_8_out size " << conv_8_out.size() << endl;
#endif
AddLast<CONV_8_OFM_ROW*CONV_8_OFM_COL*CONV_8_OFM_CH/2>(
conv_8_out,
out, reps
);
}
#ifdef __SYNTHESIS__
void ultranet(stream<my_ap_axis >& in, stream<my_ap_axis >& out, const unsigned int reps) {
#pragma HLS INTERFACE axis register both port=out
#pragma HLS INTERFACE axis register both port=in
#pragma HLS INTERFACE s_axilite port=reps bundle=control
#pragma HLS INTERFACE s_axilite port=return bundle=control
#pragma HLS ARRAY_PARTITION variable = conv_0_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_0_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_0_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_1_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_1_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_1_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_2_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_2_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_2_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_3_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_3_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_3_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_4_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_4_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_4_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_5_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_5_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_5_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_6_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_6_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_6_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_7_w complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_7_inc complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_7_bias complete dim = 1
#pragma HLS ARRAY_PARTITION variable = conv_8_w complete dim = 1
do_compute(in, out, reps);
}
#endif