MLBEDSW-6614 Improve elementwise block size selection
Improved block size selection by favouring larger
block sizes for elementwise operations.
Signed-off-by: Fredrik Svedberg <fredrik.svedberg@arm.com>
Change-Id: I5b30b358d84fcd672935b863c2154bd8f4ccd928
diff --git a/ethosu/vela/architecture_allocator.py b/ethosu/vela/architecture_allocator.py
index e7e7471..b5edcab 100644
--- a/ethosu/vela/architecture_allocator.py
+++ b/ethosu/vela/architecture_allocator.py
@@ -329,7 +329,10 @@
ifm_fetch *= full_blocks.depth
# Scale relative to every output OFM element
- relative_cost = (ifm_fetch + weight_fetch) / ofm_shape.elements()
+ if npu_op_type == NpuBlockType.ElementWise:
+ relative_cost = ofm_shape.elements() / (height * width * depth)
+ else:
+ relative_cost = (ifm_fetch + weight_fetch) / ofm_shape.elements()
# If the entire IFM can be encompassed by both buffers, bias to prefer this configuration
if ifm_shape.elements() < ifm_block.elements() * 2: