|
7 | 7 |
|
8 | 8 | namespace nnet { |
9 | 9 |
|
10 | | -// Note: DataPack logic removed, at least in the initial version |
| 10 | +// Restartable streaming kernel implementation. |
| 11 | +// Computation is carried out in a while-1 loop as long as there is valid input. |
| 12 | +// The loop breaks when the end-of-packet signal is asserted by upstream task. |
11 | 13 | template <class data_pipe, class res_pipe, typename CONFIG_T> |
12 | | -void dense_resource_stream(typename CONFIG_T::weight_t weights, typename CONFIG_T::bias_t biases) { |
| 14 | +[[intel::use_stall_enable_clusters]] void dense_resource_stream(const typename CONFIG_T::weight_t weights, const typename CONFIG_T::bias_t biases) { |
| 15 | + using namespace nnet; |
| 16 | + using DataT = typename ExtractDataType<typename ExtractPipeType<data_pipe>::value_type>::value_type; |
| 17 | + using ResT = typename ExtractDataType<typename ExtractPipeType<res_pipe>::value_type>::value_type; |
| 18 | + |
| 19 | + [[intel::fpga_register]] typename ExtractPipeType<res_pipe>::value_type resbeat; |
13 | 20 |
|
14 | | - [[intel::fpga_register]] typename ExtractPipeType<res_pipe>::value_type res; |
15 | | - [[intel::fpga_register]] auto data = data_pipe::read(); |
16 | | - dense_resource<typename ExtractPipeType<data_pipe>::value_type, typename ExtractPipeType<res_pipe>::value_type, |
17 | | - CONFIG_T>(data, res, weights, biases); |
18 | | - res_pipe::write(res); |
| 21 | + bool keep_going = true; |
| 22 | + bool did_read_input; |
| 23 | + [[intel::initiation_interval(1)]] |
| 24 | + while (keep_going) { |
| 25 | + did_read_input = false; |
| 26 | + [[intel::fpga_register]] auto databeat = data_pipe::read(did_read_input); |
| 27 | + |
| 28 | + if (did_read_input) { |
| 29 | + dense_resource<DataT, ResT, CONFIG_T>(databeat.data, resbeat.data, weights, biases); |
| 30 | + |
| 31 | + resbeat.sop = databeat.sop; |
| 32 | + resbeat.eop = databeat.eop; |
| 33 | + |
| 34 | + res_pipe::write(resbeat); |
| 35 | + keep_going = !databeat.eop; |
| 36 | + } |
| 37 | + } |
19 | 38 | } |
20 | 39 |
|
21 | 40 | } // namespace nnet |
|
0 commit comments