aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_supported_operators.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_supported_operators.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_supported_operators.py')
-rw-r--r--ethosu/vela/tflite_supported_operators.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py
index 41862b6e..14c22133 100644
--- a/ethosu/vela/tflite_supported_operators.py
+++ b/ethosu/vela/tflite_supported_operators.py
@@ -556,19 +556,31 @@ class TFLiteSupportedOperators:
@staticmethod
def constraint_stride_width_no_upper_limit(op):
- """Stride width must be greater than or equal to 1.
- For stride widths greater than 3, the post-optimization stride needs to be less than or equal to 3.
- Stride height must be between 1 and 3."""
- w, h = op.get_kernel_stride()
+ """Strides must fulfil the following criteria:
+ - Stride h must be between 1 and 3 when ofm height is greater than 1
+ - Stride w must be between 1 and 3 when ofm height is greater than 1 or
+ stride w must be divisible by 2 or 3 and ifm width must be divisible
+ by stride_w/2 or stride_w/3"""
+
+ stride_w, stride_h = op.get_kernel_stride()
stride_min = 1
stride_max_h = 3
ifm_width = op.ifm.shape[2]
- _, optimized_stride = calc_resize_factor(ifm_width, w) if w > 1 else (1, w)
+ ofm_height = op.ofm.shape[1]
+ ofm_width = op.ofm.shape[2]
+
+ stride_h_valid = ofm_height == 1 or stride_min <= stride_h <= stride_max_h
+
+ _, optimized_stride = calc_resize_factor(ifm_width, stride_w) if stride_w > 1 else (1, stride_w)
# Optimized stride indicates the final Conv2D stride width after all optimizations are performed
can_optimize_stride_width_gt_3 = optimized_stride <= 3
- valid = (stride_min <= w) and (stride_min <= h <= stride_max_h) and can_optimize_stride_width_gt_3
- return valid, f"Op has stride WxH as: {w}x{h}"
+ stride_w_valid = ofm_width == 1 or ((stride_min <= stride_w) and can_optimize_stride_width_gt_3)
+
+ return (
+ stride_h_valid and stride_w_valid,
+ f"Op has stride WxH as: {stride_w}x{stride_h}, ifm shape as: {op.ifm.shape}, ofm shape as: {op.ofm.shape}",
+ )
@staticmethod
def constraint_stride_range_no_padding(op):