Skip to content

Commit 0f0adc4

Browse files
committed
Fix failing PyTests
1 parent ff86c26 commit 0f0adc4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

hls4ml/backends/fpga/passes/codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def match(self, node):
6767
weights_transposed = node.get_attr('_weights_transposed', False)
6868

6969
# RF = 1 will optimize DSPs anyway, so no need to unroll code
70-
rf_gt_one = node.get_attr('reuse_factor') > 1
70+
rf_gt_one = node.get_attr('reuse_factor', 1) > 1
7171

7272
# User requested unrolled implementation of Dense
7373
is_unrolled = node.get_attr('dense_resource_implementation', 'standard') == 'unrolled'

hls4ml/backends/vivado/passes/convolution_templates.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
static const bool store_weights_in_bram = false;
4040
static const unsigned strategy = nnet::{strategy};
4141
static const nnet::conv_implementation implementation = nnet::conv_implementation::{implementation};
42+
static const unsigned resource_implementation = nnet::{dense_resource_implementation};
43+
template<class data_T, class res_T, class CONFIG_T>
44+
using dense_unrolled = nnet::{unrolled_function}<data_T, res_T, CONFIG_T>;
4245
static const unsigned min_width = {min_width};
4346
static const ap_uint<filt_width> pixels[min_width];
4447
static const unsigned n_partitions = {n_partitions};
@@ -80,6 +83,8 @@ def format(self, node):
8083
params['fill_fn'] = f'fill_buffer_{node.index}'
8184
else:
8285
params['fill_fn'] = 'FillConv1DBuffer'
86+
# TODO - Extend unrolled Dense Resource to Conv1D
87+
params['unrolled_function'] = 'DenseResourceUnrolled'
8388

8489
conv_config = self.template.format(**params)
8590

@@ -292,6 +297,8 @@ def format(self, node):
292297
params['scale_index_type'] = 'scale_index_regular'
293298

294299
params['config_t'] = f'config{node.index}_depthwise_mult'
300+
# TODO - Extend unrolled Dense Resource
301+
params['unrolled_function'] = 'DenseResourceUnrolled'
295302
depthwise_config = self.depthwise_template.format(**params)
296303

297304
# Depthwise mult config
@@ -334,6 +341,8 @@ def format(self, node):
334341
params['scale_index_type'] = 'scale_index_regular'
335342

336343
params['config_t'] = f'config{node.index}_pointwise_mult'
344+
# TODO - Extend unrolled Dense Resource
345+
params['unrolled_function'] = 'DenseResourceUnrolled'
337346
pointwise_config = self.pointwise_template.format(**params)
338347

339348
# Pointwise mult config
@@ -419,6 +428,8 @@ def format(self, node):
419428
params['scale_index_width_type'] = 'scale_index_regular'
420429

421430
params['config_t'] = f'config{node.index}_depthwise_mult'
431+
# TODO - Extend unrolled Dense Resource
432+
params['unrolled_function'] = 'DenseResourceUnrolled'
422433
depthwise_config = self.depthwise_template.format(**params)
423434

424435
# Depthwise mult config
@@ -464,6 +475,8 @@ def format(self, node):
464475
else:
465476
params['scale_index_width_type'] = 'scale_index_regular'
466477
params['config_t'] = f'config{node.index}_pointwise_mult'
478+
# TODO - Extend unrolled Dense Resource
479+
params['unrolled_function'] = 'DenseResourceUnrolled'
467480
pointwise_config = self.pointwise_template.format(**params)
468481

469482
# Pointwise mult config

0 commit comments

Comments
 (0)