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] |
apeforest
left a comment
There was a problem hiding this comment.
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.
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.
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?
| @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.
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.
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.
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.
…to fix-quantized-pooling
| @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.
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.
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.
May be also good to fix the alignment from L246-L249.
| 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.
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.
…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