35 static const unsigned n_in = 10;
36 static const unsigned n_out = 10;
47 #define DIV_ROUNDUP(n, d) ((n + d - 1) / d) 49 template <
class data_T,
class res_T,
typename CONFIG_T>
51 res_T
res[CONFIG_T::n_out],
52 typename CONFIG_T::weight_t
weights[CONFIG_T::n_in * CONFIG_T::n_out],
53 typename CONFIG_T::bias_t biases[CONFIG_T::n_out]) {
54 unsigned cycle_factor =
DIV_ROUNDUP(CONFIG_T::n_in * CONFIG_T::n_out, CONFIG_T::reuse_factor);
55 typename CONFIG_T::weight_t
mult[CONFIG_T::n_in * CONFIG_T::n_out];
61 typename CONFIG_T::accum_t acc[CONFIG_T::n_out];
62 for (
unsigned iacc = 0; iacc < CONFIG_T::n_out; iacc++) {
63 acc[iacc] = (
typename CONFIG_T::accum_t)biases[iacc];
65 unsigned rufactor = CONFIG_T::reuse_factor;
66 if (CONFIG_T::use_lowlatency) {
67 rufactor = CONFIG_T::n_in;
68 cycle_factor = CONFIG_T::n_out;
71 for (
unsigned ii = 0;
ii < rufactor;
ii++) {
72 if (CONFIG_T::use_lowlatency) {
75 for (
unsigned jj = 0;
jj < cycle_factor;
jj++) {
76 unsigned windex =
ii * cycle_factor +
jj;
77 unsigned index = windex / CONFIG_T::n_out;
78 if (windex > CONFIG_T::n_in * CONFIG_T::n_out - 1)
80 if (CONFIG_T::use_lowlatency) {
83 int aindex = windex / CONFIG_T::n_in;
88 if (CONFIG_T::use_lowlatency) {
90 for (
unsigned ii = 0;
ii < CONFIG_T::n_in;
ii++) {
91 for (
unsigned jj = 0;
jj < CONFIG_T::n_out;
jj++) {
97 for (
unsigned ires = 0; ires < CONFIG_T::n_out; ires++) {
98 res[ires] = (res_T)(acc[ires]);
static const unsigned n_zeros
static const unsigned n_out
void compute_layer(data_T data[CONFIG_T::n_in], res_T res[CONFIG_T::n_out], typename CONFIG_T::weight_t weights[CONFIG_T::n_in *CONFIG_T::n_out], typename CONFIG_T::bias_t biases[CONFIG_T::n_out])
static const bool store_weights_in_bram
static const bool use_lowlatency
#define DIV_ROUNDUP(n, d)
char data[epos_bytes_allocation]
static const unsigned reuse_factor
static const unsigned n_in