-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (41 loc) · 1.25 KB
/
main.cpp
File metadata and controls
52 lines (41 loc) · 1.25 KB
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
#include <string>
#include <array>
#include <stdlib.h>
#include "ap_fixed.h"
#include "emulator.h"
int main()
{
std::string modelName = "topo_v1";
hls4mlEmulator::ModelLoader loader = hls4mlEmulator::ModelLoader(modelName);
std::shared_ptr<hls4mlEmulator::Model> model = loader.load_model();
//make sure these match your current model
static const int N_INPUT_1_1 = 20;
static const int N_LAYER_11 = 1;
ap_fixed<16,6> modelInput[N_INPUT_1_1];
ap_fixed<16,6> modelResult[N_LAYER_11];
std::cout << "modelInput = [";
for (int i = 0; i < N_INPUT_1_1; i++) {
modelInput[i] = (rand() % 100) / 10.;
std::cout << modelInput[i] << ", ";
}
std::cout << "]" << std::endl;
for (int i = 0; i < N_LAYER_11; i++) {
modelResult[i] = -1;
}
model->prepare_input(modelInput);
model->predict();
std::cout << "modelResult before read = [";
for (int i = 0; i < 1; i++){
std::cout << modelResult[i] << ", ";
}
std::cout << "]" << std::endl;
std::cout << "reading result..." << std::endl;
model->read_result(modelResult);
std::cout << "DONE..." << std::endl;
std::cout << "modelResult after read = [";
for (int i = 0; i < 1; i++){
std::cout << modelResult[i] << ", ";
}
std::cout << "]" << std::endl;
return 0;
}