aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/npu_performance.py
diff options
context:
space:
mode:
authorMichael McGeagh <michael.mcgeagh@arm.com>2020-12-03 15:21:36 +0000
committerpatrik.gustavsson <patrik.gustavsson@arm.com>2020-12-07 14:54:45 +0000
commit6f72526b3c74c0e64075563be2ddf7f9708ad12c (patch)
tree34bd513e6a2fa1b96b72682589be3351c0ddf98c /ethosu/vela/npu_performance.py
parent1e05afa473cf2ca08d2a3464dae6bd2809913c83 (diff)
downloadethos-u-vela-6f72526b3c74c0e64075563be2ddf7f9708ad12c.tar.gz
MLBEDSW-3685 Fix dangerous default value usage
Pylint W0102: When a mutable value as list or dictionary is detected in a default value for an argument. Replace detected instances with None, and upon checking for None, sets the default accordingly Signed-off-by: Michael McGeagh <michael.mcgeagh@arm.com> Change-Id: I4eb73d07d01d4cdefa586eb71b9c76746eee3b11
Diffstat (limited to 'ethosu/vela/npu_performance.py')
-rw-r--r--ethosu/vela/npu_performance.py43
1 files changed, 22 insertions, 21 deletions
diff --git a/ethosu/vela/npu_performance.py b/ethosu/vela/npu_performance.py
index 9a6e8cd2..d28df97d 100644
--- a/ethosu/vela/npu_performance.py
+++ b/ethosu/vela/npu_performance.py
@@ -489,7 +489,7 @@ def estimate_memory_bandwidth(arch, mem_area, direction, tensor, block_size: Blo
return bw * (max_burst_len / burst_len)
-def performance_metrics_for_pass(arch, ps, block_config=None, rewrite_list=[], force_outputs_to_fast_storage=False):
+def performance_metrics_for_pass(arch, ps, block_config=None, rewrite_list=None, force_outputs_to_fast_storage=False):
if block_config is None:
block_config = ps.block_config
bws = make_bandwidth_array()
@@ -723,26 +723,27 @@ def performance_metrics_for_pass(arch, ps, block_config=None, rewrite_list=[], f
for tens in dma_op.inputs:
cycles[PassCycles.Npu] += tens.storage_size() / arch.memory_bandwidths_per_cycle[mem_area]
- # apply the desired rewrites
- for rewrite_op, tens, _, _, _, ps_to_rewrite in rewrite_list:
- if ps != ps_to_rewrite:
- continue
- if rewrite_op == SchedulerRewrite.Nop:
- pass # these are fine, no bandwidth changes
- elif rewrite_op in (SchedulerRewrite.ChangeTensorSubPurpose,):
- if tens.purpose == TensorPurpose.FeatureMap:
- bw = estimate_memory_bandwidth(
- arch,
- arch.fast_storage_mem_area,
- BandwidthDirection.Read,
- tens,
- ifm_block,
- replacement_read_bws[tens],
- )
- else:
- bw = replacement_read_bws[tens]
- bws[arch.fast_storage_mem_area][tens.purpose][BandwidthDirection.Read] += bw
- replacement_read_bws[tens] = 0
+ if rewrite_list is not None:
+ # apply the desired rewrites
+ for rewrite_op, tens, _, _, _, ps_to_rewrite in rewrite_list:
+ if ps != ps_to_rewrite:
+ continue
+ if rewrite_op == SchedulerRewrite.Nop:
+ pass # these are fine, no bandwidth changes
+ elif rewrite_op in (SchedulerRewrite.ChangeTensorSubPurpose,):
+ if tens.purpose == TensorPurpose.FeatureMap:
+ bw = estimate_memory_bandwidth(
+ arch,
+ arch.fast_storage_mem_area,
+ BandwidthDirection.Read,
+ tens,
+ ifm_block,
+ replacement_read_bws[tens],
+ )
+ else:
+ bw = replacement_read_bws[tens]
+ bws[arch.fast_storage_mem_area][tens.purpose][BandwidthDirection.Read] += bw
+ replacement_read_bws[tens] = 0
for tens in ps.outputs:
if force_outputs_to_fast_storage: