| #ifndef MYPROJECT_BRIDGE_H_ |
| #define MYPROJECT_BRIDGE_H_ |
|
|
| #include "firmware/myproject.h" |
| #include "firmware/nnet_utils/nnet_helpers.h" |
| #include <algorithm> |
| #include <map> |
|
|
| |
|
|
| namespace nnet { |
| bool trace_enabled = false; |
| std::map<std::string, void *> *trace_outputs = NULL; |
| size_t trace_type_size = sizeof(double); |
| } |
|
|
| extern "C" { |
|
|
| struct trace_data { |
| const char *name; |
| void *data; |
| }; |
|
|
| void allocate_trace_storage(size_t element_size) { |
| nnet::trace_enabled = true; |
| nnet::trace_outputs = new std::map<std::string, void *>; |
| nnet::trace_type_size = element_size; |
| } |
|
|
| void free_trace_storage() { |
| for (std::map<std::string, void *>::iterator i = nnet::trace_outputs->begin(); i != nnet::trace_outputs->end(); i++) { |
| void *ptr = i->second; |
| free(ptr); |
| } |
| nnet::trace_outputs->clear(); |
| delete nnet::trace_outputs; |
| nnet::trace_outputs = NULL; |
| nnet::trace_enabled = false; |
| } |
|
|
| void collect_trace_output(struct trace_data *c_trace_outputs) { |
| int ii = 0; |
| for (std::map<std::string, void *>::iterator i = nnet::trace_outputs->begin(); i != nnet::trace_outputs->end(); i++) { |
| c_trace_outputs[ii].name = i->first.c_str(); |
| c_trace_outputs[ii].data = i->second; |
| ii++; |
| } |
| } |
|
|
| |
|
|
| |
| void myproject_float( |
| float *x, |
| float *layer40_out |
| ) { |
|
|
| hls::stream<input_t> x_ap("x"); |
| nnet::convert_data<float, input_t, 1*64*64*1>(x, x_ap); |
|
|
| hls::stream<result_t> layer40_out_ap("layer40_out"); |
|
|
| myproject(x_ap,layer40_out_ap); |
|
|
| nnet::convert_data<result_t, float, 64*64*1>(layer40_out_ap, layer40_out); |
| } |
|
|
| void myproject_double( |
| double *x, |
| double *layer40_out |
| ) { |
|
|
| hls::stream<input_t> x_ap("x"); |
| nnet::convert_data<double, input_t, 1*64*64*1>(x, x_ap); |
|
|
| hls::stream<result_t> layer40_out_ap("layer40_out"); |
|
|
| myproject(x_ap,layer40_out_ap); |
|
|
| nnet::convert_data<result_t, double, 64*64*1>(layer40_out_ap, layer40_out); |
| } |
| } |
|
|
| #endif |
|
|