MLBEDSW-5286 - MLCE: IndexError for ADD + TANH network
Resolves a bug where an IndexError would occur
if the same tensor was assigned to both IFM
and IFM2 of a binary elementwise operator
due to duplicates being allowed in operator
inputs but not in pass inputs.
Signed-off-by: Dwight Lidman <dwight.lidman@arm.com>
Change-Id: I39a6206a6252f6a848be9f9d4c5a8dc749c71699
diff --git a/ethosu/vela/scheduler.py b/ethosu/vela/scheduler.py
index 044b246..2ac4787 100644
--- a/ethosu/vela/scheduler.py
+++ b/ethosu/vela/scheduler.py
@@ -978,7 +978,10 @@
new_tens.consumer_list.append(parent_op)
parent_op.inputs[idx] = new_tens
- sched_op.parent_ps.inputs[idx] = new_tens
+ # If the index is out of range, IFM and IFM2 are the same tensor
+ # and pass inputs don't have duplicates
+ if idx < len(sched_op.parent_ps.inputs):
+ sched_op.parent_ps.inputs[idx] = new_tens
def print_schedule(self, schedule: Schedule):
print(f"Schedule: '{schedule.name}'")