aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_graph_optimiser.py
diff options
context:
space:
mode:
authorJohan Alfven <johan.alfven@arm.com>2023-10-27 13:08:21 +0200
committerJohan Alfven <johan.alfven@arm.com>2023-10-31 10:18:33 +0100
commitafb56ae11294bdf50e190cfafd76e507d5e2787d (patch)
treebf377821860dbba9f92bad3395d29b2560c840ef /ethosu/vela/tflite_graph_optimiser.py
parent909923a2461087f64a40e07be7752e8923f70ae7 (diff)
downloadethos-u-vela-afb56ae11294bdf50e190cfafd76e507d5e2787d.tar.gz
MLBEDSW-8201: [MLCE] Extended stride support for CONV_2D
- Added support for stride_h > 3 when ofm height is 1 - Added support for stride_w > 3 when ofm width is 1 - Updated constraints - Updated tests - Updated SUPPORTED_OPS.md Change-Id: I8f89909b05a0f052df5f03702966cee50da61cfc Signed-off-by: Johan Alfven <johan.alfven@arm.com>
Diffstat (limited to 'ethosu/vela/tflite_graph_optimiser.py')
-rw-r--r--ethosu/vela/tflite_graph_optimiser.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/ethosu/vela/tflite_graph_optimiser.py b/ethosu/vela/tflite_graph_optimiser.py
index 794a6ec2..ae11becd 100644
--- a/ethosu/vela/tflite_graph_optimiser.py
+++ b/ethosu/vela/tflite_graph_optimiser.py
@@ -1170,6 +1170,26 @@ def fixup_strided_conv(op: Operation, arch, nng):
stride_x = final_stride
op.attrs.update({"stride_w": stride_x, "stride_h": stride_y, "strides": (1, stride_y, stride_x, 1)})
+ ofm_shape = op.ofm_shapes[0]
+ if ofm_shape.height == 1 or ofm_shape.width == 1:
+ # If height or width is 1 no stride is done in y or x direction and stride value can be set to 1
+ # Before forcing kernel stride to 1 make sure to calculate the correct padding since it is
+ # based on the original kernel stride
+ padding, _ = calc_padding_and_skirt(
+ op.attrs["padding"],
+ op.kernel,
+ ifm_shape,
+ op.attrs.get("explicit_padding"),
+ )
+ # Use explicit padding so it is not recalculated later with the wrong kernel stride
+ op.attrs["padding"] = Padding.EXPLICIT
+ op.attrs["explicit_padding"] = padding
+
+ stride_y = 1 if ofm_shape.height == 1 else stride_y
+ stride_x = 1 if ofm_shape.width == 1 else stride_x
+
+ op.attrs.update({"stride_w": stride_x, "stride_h": stride_y, "strides": (1, stride_y, stride_x, 1)})
+
return op