aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/extract_npu_subgraphs.py
diff options
context:
space:
mode:
authorJohan Alfvén <johan.alfven@arm.com>2022-02-04 11:19:17 +0100
committerJohan Alfvén <johan.alfven@arm.com>2022-02-07 10:13:09 +0100
commit8d57aaa722a4f0430d7e7520d194d1df5394eb6c (patch)
treeb691d998389809d04db58576bb31fecf30a7c3f3 /ethosu/vela/extract_npu_subgraphs.py
parente546defed8b204b175f708fa51366462db41ad07 (diff)
downloadethos-u-vela-8d57aaa722a4f0430d7e7520d194d1df5394eb6c.tar.gz
MLBEDSW-6148: Allow overwrite of subgraph input
This change will allow the subgraph's input tensor to be reused/overwritten by the output from an elementwise op if there is only one consumer attached to the input tensor. Signed-off-by: Johan Alfven <johan.alfven@arm.com> Change-Id: I317188af11a5470614770e18dc8973462fd5f21c
Diffstat (limited to 'ethosu/vela/extract_npu_subgraphs.py')
-rw-r--r--ethosu/vela/extract_npu_subgraphs.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/ethosu/vela/extract_npu_subgraphs.py b/ethosu/vela/extract_npu_subgraphs.py
index f46f031a..ac24e430 100644
--- a/ethosu/vela/extract_npu_subgraphs.py
+++ b/ethosu/vela/extract_npu_subgraphs.py
@@ -87,6 +87,14 @@ def rewrite_tensor_cpu_producer_npu_consumers(
call_ps.inputs.append(orig_tens)
call_ps.primary_op.inputs.append(orig_tens)
+ # Elementwise op can not overwrite ifm if input is used by many consumers
+ if orig_tens in cpu_subgraph.input_tensors and len(orig_tens.consumers()) > 1:
+ new_tens.ifm_write_protected = True
+
+ # Elementwise op can not overwrite ifm if tensor is used as output from sub graph
+ if orig_tens in cpu_subgraph.output_tensors:
+ new_tens.ifm_write_protected = True
+
for op in list(orig_tens.consumers()):
if op is None:
continue # Subgraph consumers handled separately.