From 66d7ec060a9c97f2095cb65f7242fa044a505810 Mon Sep 17 00:00:00 2001 From: Diqing Zhong Date: Mon, 1 Feb 2021 19:07:04 +0100 Subject: MLBEDSW-3927: Fix wrong compression ratio Change-Id: I06feeb98fb48badf06097f377a9504e6f4eeae91 Signed-off-by: Diqing Zhong --- ethosu/vela/tensor_allocation.py | 15 ++++----------- ethosu/vela/weight_compressor.py | 3 +++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/ethosu/vela/tensor_allocation.py b/ethosu/vela/tensor_allocation.py index 1e5eb852..0a7da5da 100644 --- a/ethosu/vela/tensor_allocation.py +++ b/ethosu/vela/tensor_allocation.py @@ -202,12 +202,6 @@ def allocate_tensors( else: sg.memory_used_per_type[mem_type] += total_sz - if mem_area == arch.fast_storage_mem_area: - for tens in lrs.ranges: - if tens.purpose == TensorPurpose.Weights: - nng.total_compressed_weights += tens.storage_size() - nng.total_original_weights += tens.elements() * tens.element_size() - print_allocation(lrs, mem_area, mem_type_set, sg, verbose_allocation) if mem_area == MemArea.Sram: @@ -217,10 +211,9 @@ def allocate_tensors( if sg == nng.get_root_subgraph(): nng.memory_used = sg.memory_used - if mem_area == arch.fast_storage_mem_area: - try: - nng.weights_compression_ratio = nng.total_compressed_weights / nng.total_original_weights - except ZeroDivisionError: - nng.weights_compression_ratio = 0.0 + try: + nng.weights_compression_ratio = nng.total_compressed_weights / nng.total_original_weights + except ZeroDivisionError: + nng.weights_compression_ratio = 0.0 return True diff --git a/ethosu/vela/weight_compressor.py b/ethosu/vela/weight_compressor.py index 188b16ad..60ca846c 100644 --- a/ethosu/vela/weight_compressor.py +++ b/ethosu/vela/weight_compressor.py @@ -521,6 +521,9 @@ def update_pass_weight_and_scale_tensors(nng, arch): compress_weights( arch, nng, tens, op.type.npu_block_type, ps.block_config[-1], ofm_depth_step, op.get_dilation_h_w() ) + nng.total_compressed_weights += tens.weight_compressed_offsets[-1] + nng.total_original_weights += tens.elements() * tens.element_size() + # Update source tensor if needs_dma: src_tens = tens.get_dma_src_tensor() -- cgit v1.2.1