From 6d7f9bb91e0dee93955457f1851339542cf6c872 Mon Sep 17 00:00:00 2001 From: Yaman Umuroglu <maltanar@gmail.com> Date: Thu, 20 Aug 2020 10:31:26 +0200 Subject: [PATCH] [Transform] allow prefixes in GiveUniqueNodeNames --- src/finn/transformation/general.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/finn/transformation/general.py b/src/finn/transformation/general.py index 690364a7d..8ad59d2ba 100644 --- a/src/finn/transformation/general.py +++ b/src/finn/transformation/general.py @@ -81,14 +81,19 @@ class RemoveStaticGraphInputs(Transformation): class GiveUniqueNodeNames(Transformation): - """Give unique names to each node in the graph using enumeration.""" + """Give unique names to each node in the graph using enumeration, starting + with given prefix (if specified in the constructor).""" + + def __init__(self, prefix=""): + super().__init__() + self.prefix = prefix def apply(self, model): optype_count = {} for n in model.graph.node: if n.op_type not in optype_count.keys(): optype_count[n.op_type] = 0 - n.name = "%s_%d" % (n.op_type, optype_count[n.op_type]) + n.name = "%s%s_%d" % (self.prefix, n.op_type, optype_count[n.op_type]) optype_count[n.op_type] += 1 # return model_was_changed = False as single iteration is always enough return (model, False) -- GitLab