diff options
author | Louis Verhaard <louis.verhaard@arm.com> | 2020-10-14 08:32:41 +0200 |
---|---|---|
committer | Louis Verhaard <louis.verhaard@arm.com> | 2020-10-20 08:50:29 +0200 |
commit | 17afa2837ad366f2da32e2bc0e2659ebb35bd1d5 (patch) | |
tree | 7329fe546be4e2a95e205daf83637c7927bf7684 /ethosu/vela/insert_dma.py | |
parent | 6e827082524af57bf04833c30754384b46216e59 (diff) | |
download | ethos-u-vela-17afa2837ad366f2da32e2bc0e2659ebb35bd1d5.tar.gz |
MLBEDSW-3268: Refactor mark_tensors
- Refactored mark_tensor_purpose
- Initial weight compression is now always done in insert_dma
- Removed mark_tensor_format
Change-Id: Ic719b9bcd1d27e1390d7b9ce8cd21795139ec814
Signed-off-by: Louis Verhaard <louis.verhaard@arm.com>
Diffstat (limited to 'ethosu/vela/insert_dma.py')
-rw-r--r-- | ethosu/vela/insert_dma.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/ethosu/vela/insert_dma.py b/ethosu/vela/insert_dma.py index 56d68d13..fc1e7986 100644 --- a/ethosu/vela/insert_dma.py +++ b/ethosu/vela/insert_dma.py @@ -26,6 +26,7 @@ from .weight_compressor import compress_weights def weights_fit_sram(arch, op, tens, nng): + # Compresses weights and checks if they fit in SRAM if tens.purpose != TensorPurpose.Weights: return True @@ -35,22 +36,17 @@ def weights_fit_sram(arch, op, tens, nng): elif len(tens.shape) == 2: min_weight_size = tens.shape[0] * arch.OFMSplitDepth - # Need to be fit into Sram, as a double buffer - # Only evaluate when the compression test limit will make it impossible to fit - w_comp_test_limit = 2 - if (w_comp_test_limit * min_weight_size * 2) > arch.sram_size: - # check worst compression ratio - npu_block_type = op.attrs.get("npu_block_type", NpuBlockType.Default) - compress_weights(arch, nng, tens, npu_block_type, 16, 16, op.get_dilation_h_w()) + compress_weights(arch, nng, tens, op.type.npu_block_type, 16, 16, op.get_dilation_h_w()) - worst_buffer_size = tens.compression_scale_for_worst_weight_stream * min_weight_size * 2 - if worst_buffer_size > arch.sram_size: - print( - "Weights, {}, are too big to be DMAed to SRAM, estimated minimum size is {} bytes".format( - tens.name, worst_buffer_size - ) + # Need to be fit into Sram, as a double buffer + worst_buffer_size = tens.compression_scale_for_worst_weight_stream * min_weight_size * 2 + if worst_buffer_size > arch.sram_size: + print( + "Weights, {}, are too big to be DMAed to SRAM, estimated minimum size is {} bytes".format( + tens.name, worst_buffer_size ) - return False + ) + return False return True |