You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by lu...@apache.org on 2022/06/28 15:13:03 UTC
[tvm] 01/01: [microNPU] Fix offloading incompatible average pool
This is an automated email from the ASF dual-hosted git repository.
lukhut pushed a commit to branch fix-avg-pool-offload
in repository https://gitbox.apache.org/repos/asf/tvm.git
commit 0c790422daeaa2871dee816be06dca8f92e6a7a6
Author: Luke Hutton <lu...@arm.com>
AuthorDate: Thu May 26 13:28:01 2022 +0000
[microNPU] Fix offloading incompatible average pool
Fixes offloading a few corner cases of average pooling. Specifically
not offloading nn.avg_pool2d when:
* The attribute count_include_pad=True
* Padding exceeds the dimensions [3, 3, 4, 4]
* The pool size is greater than [8, 8] when the pool uses padding
Change-Id: I7be546e28ebe1f17482f3ed3cee56996a71bfcd1
---
python/tvm/relay/op/contrib/ethosu.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/python/tvm/relay/op/contrib/ethosu.py b/python/tvm/relay/op/contrib/ethosu.py
index 806bf6dce2..ed9aa7505d 100644
--- a/python/tvm/relay/op/contrib/ethosu.py
+++ b/python/tvm/relay/op/contrib/ethosu.py
@@ -589,10 +589,17 @@ class MaxPool2DParams:
return False
if not check_batch_size(self.ifm):
return False
+ if self.count_include_pad:
+ return False
if not check_padding(self.padding, self.padding_bounds):
return False
if not check_pool_shape(self.pool_shape):
return False
+ # Averge pool with padding only supports 1 <= pool_shape <= 8
+ if list(self.padding) != [0, 0, 0, 0] and (
+ self.pool_shape[0] > 8 or self.pool_shape[1] > 8
+ ):
+ return False
return True
@@ -613,7 +620,7 @@ class AvgPool2DParams:
composite_name = "ethos-u.avgpool2d"
# The hardware only supports padding upto the numbers as follows
- padding_bounds = [127, 127, 128, 128]
+ padding_bounds = [3, 3, 4, 4]
def __init__(self, func_body: Call):
clip = None
@@ -632,6 +639,7 @@ class AvgPool2DParams:
self.pool_shape = attrs.pool_size
self.strides = attrs.strides
self.padding = attrs.padding
+ self.count_include_pad = attrs.count_include_pad
self.activation = clip
self.pooling_type = "AVG"