Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
[create_generic_partitions]: minor modification, removed redundant ou…
Browse files Browse the repository at this point in the history
…tput value_info entries. (#26)
  • Loading branch information
mmrahorovic authored Apr 12, 2021
1 parent 0d36220 commit b99707d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/finn/transformation/create_generic_partitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def apply(self, model):
assert (
self.partitioning(node) != partition_id
), """cycle-free graph violated: partition depends on itself"""
print(node)
# print(node)
predecessors = model.find_direct_predecessors(node)
if predecessors is not None:
next_to_check.extend(predecessors)
Expand All @@ -141,11 +141,25 @@ def apply(self, model):
for o in p_out_vi:
p_model.graph.output.append(o)

# remove redundant input value_info entries
# remove redundant input and output value_info entries
for i in p_in_vi:
if i in p_model.graph.value_info:
# the tensor can be both an input and value_info, so we also have to
# ensure that the tensor is not a relevant value_info before removing
if (
i in p_model.graph.value_info
and p_model.find_producer(i.name) is None
):
p_model.graph.value_info.remove(i)

for o in p_out_vi:
# the tensor can both an output and value_info, so we also have to
# ensure that the tensor is not a relevant value_info before removing
if (
o in p_model.graph.value_info
and p_model.find_consumers(o.name) is None
):
p_model.graph.value_info.remove(o)

# save partition model
p_model_filename = (
self.partition_dir + "/partition_" + str(partition_id) + ".onnx"
Expand Down

0 comments on commit b99707d

Please # to comment.