@@ -70,6 +70,7 @@ struct pooling1d_config {
70
70
static const unsigned n_out = (n_in - pool_width) / stride_width + 1 ;
71
71
static const unsigned pad_left = 0 ;
72
72
static const unsigned pad_right = 0 ;
73
+ static const bool count_pad = false ;
73
74
// Pooling function
74
75
static const Pool_Op pool_op = Max;
75
76
};
@@ -130,6 +131,7 @@ void global_pooling1d_cl(data_T data[CONFIG_T::n_in * CONFIG_T::n_filt], res_T r
130
131
131
132
for (int ff = 0 ; ff < CONFIG_T::n_filt; ff++) {
132
133
data_T pool[CONFIG_T::n_in];
134
+ #pragma HLS ARRAY_PARTITION variable=pool complete dim=0
133
135
for (int jj = 0 ; jj < CONFIG_T::n_in; jj++) {
134
136
pool[jj] = data[jj * CONFIG_T::n_filt + ff];
135
137
}
@@ -154,6 +156,7 @@ struct pooling2d_config {
154
156
static const unsigned pad_bottom = 0 ;
155
157
static const unsigned pad_left = 0 ;
156
158
static const unsigned pad_right = 0 ;
159
+ static const bool count_pad = false ;
157
160
// Pooling function
158
161
static const Pool_Op pool_op = Max;
159
162
// Reuse factor
@@ -245,6 +248,7 @@ void pooling2d_cf(data_T data[CONFIG_T::in_height * CONFIG_T::in_width * CONFIG_
245
248
// Loop over input image x in steps of stride
246
249
for (int jj = 0 ; jj < padded_width; jj += CONFIG_T::stride_width) {
247
250
data_T pool[CONFIG_T::pool_height * CONFIG_T::pool_width];
251
+ #pragma HLS ARRAY_PARTITION variable=pool complete dim=0
248
252
// Keep track of number of pixels in image vs padding region
249
253
unsigned img_overlap = 0 ;
250
254
// Loop over pool window y
@@ -255,10 +259,12 @@ void pooling2d_cf(data_T data[CONFIG_T::in_height * CONFIG_T::in_width * CONFIG_
255
259
jj + ll < CONFIG_T::pad_left || jj + ll >= (padded_width - CONFIG_T::pad_right)) {
256
260
// Add padding
257
261
pool[kk * CONFIG_T::stride_width + ll] = pad_val<data_T, CONFIG_T::pool_op>();
262
+ if (CONFIG_T::count_pad)
263
+ img_overlap++;
258
264
} else {
259
265
pool[kk * CONFIG_T::stride_width + ll] =
260
- data[(ii + kk) * CONFIG_T::in_width + ff * CONFIG_T::in_width * CONFIG_T::in_height + ll +
261
- jj ];
266
+ data[(ii + kk - CONFIG_T::pad_top) * CONFIG_T::in_width +
267
+ ff * CONFIG_T::in_width * CONFIG_T::in_height + ll + jj - CONFIG_T::pad_left ];
262
268
img_overlap++;
263
269
}
264
270
}
0 commit comments