-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
47 lines (38 loc) · 1.1 KB
/
main.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
#include <string>
#include <array>
#include <stdlib.h>
#include "ap_fixed.h"
#include "emulator.h"
int main()
{
std::string modelName = "TOoLLiP_v1";
hls4mlEmulator::ModelLoader loader = hls4mlEmulator::ModelLoader(modelName);
std::shared_ptr<hls4mlEmulator::Model> model = loader.load_model();
std::cout << "modelInput = [";
ap_fixed<16,6> modelInput[140];
for (int i = 0; i < 140; i++) {
modelInput[i] = (rand() % 100) / 10.;
std::cout << modelInput[i] << ", ";
}
std::cout << "]" << std::endl;
ap_fixed<16,6> modelResult[1];
for (int i = 0; i < 1; 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;
}