MLBEDSW-4602: Fix Deepspeech scale & bias reuse issue.
- Deepspeech reuses identical weights and biases throughout
the network. Since biases are now interleaved with weights
there is a scaling issue when the ifm scales differ between
operations using the same weight and scale tensor.
- This commit uses interleaved weights/scales on their first use
but separates scales to source memory on subsequent use (if
the ifm scale is different).
Signed-off-by: Tim Hall <tim.hall@arm.com>
Change-Id: I7aae163438160a919cae04e235966e75355a6148
diff --git a/ethosu/vela/live_range.py b/ethosu/vela/live_range.py
index d75a167..b687a9e 100644
--- a/ethosu/vela/live_range.py
+++ b/ethosu/vela/live_range.py
@@ -344,16 +344,14 @@
lr_graph, tens, target_mem_area, target_mem_type_set
):
continue
-
rng = lr_graph.get_or_create_range(tens)
rng.mark_usage(sg_time)
for sched_op, op_info in sg.schedule.cost_map.items():
- if op_info.npu_weights_tensor and not (
- tensor_should_be_ignored(lr_graph, op_info.npu_weights_tensor, target_mem_area, target_mem_type_set)
- ):
- rng = lr_graph.get_or_create_range(op_info.npu_weights_tensor)
- rng.mark_usage(sg_time)
+ for tensor in [op_info.npu_weights_tensor, op_info.npu_scales_tensor]:
+ if tensor and not (tensor_should_be_ignored(lr_graph, tensor, target_mem_area, target_mem_type_set)):
+ rng = lr_graph.get_or_create_range(tensor)
+ rng.mark_usage(sg_time)
lr_graph.current_time += 1
return lr_graph