diff options
author | Andreas Nevalainen <andreas.nevalainen@arm.com> | 2020-09-25 14:12:43 +0200 |
---|---|---|
committer | Andreas Nevalainen <andreas.nevalainen@arm.com> | 2020-09-25 14:59:46 +0200 |
commit | f3d737ea14eabffede935cb418611b1f624e180a (patch) | |
tree | c8fc87e17cf0c76d6d29d621f4c2f8c58a73a900 /ethosu/vela/graph_optimiser.py | |
parent | 0b9c9a3873da3d368e184308f4f9a4c202e3fb67 (diff) | |
download | ethos-u-vela-f3d737ea14eabffede935cb418611b1f624e180a.tar.gz |
MLBEDSW-2811: Add rescaling to ReLus with different scaling
If IFM/OFM is not 4d rescaling ops are added to ReLus with
different scaling.
Change-Id: I631d44fc8a51fb476b9f62ef90eda26eef3d35f3
Signed-off-by: Andreas Nevalainen <andreas.nevalainen@arm.com>
Diffstat (limited to 'ethosu/vela/graph_optimiser.py')
-rw-r--r-- | ethosu/vela/graph_optimiser.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/ethosu/vela/graph_optimiser.py b/ethosu/vela/graph_optimiser.py index e5fbc25f..68473307 100644 --- a/ethosu/vela/graph_optimiser.py +++ b/ethosu/vela/graph_optimiser.py @@ -657,6 +657,15 @@ def fixup_relus_with_differing_ifm_ofm_scaling(op, arch): relu_fused_op.attrs["fused_activation_function"] = op.type # Tidy up and assign the ifm and ofm to the new op ifm.consumer_list.remove(op) + + # if not 4d, reshape ifm/ofm + if len(ifm.shape) < 4: + ifm_shaped = create_reshape_tensor(ifm, full_shape(4, ifm.shape, 1)) + ifm = ifm_shaped + if len(ofm.shape) < 4: + ofm_shaped = create_reshape_tensor(ofm, full_shape(4, ofm.shape, 1), False) + ofm = ofm_shaped + relu_fused_op.add_input_tensor(ifm) relu_fused_op.set_output_tensor(ofm) op = relu_fused_op |