-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcaloADModel.cpp
40 lines (34 loc) · 1009 Bytes
/
caloADModel.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
#include "firmware/myproject.h" //include of the top level of HLS model
#include "emulator.h" //include of emulator modeling
#include <any>
#include "ap_fixed.h"
class caloADModel : public HLS4MLModel{
private:
input_t _input[N_INPUT_1_1];
result_t _result[N_LAYER_6];
public:
virtual void prepare_input(std::any input)
{
input_t* input_p = std::any_cast<input_t*>(input);
for(int i = 0; i < N_INPUT_1_1; ++i)
_input[i] = std::any_cast<input_t>(input_p[i]);
}
virtual void predict()
{
myproject(_input, _result);
}
virtual void read_result(std::any result)
{
result_t *result_p = std::any_cast<result_t*>(result);
for (int i = 0; i < N_LAYER_6; ++i)
result_p[i] = _result[i];
}
};
extern "C" HLS4MLModel* create_model()
{
return new caloADModel;
}
extern "C" void destroy_model(HLS4MLModel* m)
{
delete m;
}