aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/pass_packing.py
diff options
context:
space:
mode:
authorMichael McGeagh <michael.mcgeagh@arm.com>2020-09-08 11:09:48 +0100
committerMichael McGeagh <michael.mcgeagh@arm.com>2020-09-11 13:29:06 +0100
commit8dbf8cfefa1feea6598f5f4864657ba6b6ad60ed (patch)
treee55debe4a80b01a79381a6aca378a9c6a7da5447 /ethosu/vela/pass_packing.py
parentfa4cb29996ffe1e64e39655c2195af6ff02e887a (diff)
downloadethos-u-vela-8dbf8cfefa1feea6598f5f4864657ba6b6ad60ed.tar.gz
MLBEDSW-2745 Support relus with differing scales
In the event we have a relu op with different input and output scales, we need to fuse it with a nop avgpool. Also refactor the existing avgpool nop code to a common function. Signed-off-by: Michael McGeagh <michael.mcgeagh@arm.com> Change-Id: Iedf4513e7595ee4ee1777ba0b1eb38a8df8aed5e
Diffstat (limited to 'ethosu/vela/pass_packing.py')
-rw-r--r--ethosu/vela/pass_packing.py19
1 files changed, 4 insertions, 15 deletions
diff --git a/ethosu/vela/pass_packing.py b/ethosu/vela/pass_packing.py
index 9e36cd62..a1b03fe2 100644
--- a/ethosu/vela/pass_packing.py
+++ b/ethosu/vela/pass_packing.py
@@ -20,8 +20,8 @@ import enum
from .nn_graph import Pass
from .nn_graph import PassPlacement
+from .operation import create_avgpool_nop
from .operation import NpuBlockType
-from .operation import Operation
from .tensor import TensorPurpose
@@ -455,20 +455,9 @@ def pack_into_passes(nng, arch, verbose_packing=False):
# Configure a 1x1 AvgPool and attach the op onto it
op = op_list[0]
inp = op.inputs[0]
- avgpool_name = op.name + "_avgpool"
- avgpool_op = Operation("AvgPool", avgpool_name)
- avgpool_op.inputs = [inp]
- avgpool_op.inputs[0].consumer_list.append(avgpool_op)
- avgpool_op.attrs["padding"] = b"VALID"
- avgpool_op.attrs["npu_block_type"] = NpuBlockType.Pooling
- avgpool_op.attrs["stride_w"] = 1
- avgpool_op.attrs["stride_h"] = 1
- avgpool_op.attrs["filter_width"] = 1
- avgpool_op.attrs["filter_height"] = 1
- avgpool_op.attrs["strides"] = [1, 1, 1, 1]
- avgpool_op.attrs["ksize"] = [1, 1, 1, 1]
- avgpool_op.attrs["skirt"] = [0, 0, 0, 0]
- avgpool_op.attrs["explicit_padding"] = [0, 0, 0, 0]
+
+ avgpool_op = create_avgpool_nop(op.name + "_avgpool")
+ avgpool_op.add_input_tensor(inp)
avgpool_out = inp.clone("_avgpooled")
avgpool_out.consumer_list.append(op)
avgpool_op.set_output_tensor(avgpool_out)