-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
hls4ml/templates/quartus/firmware/nnet_utils/nnet_stream.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef NNET_STREAM_H | ||
#define NNET_STREAM_H | ||
|
||
namespace nnet { | ||
|
||
struct broadcast_config { | ||
static const unsigned in_height = 10; | ||
static const unsigned in_width = 10; | ||
static const unsigned n_chan = 1; | ||
static const unsigned n_dupl = 2; | ||
}; | ||
|
||
template<class data_T, class res_T, int N> | ||
void clone_stream(stream<data_T> &data, stream<res_T> &res1, stream<res_T> &res2) { | ||
CloneLoop: | ||
#pragma ii 1 | ||
for (int i = 0; i < N / data_T::size; i++) { | ||
data_T in_data = data.read(); | ||
res_T out_data1; | ||
res_T out_data2; | ||
|
||
ClonePack: | ||
#pragma unroll | ||
for (int j = 0; j < data_T::size; j++) { | ||
out_data1[j] = in_data[j]; | ||
out_data2[j] = in_data[j]; | ||
} | ||
|
||
res1.write(out_data1); | ||
res2.write(out_data2); | ||
} | ||
} | ||
|
||
} | ||
|
||
#endif |