MLBEDSW-7865: Vela duplicates outputs
We now don't rewrite tensors if the tensor is already an output tensor of the current subgraph
Signed-off-by: William Isaksson <william.isaksson@arm.com>
Change-Id: I9cb36d830616a69d35180326437ff53bcaa62d71
diff --git a/ethosu/vela/extract_npu_subgraphs.py b/ethosu/vela/extract_npu_subgraphs.py
index dcc8687..c4f66b8 100644
--- a/ethosu/vela/extract_npu_subgraphs.py
+++ b/ethosu/vela/extract_npu_subgraphs.py
@@ -246,12 +246,13 @@
need_rewrite = True
break
for orig_out_tens in orig_sg.output_tensors:
- if tens == orig_out_tens:
- need_rewrite = True
- elif tens.equivalence_id == orig_out_tens.equivalence_id:
- need_rewrite = True
- multiple_npu_sg_have_same_cpu_out_tens = True
- output_tensor = orig_out_tens
+ if tens not in curr_sg.output_tensors:
+ if tens == orig_out_tens:
+ need_rewrite = True
+ elif tens.equivalence_id == orig_out_tens.equivalence_id:
+ need_rewrite = True
+ multiple_npu_sg_have_same_cpu_out_tens = True
+ output_tensor = orig_out_tens
if need_rewrite:
rewrite_tensor_npu_producer_cpu_consumers(