From cd65e0388a39403fc13d5f499ffbca3f7828feae Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <yamanu@xilinx.com> Date: Thu, 24 Feb 2022 17:44:36 +0100 Subject: [PATCH] [Thresholding] enable frp, more test bugfixes --- src/finn/custom_op/fpgadataflow/thresholding_batch.py | 5 +++++ tests/fpgadataflow/test_fpgadataflow_thresholding.py | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/finn/custom_op/fpgadataflow/thresholding_batch.py b/src/finn/custom_op/fpgadataflow/thresholding_batch.py index 0ab987c3d..173882bf9 100644 --- a/src/finn/custom_op/fpgadataflow/thresholding_batch.py +++ b/src/finn/custom_op/fpgadataflow/thresholding_batch.py @@ -937,3 +937,8 @@ class Thresholding_Batch(HLSCustomOp): thres_count = out_features * num_steps ret_dict[thres_param_type] = thres_count return ret_dict + + def ipgen_extra_directives(self): + "Return a list of extra tcl directives for HLS synthesis." + + return ["config_compile -pipeline_style frp"] diff --git a/tests/fpgadataflow/test_fpgadataflow_thresholding.py b/tests/fpgadataflow/test_fpgadataflow_thresholding.py index f8ca1db58..24f188175 100644 --- a/tests/fpgadataflow/test_fpgadataflow_thresholding.py +++ b/tests/fpgadataflow/test_fpgadataflow_thresholding.py @@ -165,6 +165,8 @@ def test_fpgadataflow_thresholding(idt, act, nf, ich, exec_mode, mem_mode): # multithreshold util fxn wants NCHW input, not NHWC y = multithreshold(np.transpose(x, (0, 3, 1, 2)), T) + # convert back to NHWC for comparison to hw outputs + y = np.transpose(y, (0, 2, 3, 1)) if act == DataType["BIPOLAR"]: # binary to bipolar y = 2 * y - 1 @@ -258,7 +260,13 @@ def test_runtime_thresholds_single_layer(): # only use second batch element in output; first will be invalid due to # old weights (see above) y = exec_ctx["outp"][1] - expected = multithreshold(in_tensor, T)[1] + + # multithreshold util fxn wants NCHW input, not NHWC + expected = multithreshold(np.transpose(in_tensor, (0, 3, 1, 2)), T) + # convert back to NHWC for comparison to hw outputs + expected = np.transpose(expected, (0, 2, 3, 1))[1] + + # expected = multithreshold(in_tensor, T)[1] if act == DataType["BIPOLAR"]: # binary to bipolar expected = 2 * expected - 1 -- GitLab