From 5cc4c76988eb72c89fe92e96ae670b1828fedf88 Mon Sep 17 00:00:00 2001 From: Fredrik Svedberg Date: Thu, 16 Jun 2022 13:14:52 +0200 Subject: MLBEDSW-6614 Improve elementwise block size selection Improved block size selection by favouring larger block sizes for elementwise operations. Signed-off-by: Fredrik Svedberg Change-Id: I5b30b358d84fcd672935b863c2154bd8f4ccd928 --- ethosu/vela/architecture_allocator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 @@ def find_block_config( 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: -- cgit v1.2.1