From 4d039c70010232995c470e1edc8da8246190912f Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Wed, 8 Apr 2020 23:45:11 +0100 Subject: [PATCH] [HLSCustomOp] use dictionaries for all resource reporting --- .../analysis/fpgadataflow/hls_synth_res_estimation.py | 6 ++---- src/finn/custom_op/fpgadataflow/__init__.py | 10 +++++----- .../transformation/fpgadataflow/annotate_resources.py | 6 +++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/finn/analysis/fpgadataflow/hls_synth_res_estimation.py b/src/finn/analysis/fpgadataflow/hls_synth_res_estimation.py index d2fc9bd37..68738aba9 100644 --- a/src/finn/analysis/fpgadataflow/hls_synth_res_estimation.py +++ b/src/finn/analysis/fpgadataflow/hls_synth_res_estimation.py @@ -60,14 +60,12 @@ def hls_synth_res_estimation(model): ) if os.path.isfile(xmlfile): - res_dict[node.name] = [] + res_dict[node.name] = dict() tree = ET.parse(xmlfile) root = tree.getroot() for item in root.findall("AreaEstimates/Resources"): for child in item: - res_dict[node.name].append( - "{} : {}".format(child.tag, child.text) - ) + res_dict[node.name][child.tag] = child.text else: raise Exception( """Please run "HLSSynth_IPGen" first diff --git a/src/finn/custom_op/fpgadataflow/__init__.py b/src/finn/custom_op/fpgadataflow/__init__.py index fb302027b..c4ee7944c 100644 --- a/src/finn/custom_op/fpgadataflow/__init__.py +++ b/src/finn/custom_op/fpgadataflow/__init__.py @@ -79,11 +79,11 @@ class HLSCustomOp(CustomOp): def node_res_estimation(self): """Returns summarized resource estimation of BRAMs and LUTs - of the node.""" - resources = [] - resources.append("BRAM_18K: " + str(self.bram_estimation())) - resources.append("LUT: " + str(self.lut_estimation())) - return resources + of the node as a dictionary.""" + ret = dict() + ret["BRAM_18K"] = self.bram_estimation() + ret["LUT"] = self.lut_estimation() + return ret def bram_estimation(self): """Function for BRAM resource estimation, is member function of diff --git a/src/finn/transformation/fpgadataflow/annotate_resources.py b/src/finn/transformation/fpgadataflow/annotate_resources.py index e7f5aa686..4806c2eb6 100644 --- a/src/finn/transformation/fpgadataflow/annotate_resources.py +++ b/src/finn/transformation/fpgadataflow/annotate_resources.py @@ -58,9 +58,9 @@ class AnnotateResources(Transformation): res_dict = model.analysis(res_fxn) total_dict = {} for lname in res_dict.keys(): - layer_res = res_dict[lname] - for res_entry in layer_res: - r_type, r_amount = res_entry.split(": ") + layer_res_dict = res_dict[lname] + for r_type in layer_res_dict.keys(): + r_amount = layer_res_dict[r_type] r_amount = float(r_amount) if r_type in total_dict.keys(): total_dict[r_type] += r_amount -- GitLab