diff options
author | Björn Davidsson <bjoern.davidsson@arm.com> | 2023-10-10 11:22:59 +0200 |
---|---|---|
committer | Björn Davidsson <bjoern.davidsson@arm.com> | 2023-11-02 10:15:01 +0100 |
commit | 199e8e66ba3d959fd0f584683e5b1c1fda77ce6b (patch) | |
tree | f0b0d88dbebea983adac2b14c99664225d8823f7 /ethosu/vela/register_command_stream_util.py | |
parent | 67daf2a3036608e60d7741f5bdf02196234ef85c (diff) | |
download | ethos-u-vela-199e8e66ba3d959fd0f584683e5b1c1fda77ce6b.tar.gz |
MLBEDSW-8117: Incorrect stride check for IFM/IFM2 and OFM
The constraint check for the IFM/IFM2/OFM strides were coded
according to an incorrect version of the specification.
Changed the check to verify that the strides are a multiple
of 16 bytes. Also changed the wording in the exception message
to clarify if it is a stride or value violating the constraint.
Test case had two stride settings violating the constraint,
after this change one of them still fails the check, so
no change to tests, except in comments clarifying what is
being tested.
Change-Id: I93815d8bb08303b5f747c947c0bbd461b12895e3
Signed-off-by: Björn Davidsson <bjoern.davidsson@arm.com>
Diffstat (limited to 'ethosu/vela/register_command_stream_util.py')
-rw-r--r-- | ethosu/vela/register_command_stream_util.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/ethosu/vela/register_command_stream_util.py b/ethosu/vela/register_command_stream_util.py index c7050a38..74c4f90e 100644 --- a/ethosu/vela/register_command_stream_util.py +++ b/ethosu/vela/register_command_stream_util.py @@ -60,10 +60,18 @@ def check_alignment(payload, required_alignment): raise ByteAlignmentError(f"Cmd1 payload of size: {payload} Bytes is not {required_alignment}-byte aligned") -def check_size(payload, required_multiple): +def check_size(payload, required_multiple, value_type): # assuming payload is defined in bytes if payload % required_multiple != 0: - raise ByteSizeError(f"Cmd1 payload of size: {payload} Bytes is not a multiple of {required_multiple}") + raise ByteSizeError(f"Cmd1 {value_type} of size: {payload} Bytes is not a multiple of {required_multiple}") + + +def check_stride(stride, required_multiple): + check_size(stride, required_multiple, "stride") + + +def check_length(length, required_multiple): + check_size(length, required_multiple, "length") def to_npu_kernel(kernel: Kernel) -> NpuKernel: @@ -263,12 +271,12 @@ def check_strides(fm: NpuFeatureMap, strides: NpuShape3D): if fm.layout == NpuLayout.NHCWB16: strides_to_check = [strides.depth, strides.height] - required_multiple = 16 * element_size_in_bytes + required_multiple = 16 else: strides_to_check = [strides.height, strides.width] required_multiple = element_size_in_bytes for stride in strides_to_check: - check_size(stride, required_multiple) + check_stride(stride, required_multiple) def check_addresses(addresses: List[int], layout: NpuLayout, element_size, arch: ArchitectureFeatures): @@ -384,11 +392,11 @@ def check_dma_op(dma_op: NpuDmaOperation, arch: ArchitectureFeatures): check_alignment(dma_op.src.address, 16) if dma_op.dest.region == BASE_PTR_INDEX_MEM2MEM: check_alignment(dma_op.dest.address, 16) - check_size(dma_op.src.length, 16) + check_length(dma_op.src.length, 16) else: check_alignment(dma_op.src.address, 16) check_alignment(dma_op.dest.address, 16) - check_size(dma_op.src.length, 16) + check_length(dma_op.src.length, 16) # ------------------------------------------------------------------- |