aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Alfven <johan.alfven@arm.com>2023-08-22 11:02:47 +0200
committerJohan Alfven <johan.alfven@arm.com>2023-08-22 11:02:47 +0200
commitc02eaa3e25840aee4ff909df263d4d0673227c5d (patch)
tree4f8917f9ac22c2ebefc1f131e3d850a85386698b
parent00a15db3e1a188b25065d095152d701f4394cdc5 (diff)
downloadethos-u-vela-c02eaa3e25840aee4ff909df263d4d0673227c5d.tar.gz
MLBEDSW-7949: [MLCE] Remove duplicate cpu tensors
- If a npu op is followed by a convolution op than runs on the cpu, the optimized file ends up containing a duplicated tensor called _cpu. Functionality wise not a problem but the graph will look strange in a graph viewer. - This error was introduced when removing duplicate weights tensors but the above use case was not considered in that patch. - The fix is to make sure that only the weight and bias tensor are modified. Change-Id: I576f13650f1f9d3d50a421ab7100fc8b5ab62657 Signed-off-by: Johan Alfven <johan.alfven@arm.com>
-rw-r--r--ethosu/vela/tflite_writer.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ethosu/vela/tflite_writer.py b/ethosu/vela/tflite_writer.py
index 5aa38a7..6d85567 100644
--- a/ethosu/vela/tflite_writer.py
+++ b/ethosu/vela/tflite_writer.py
@@ -103,10 +103,10 @@ class TFLiteSerialiser:
self.align_nng_inputs_to_tflite(op)
all_ops.append(op)
if op.type.is_conv2d_op() or op.type.is_depthwise_conv2d_op() or op.type == Op.FullyConnected:
- # Op is run on CPU, make sure original tensor are written back
+ # Op is run on CPU, make sure the original weight and bias tensors are written back
# instead of the cloned/reshaped (see tflite_reader)
for idx, inp in enumerate(op.inputs):
- if inp is not None and inp.src_tensor is not None:
+ if inp != op.ifm and inp is not None and inp.src_tensor is not None:
op.inputs[idx] = inp.src_tensor
# list of tuple(Op, string, op.version); the custom code is only used for 3rd party custom operators