diff options
author | Raul Farkas <raul.farkas@arm.com> | 2023-05-16 17:18:31 +0100 |
---|---|---|
committer | Fredrik Svedberg <fredrik.svedberg@arm.com> | 2023-06-16 12:25:03 +0000 |
commit | 3b64f068db4ea8e954a1b472de169dd423b8c049 (patch) | |
tree | cbd0c98da22bb62473daf08fdb6b53209ef6d971 /ethosu/vela/graph_optimiser_util.py | |
parent | 5d24821355ea5c3af1d069fd50864c5f2f0effd3 (diff) | |
download | ethos-u-vela-3b64f068db4ea8e954a1b472de169dd423b8c049.tar.gz |
MLBEDSW-7648: Fix bug with filter padding in conv2d
* Fix bug that caused filter padding to not be added proportionally
compared to the hardware padding added to IFM.
* Update needed_total_padding function that calculates hardware padding
to also account for the cases in which IFM width is not divisible by
the stride width.
* Update supported ops constraint on strides for conv2d to mark ops with
stride width > 3 and IFM width that is not divisible by the
optimization resize factor as not supported.
* Update unit tests that verify correct functionality when checking
whether ops are supported or not.
Change-Id: I62f14cca890b779ca787a9603fa37c873ad522f8
Signed-off-by: Raul Farkas <raul.farkas@arm.com>
Diffstat (limited to 'ethosu/vela/graph_optimiser_util.py')
-rw-r--r-- | ethosu/vela/graph_optimiser_util.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/ethosu/vela/graph_optimiser_util.py b/ethosu/vela/graph_optimiser_util.py index da3fe138..220ba1a9 100644 --- a/ethosu/vela/graph_optimiser_util.py +++ b/ethosu/vela/graph_optimiser_util.py @@ -185,10 +185,11 @@ def calc_explicit_padding(input_size, stride, filter_size, pad_before, pad_after def needed_total_padding(input_size, stride, filter_size): - out_size = (input_size + stride - 1) // stride - needed_input = (out_size - 1) * stride + filter_size - total_padding = max(0, needed_input - input_size) - return total_padding + """Compute hardware padding.""" + if input_size % stride == 0: + return max(filter_size - stride, 0) + + return max(filter_size - (input_size % stride), 0) # Set input/output tensor equivalence to the same id for memory operations |