Skip to content

Commit

Permalink
[microNPU] Fix offloading incompatible average pool (#11469)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lhutton1 authored Jun 30, 2022
1 parent e7851ed commit 80a0c6c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/tvm/relay/op/contrib/ethosu.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,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
Expand All @@ -632,6 +632,7 @@ def __init__(self, func_body: Call):
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"

Expand All @@ -648,10 +649,17 @@ def is_valid(self):
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


Expand Down

0 comments on commit 80a0c6c

Please sign in to comment.