From f8e353bd0a6e48f27e4c16b7243e403e5dae8d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Alfv=C3=A9n?= Date: Fri, 4 Feb 2022 17:24:23 +0100 Subject: Updated elementwise cycle calculation - Corrected rounding error - Number of elements depends on ofm format Signed-off-by: Johan Alfven Change-Id: I568d660b7571b6e0ffb131211b3a89c8be4b9295 --- ethosu/vela/npu_performance.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ethosu/vela/npu_performance.py b/ethosu/vela/npu_performance.py index 0b8e0a67..450fa7b6 100644 --- a/ethosu/vela/npu_performance.py +++ b/ethosu/vela/npu_performance.py @@ -35,6 +35,7 @@ from .architecture_features import SHRAMElements from .architecture_features import TensorFormat from .nn_graph import Graph from .numeric_util import round_up +from .numeric_util import round_up_to_int from .operation import Kernel from .operation import Op from .scheduler import Schedule @@ -388,7 +389,9 @@ def _estimate_conv_cycles(arch, op_type: Op, faf_type: Op, query: PerformanceQue # Estimate output cycles num_ofm_blks = query.ofm_shape.div_round_up(ofm_block).elements() - cycles_output_blk = _estimate_output_cycles_per_element(arch, op_type, faf_type, query) * ofm_block.elements() + cycles_output_blk = round_up_to_int( + _estimate_output_cycles_per_element(arch, op_type, faf_type, query) * ofm_block.elements() + ) # Scale and bias tensor if query.const_shape.depth > 0: @@ -442,8 +445,10 @@ def measure_cycle_cost(arch, op_type: Op, faf_type: Op, query: PerformanceQuery) # Elementwise cycle calculation elif query.npu_block_type == NpuBlockType.ElementWise: cycles.op_macs = 0 - cycles.op_cycles = int(_estimate_output_cycles_per_element(arch, op_type, faf_type, query)) * int( - query.ofm_shape.elements() + ofm_rounding = Shape4D(list(arch.storage_rounding_quantums[query.ofm_format])) + cycles.op_cycles = round_up_to_int( + _estimate_output_cycles_per_element(arch, op_type, faf_type, query) + * Shape4D.round_up(query.ofm_shape, ofm_rounding).elements() ) else: assert False -- cgit v1.2.1