-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Support full convention in quantized pooling #13260
Conversation
5191444
to
5198063
Compare
This PR depends on #11047 to past the new unit test. |
@TaoLv thanks for your contribution - could you please take a look at the failed CI and re-trigger it? |
@mxnet-label-bot add [pr-work-in-progress] |
@kalyc Code was re-based and passed the CI. It's ready for review now. |
@zheng-da @reminisce @szha @eric-haibin-lin @apeforest |
@mxnet-label-bot update [pr-awaiting-review] |
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.
Thanks for your contribution.
(dshape[3] + 2 * param.pad[1] - param.kernel[1]) / | ||
param.stride[1]; | ||
} else { | ||
oshape[2] = 1 + static_cast<int>(std::ceil( |
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.
It might be good to write a function to do such calculation, with a flag pool_enum to distinguish the way of calculating the shape. kValid: using floor, otherwise, using ceil.
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.
You are probably right. But this code snippet was copied from FP32 pooling infer shape here: https://github.com/apache/incubator-mxnet/blob/master/src/operator/nn/pooling.cc#L163
I try not to change the code of FP32 pooling in this PR and keep the code align between quantized pooling and FP32 pooling. So I would keep it as is and refactor them in another PR in the future. What do you think?
@@ -214,7 +214,7 @@ def check_quantized_conv(data_shape, kernel, num_filter, pad, stride, no_bias, q | |||
|
|||
@with_seed() | |||
def test_quantized_pooling(): | |||
def check_quantized_pooling(data_shape, kernel, pool_type, pad, stride, global_pool, qdtype): | |||
def check_quantized_pooling(data_shape, kernel, pool_type, pad, stride, global_pool, qdtype, convention): |
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.
I suggest we keep this test to test the default behavior without passing in convention. Add another test to pass in convention as an extra argument.
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.
Having another check function like check_quantized_pooling_with_convention
may need much redundant code here. Do you think we can give the argument convention
a default value here?
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.
It's okay to only keep this test method. But As @yuxihu mentioned, you may want to test the backward compatibility of the operator without passing this argument.
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.
Sure.
…to fix-quantized-pooling
@@ -214,7 +214,7 @@ def check_quantized_conv(data_shape, kernel, num_filter, pad, stride, no_bias, q | |||
|
|||
@with_seed() | |||
def test_quantized_pooling(): | |||
def check_quantized_pooling(data_shape, kernel, pool_type, pad, stride, global_pool, qdtype): | |||
def check_quantized_pooling(data_shape, kernel, pool_type, pad, stride, global_pool, qdtype, convention): |
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.
What is the default convention before this PR? By adding a new argument, you are testing "valid" and "full". Has the default case been covered with your change?
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.
The default convention for mxnet pooling is "valid".
https://github.com/apache/incubator-mxnet/blob/master/src/operator/nn/pooling-inl.h#L74
I will set the default value for argument "convention" to "valid" here and revert the change for L264-L267. So the behavior of these 4 test cases will be as before.
@@ -244,7 +245,8 @@ def check_quantized_pooling(data_shape, kernel, pool_type, pad, stride, global_p | |||
quantized_pooling = mx.sym.contrib.quantized_pooling(data=qdata, min_data=min_data, | |||
max_data=max_data, kernel=kernel, |
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.
May be also good to fix the alignment from L246-L249.
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.
Fixed.
@@ -244,7 +245,8 @@ def check_quantized_pooling(data_shape, kernel, pool_type, pad, stride, global_p | |||
quantized_pooling = mx.sym.contrib.quantized_pooling(data=qdata, min_data=min_data, | |||
max_data=max_data, kernel=kernel, | |||
pad=pad, stride=stride, pool_type=pool_type, | |||
global_pool=global_pool) | |||
global_pool=global_pool, | |||
pooling_convention=convention) |
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.
same question here: what was the default value for pooling_convention? Make sure the current case is covered.
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.
…to fix-quantized-pooling
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.
LGTM.
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.
LGTM
…to fix-quantized-pooling
@marcoabreu I don't have any idea about the CI failure. Could you help to take a look? Thanks. |
Description
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.
Changes
Comments