From 1b9218e8ea1e2c2a1e01894ba8fe59cfc978cf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Alfv=C3=A9n?= Date: Tue, 8 Feb 2022 13:01:09 +0100 Subject: MLBEDSW-6180: Protect overwrite of subgraph output Make sure output from subgraph is write protected and not overwritten by an element wise op. Signed-off-by: Johan Alfven Change-Id: Ie26979913843c62794c5346a315b7089206850e0 --- ethosu/vela/extract_npu_subgraphs.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethosu/vela/extract_npu_subgraphs.py b/ethosu/vela/extract_npu_subgraphs.py index 015634c..ada76f2 100644 --- a/ethosu/vela/extract_npu_subgraphs.py +++ b/ethosu/vela/extract_npu_subgraphs.py @@ -120,6 +120,14 @@ def rewrite_tensor_npu_producer_cpu_consumers( call_ps.primary_op.outputs.append(new_tens) new_tens.ops = [call_ps.primary_op] + # Elementwise op can not overwrite ifm if input is used by many consumers + if orig_tens in npu_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 npu_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. -- cgit v1.2.1