diff options
author | Johan Alfvén <johan.alfven@arm.com> | 2022-02-04 17:24:23 +0100 |
---|---|---|
committer | Johan Alfvén <johan.alfven@arm.com> | 2022-03-08 15:47:12 +0100 |
commit | f8e353bd0a6e48f27e4c16b7243e403e5dae8d47 (patch) | |
tree | 20b1cdac9ac5c7c35d5d2f76e5c7921b54ff9d9e | |
parent | 25e700c9894bc9ca5fb219e902c907c04b2048b2 (diff) | |
download | ethos-u-vela-f8e353bd0a6e48f27e4c16b7243e403e5dae8d47.tar.gz |
Updated elementwise cycle calculation
- Corrected rounding error
- Number of elements depends on ofm format
Signed-off-by: Johan Alfven <johan.alfven@arm.com>
Change-Id: I568d660b7571b6e0ffb131211b3a89c8be4b9295
-rw-r--r-- | ethosu/vela/npu_performance.py | 11 |
1 files 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 |