From d049f6b4946a3d7d6eb11fc8103208342b39d8e6 Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Tue, 25 Aug 2020 16:53:21 +0200 Subject: [PATCH] [Analysis] report post-synth top resources too, annotate as own metadata_prop --- .../analysis/fpgadataflow/post_synth_res.py | 38 +++++++++---------- .../fpgadataflow/annotate_resources.py | 3 ++ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/finn/analysis/fpgadataflow/post_synth_res.py b/src/finn/analysis/fpgadataflow/post_synth_res.py index 1ad0d7c98..79204c54c 100644 --- a/src/finn/analysis/fpgadataflow/post_synth_res.py +++ b/src/finn/analysis/fpgadataflow/post_synth_res.py @@ -81,32 +81,30 @@ def post_synth_res(model, override_synth_report_filename=None): else: restype_to_ind = restype_to_ind_default + def get_instance_stats(inst_name): + row = root.findall(".//*[@contents='%s']/.." % inst_name) + if row != []: + node_dict = {} + row = row[0].getchildren() + for (restype, ind) in restype_to_ind.items(): + node_dict[restype] = int(row[ind].attrib["contents"]) + return node_dict + else: + return None + + # global (top-level) stats, including shell etc. + top_dict = get_instance_stats("(top)") + if top_dict is not None: + res_dict["(top)"] = top_dict + for node in model.graph.node: if node.op_type == "StreamingDataflowPartition": sdp_model = ModelWrapper(getCustomOp(node).get_nodeattr("model")) sdp_res_dict = post_synth_res(sdp_model, synth_report_filename) res_dict.update(sdp_res_dict) elif _is_fpgadataflow_node(node): - row = root.findall(".//*[@contents='%s']/.." % node.name) - if row != []: - node_dict = {} - row = row[0].getchildren() - """ Expected XML structure: -<tablerow class="" suppressoutput="0" wordwrap="0"> - <tableheader class="" contents="Instance" halign="3" width="-1"/> - <tableheader class="" contents="Module" halign="3" width="-1"/> - <tableheader class="" contents="Total LUTs" halign="3" width="-1"/> - <tableheader class="" contents="Logic LUTs" halign="3" width="-1"/> - <tableheader class="" contents="LUTRAMs" halign="3" width="-1"/> - <tableheader class="" contents="SRLs" halign="3" width="-1"/> - <tableheader class="" contents="FFs" halign="3" width="-1"/> - <tableheader class="" contents="RAMB36" halign="3" width="-1"/> - <tableheader class="" contents="RAMB18" halign="3" width="-1"/> - <tableheader class="" contents="DSP48 Blocks" halign="3" width="-1"/> -</tablerow> - """ - for (restype, ind) in restype_to_ind.items(): - node_dict[restype] = int(row[ind].attrib["contents"]) + node_dict = get_instance_stats(node.name) + if node_dict is not None: res_dict[node.name] = node_dict return res_dict diff --git a/src/finn/transformation/fpgadataflow/annotate_resources.py b/src/finn/transformation/fpgadataflow/annotate_resources.py index 8f89ca19a..d6ff05884 100644 --- a/src/finn/transformation/fpgadataflow/annotate_resources.py +++ b/src/finn/transformation/fpgadataflow/annotate_resources.py @@ -100,4 +100,7 @@ class AnnotateResources(Transformation): if "efficiency" in k: total_dict[k] = total_dict[k] / len(graph.node) model.set_metadata_prop("res_total_" + self.mode, str(total_dict)) + if "(top)" in self.res_dict.keys(): + top_dict = self.res_dict["(top)"] + model.set_metadata_prop("res_total_top_" + self.mode, str(top_dict)) return (model, False) -- GitLab