-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfully_connect.cpp
27 lines (25 loc) · 940 Bytes
/
fully_connect.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
#include "fully_connect.h"
void fully_connect(ap_uint<16> CHin, ap_uint<16> Hin, ap_uint<16> Win, ap_uint<16> fc_ch,
float feature_in[], float fc_w[], float fc_b[], float feature_out[])
{
#pragma HLS INTERFACE m_axi depth=4294967295 port=feature_out
#pragma HLS INTERFACE m_axi depth=4294967295 port=fc_b
#pragma HLS INTERFACE m_axi depth=4294967295 port=fc_w
#pragma HLS INTERFACE m_axi depth=4294967295 port=feature_in
#pragma HLS INTERFACE s_axilite port=Win
#pragma HLS INTERFACE s_axilite port=fc_ch
#pragma HLS INTERFACE s_axilite port=Hin
#pragma HLS INTERFACE s_axilite port=return
#pragma HLS INTERFACE s_axilite port=CHin
float sum = 0;
for (int FC_CH = 0; FC_CH < fc_ch; FC_CH++)
{
sum = 0;
for (int j = 0; j < CHin; j++)
for (int i = 0; i < Hin * Win; i++)
#pragma HLS UNROLL
sum = sum + feature_in[j * Hin * Win + i] * fc_w[j * Hin * Win + i];
sum = sum + fc_b[FC_CH];
feature_out[FC_CH] = sum;
}
}