From 36da8d32199bff60c493cd9ef7aa39a057c66304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Alfv=C3=A9n?= Date: Tue, 18 Jan 2022 08:56:56 +0100 Subject: 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 Change-Id: I298cd6f109527fc32f6db77ffffca9e765a84ce0 --- ethosu/vela/tensor_allocation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ethosu/vela/tensor_allocation.py b/ethosu/vela/tensor_allocation.py index db261ae5..c82140c5 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( -- cgit v1.2.1