New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add count_include_pad support to AvgPool #1163
Conversation
topi/python/topi/nn/pooling.py
Outdated
@@ -42,7 +42,8 @@ def global_pool(data, pool_type, layout="NCHW"): | |||
return cpp.nn.global_pool(data, POOL_TYPE_CODE[pool_type], layout) | |||
|
|||
|
|||
def pool(data, kernel, stride, padding, pool_type, ceil_mode=False, layout="NCHW"): | |||
def pool(data, kernel, stride, padding, pool_type, ceil_mode=False, layout="NCHW", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when there are multiple lines, let us break it into one argument per line
topi/include/topi/nn/pooling.h
Outdated
if (count_include_pad) { | ||
return tsum(output) / (kernel_height * kernel_width); | ||
} else { | ||
auto h_start = output[height_axis] * stride_height - padding_height; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer Expr to auto, when we know the type and can type it out easily
Thanks for the contribution! this is merged |
* Add count_include_pad support to AvgPool * Fix python_cpp/test_topi_pooling.py * Change auto to explicitly type, and fix format.
* Add count_include_pad support to AvgPool * Fix python_cpp/test_topi_pooling.py * Change auto to explicitly type, and fix format.
This PR addressed #1144
I confirmed same result as pytorch using following code:
https://gist.github.com/nishi-t/f1c283f176b073b038338dc2ff044ecf