aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tensor_allocation.py
diff options
context:
space:
mode:
authorMichael McGeagh <michael.mcgeagh@arm.com>2020-12-02 15:29:22 +0000
committerMichael McGeagh <michael.mcgeagh@arm.com>2020-12-14 11:38:03 +0000
commit7a6f8438aaf750380a9fff799ca81ff5c7e2ae43 (patch)
tree163c6868ec869ae52a5cfd848207dcf0ef7b212e /ethosu/vela/tensor_allocation.py
parent9b43f846b144d39bfb0cf16853bf6901c74b6672 (diff)
downloadethos-u-vela-7a6f8438aaf750380a9fff799ca81ff5c7e2ae43.tar.gz
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 <michael.mcgeagh@arm.com> Change-Id: I0941c04e91010da1db77299517a8e2d896371e77
Diffstat (limited to 'ethosu/vela/tensor_allocation.py')
-rw-r--r--ethosu/vela/tensor_allocation.py12
1 files changed, 3 insertions, 9 deletions
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}"
)