From 7a6f8438aaf750380a9fff799ca81ff5c7e2ae43 Mon Sep 17 00:00:00 2001 From: Michael McGeagh Date: Wed, 2 Dec 2020 15:29:22 +0000 Subject: MLBEDSW-2066 Improve Exception messages Minor refactoring to use fstrings. Improve Error classes to correctly inherit the base class. Use existing exception classes instead of plain exceptions where it makes sense. Signed-off-by: Michael McGeagh Change-Id: I0941c04e91010da1db77299517a8e2d896371e77 --- ethosu/vela/tensor_allocation.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'ethosu/vela/tensor_allocation.py') diff --git a/ethosu/vela/tensor_allocation.py b/ethosu/vela/tensor_allocation.py index 9736ca22..7f66579e 100644 --- a/ethosu/vela/tensor_allocation.py +++ b/ethosu/vela/tensor_allocation.py @@ -91,7 +91,7 @@ def verify_alignment(live_ranges: LiveRangeGraph, alignment: int): if not all(op and op.run_on_npu for op in tens.ops + tens.consumer_list): # This is a CPU tensor, verify alignment if tens.address % alignment != 0: - raise AllocationError("Tensor {} not aligned to {} bytes".format(tens.name, alignment)) + raise AllocationError(f"Tensor '{tens.name}' not aligned to {alignment} bytes") def verify_allocation(live_ranges: LiveRangeGraph, alignment: int): @@ -104,14 +104,8 @@ def verify_allocation(live_ranges: LiveRangeGraph, alignment: int): 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( - "Overlapping buffers: {}: {} -> {} and {}: {} -> {}".format( - n.name, - tens_n.address, - tens_n.address + n.size, - m.name, - tens_m.address, - tens_m.address + m.size, - ) + f"Overlapping buffers: {n.name}: {tens_n.address} -> {tens_n.address + n.size}" + f" and {m.name}: {tens_m.address} -> {tens_m.address + m.size}" ) -- cgit v1.2.1