aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_reader.py
diff options
context:
space:
mode:
authorPatrik Gustavsson <patrik.gustavsson@arm.com>2020-11-04 12:43:50 +0100
committerPatrik Gustavsson <patrik.gustavsson@arm.com>2020-11-10 11:19:49 +0100
commit6ae0e4212abf1b92506fcbb180f647a953a37d89 (patch)
tree7fc75cdc65619195a437033748acb2ecc5c7e25e /ethosu/vela/tflite_reader.py
parentfd31428db9985fe31811063428ebc609a2b42d05 (diff)
downloadethos-u-vela-6ae0e4212abf1b92506fcbb180f647a953a37d89.tar.gz
MLBEDSW-2868 Refactor separation of scale + bias tensors
Changed so that there is an option to set if Tensor clone should be seen as unique or not. Signed-off-by: Patrik Gustavsson <patrik.gustavsson@arm.com> Change-Id: Ie51c1a5e84b535380d498b105aa18ccba1c8b27c
Diffstat (limited to 'ethosu/vela/tflite_reader.py')
-rw-r--r--ethosu/vela/tflite_reader.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/ethosu/vela/tflite_reader.py b/ethosu/vela/tflite_reader.py
index 82feddd9..24f9f874 100644
--- a/ethosu/vela/tflite_reader.py
+++ b/ethosu/vela/tflite_reader.py
@@ -41,9 +41,8 @@ def decode_str(s):
return s.decode("utf-8")
-def clone_and_reshape_tensor(src_tens, reorder):
-
- tens = src_tens.clone("_reshape")
+def clone_and_reshape_tensor(src_tens, reorder, set_unique):
+ tens = src_tens.clone("_reshape", set_unique)
tens.shape = [src_tens.shape[idx] for idx in reorder]
tens.bandwidth_shape = tens.shape
tens.storage_shape = tens.shape
@@ -153,17 +152,16 @@ class TFLiteSubgraph:
if op.type.is_depthwise_conv2d_op() or op.type.is_conv2d_op() or op.type == Op.FullyConnected:
if inputs[1].values is not None:
if op.type == Op.FullyConnected:
- inputs[1] = clone_and_reshape_tensor(inputs[1], (1, 0))
+ inputs[1] = clone_and_reshape_tensor(inputs[1], (1, 0), False)
else:
- inputs[1] = clone_and_reshape_tensor(inputs[1], (1, 2, 3, 0))
+ inputs[1] = clone_and_reshape_tensor(inputs[1], (1, 2, 3, 0), False)
if op.type.needs_bias() and len(inputs) <= op_type.info.indices.biases[0]:
# No Bias tensor
inputs.append(None)
if inputs[-1] and inputs[-1].values is not None:
- inputs[-1] = clone_and_reshape_tensor(inputs[-1], (0,))
# Since bias tensor is used for both bias and scale,
- # set different equivalence_id for all bias tensors
- inputs[-1].set_random_equivalence_id()
+ # a clone with a unique equivalence_id is needed
+ inputs[-1] = clone_and_reshape_tensor(inputs[-1], (0,), True)
if opt_serializer is not None:
op.attrs = opt_serializer.deserialize(op_data)