aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Alfvén <johan.alfven@arm.com>2022-01-18 08:56:56 +0100
committerJohan Alfvén <johan.alfven@arm.com>2022-01-18 10:00:38 +0100
commit36da8d32199bff60c493cd9ef7aa39a057c66304 (patch)
tree3d1118d5771cabcd78dc2dcffdc9b25b32b6e9d7
parent1c08afa0ed049edd486498e62bab94a4dc7924bc (diff)
downloadethos-u-vela-36da8d32199bff60c493cd9ef7aa39a057c66304.tar.gz
Optimize tensor allocation verification
By not comparing items that have already been compared with each other, the number of iterations for the loop is reduced. For large network with long live ranges, this improves compile time significantly. Signed-off-by: Johan Alfven <johan.alfven@arm.com> Change-Id: I298cd6f109527fc32f6db77ffffca9e765a84ce0
-rw-r--r--ethosu/vela/tensor_allocation.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ethosu/vela/tensor_allocation.py b/ethosu/vela/tensor_allocation.py
index db261ae..c82140c 100644
--- a/ethosu/vela/tensor_allocation.py
+++ b/ethosu/vela/tensor_allocation.py
@@ -96,8 +96,9 @@ def verify_allocation(live_ranges: LiveRangeGraph, alignment: int):
for t in range(lr.start_time, lr.end_time + 1):
lrs_at_time[t].append(lr)
for t in range(nr_time_slots):
- for ix, n in enumerate(lrs_at_time[t]):
- for m in lrs_at_time[t][ix + 1 :]:
+ lrs_new_items = [lr for lr in lrs_at_time[t] if t == 0 or lr not in lrs_at_time[t - 1]]
+ for m in lrs_new_items:
+ for n in lrs_at_time[t]:
overlap, tens_n, tens_m = n.overlaps_address(m)
if overlap and not (tens_n.equivalent(tens_m) and tens_n.address == tens_m.address):
raise AllocationError(