From 4132c756123264381c517e6ed62339a62f96ecda Mon Sep 17 00:00:00 2001 From: aziz bahri Date: Tue, 9 Apr 2024 16:47:31 +0100 Subject: [PATCH 1/2] [Threshold RTL] padd threshold steps based on activation bitwidth Signed-off-by: aziz bahri --- src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py | 3 ++- tests/end2end/test_end2end_bnn_pynq.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py b/src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py index 67b41d0165..dda04f70f3 100644 --- a/src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py +++ b/src/finn/custom_op/fpgadataflow/rtl/thresholding_rtl.py @@ -529,7 +529,8 @@ def make_weight_file(self, weights, weight_file_mode, weight_file_name): if weights.shape == (1, 1): weights = np.broadcast_to(weights, expected_shape) - width_padded = roundup_to_integer_multiple(weights.shape[1], 4) + odt = self.get_output_datatype().bitwidth() + width_padded = roundup_to_integer_multiple(weights.shape[1], 2**odt) weight_padded = np.zeros((weights.shape[0], width_padded)) weight_padded[: weights.shape[0], :n_thres_steps] = weights weight_stream = [] diff --git a/tests/end2end/test_end2end_bnn_pynq.py b/tests/end2end/test_end2end_bnn_pynq.py index 556ba1d187..84eb970973 100644 --- a/tests/end2end/test_end2end_bnn_pynq.py +++ b/tests/end2end/test_end2end_bnn_pynq.py @@ -136,7 +136,7 @@ def fold_tfc(model): inp_qnt = getCustomOp(inp_qnt_node) inp_qnt.set_nodeattr("PE", 49) # TODO: update PYNQ driver to support runtime writeable weights for RTL Thresholding - # inp_qnt.set_nodeattr("runtime_writeable_weights", 1) + inp_qnt.set_nodeattr("runtime_writeable_weights", 1) return model From b02f72e1becb3c58e4d9ab59844cc1d9e057f4dd Mon Sep 17 00:00:00 2001 From: aziz bahri Date: Wed, 10 Apr 2024 09:38:53 +0100 Subject: [PATCH 2/2] [BNN Test] remove comment Signed-off-by: aziz bahri --- tests/end2end/test_end2end_bnn_pynq.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/end2end/test_end2end_bnn_pynq.py b/tests/end2end/test_end2end_bnn_pynq.py index 84eb970973..94134967fa 100644 --- a/tests/end2end/test_end2end_bnn_pynq.py +++ b/tests/end2end/test_end2end_bnn_pynq.py @@ -135,7 +135,6 @@ def fold_tfc(model): inp_qnt_node = model.get_nodes_by_op_type("Thresholding_rtl")[0] inp_qnt = getCustomOp(inp_qnt_node) inp_qnt.set_nodeattr("PE", 49) - # TODO: update PYNQ driver to support runtime writeable weights for RTL Thresholding inp_qnt.set_nodeattr("runtime_writeable_weights", 1) return model