-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathereg_v1.cpp
79 lines (65 loc) · 2.7 KB
/
ereg_v1.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
//
// rfnoc-hls-neuralnet: Vivado HLS code for neural-net building blocks
//
// Copyright (C) 2017 EJ Kreinar
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <iostream>
#include "parameters.h"
#include "ereg_v1.h"
#include "nnet_utils/nnet_layer.h"
#include "nnet_utils/nnet_conv.h"
#include "nnet_utils/nnet_activation.h"
//hls-fpga-machine-learning insert weights
#include "weights/w1.h"
#include "weights/b1.h"
#include "weights/w2.h"
#include "weights/b2.h"
#include "weights/w3.h"
#include "weights/b3.h"
void ereg_v1(
input_t data[N_INPUTS],
result_t res[N_OUTPUTS])
//unsigned short &const_size_in,
//unsigned short &const_size_out)
{
//hls-fpga-machine-learning insert IO
//#pragma HLS ARRAY_RESHAPE variable=data complete dim=0
//#pragma HLS ARRAY_RESHAPE variable=res complete dim=0
//#pragma HLS INTERFACE ap_vld port=data,res
#pragma HLS PIPELINE
//const_size_in = N_INPUTS;
//const_size_out = N_OUTPUTS;
// ****************************************
// NETWORK INSTANTIATION
// ****************************************
//hls-fpga-machine-learning insert layers
layer1_t layer1_out[N_LAYER_1];
#pragma HLS ARRAY_PARTITION variable=layer1_out complete dim=0
layer1_t logits1[N_LAYER_1];
#pragma HLS ARRAY_PARTITION variable=logits1 complete dim=0
nnet::compute_layer<input_t, layer1_t, config1>(data, logits1, w1, b1);
nnet::linear<layer1_t, layer1_t, linear_config1>(logits1, layer1_out);
layer2_t layer2_out[N_LAYER_2];
#pragma HLS ARRAY_PARTITION variable=layer2_out complete dim=0
layer2_t logits2[N_LAYER_2];
#pragma HLS ARRAY_PARTITION variable=logits2 complete dim=0
nnet::compute_layer<layer1_t, layer2_t, config2>(layer1_out, logits2, w2, b2);
nnet::linear<layer2_t, layer2_t, linear_config2>(logits2, layer2_out);
result_t logits3[N_OUTPUTS];
#pragma HLS ARRAY_PARTITION variable=logits3 complete dim=0
nnet::compute_layer<layer2_t, result_t, config3>(layer2_out, logits3, w3, b3);
nnet::linear<result_t, result_t, linear_config3>(logits3, res);
}