MLBEDSW-7386: Fix assert in pass packing
- The assert was caused due to a faulty optimization being done
in the pass packing when trying to group CPU passes. The code
did not take into account that a CPU op could have many outputs.
-The fix is to make sure that the pass the follows the CPU pass is
not dependent on any of the outputs from the CPU pass. If there is a
dependency the CPU pass cannot be moved.
Change-Id: Ia0c90bae1ed97d503a97e7bc353f834a0fa75130
Signed-off-by: Johan Alfven <johan.alfven@arm.com>
diff --git a/ethosu/vela/pass_packing.py b/ethosu/vela/pass_packing.py
index 6049366..5a9f957 100644
--- a/ethosu/vela/pass_packing.py
+++ b/ethosu/vela/pass_packing.py
@@ -520,11 +520,12 @@
pass_list.insert(insert_index, cpu_ps)
break
+ # Check all outputs from the cpu pass
if (
- cpu_ps.ops[0].ofm in [next_ps.ops[0].ifm, next_ps.ops[0].ifm2]
+ any(ofm in [next_ps.ops[0].ifm, next_ps.ops[0].ifm2] for ofm in cpu_ps.ops[0].outputs)
or next_ps.placement == PassPlacement.MemoryOnly
):
- # Not possible to move
+ # Not possible to move since next pass depends on the output from the cpu pass
break
if pass_list.index(next_ps) == last_idx: