Skip to content

Commit 37268db

Browse files
committed
update using exclusive padding for avg-pool
1 parent cc28fb4 commit 37268db

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

paddle/gserver/layers/MKLDNNPoolLayer.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,8 @@ bool MKLDNNPoolLayer::init(const LayerMap& layerMap,
4949
if (type == "max-projection") {
5050
poolAlgo_ = algorithm::pooling_max;
5151
} else if (type == "avg-projection") {
52-
// TODO(TJ): support choosing exclusive or inclusive when paddle support it
53-
// only can make sure that paddle use exclude when ph==pw==0
54-
// otherwise, paddle may used mixed or only include.
55-
poolAlgo_ = (ph_ == 0 && pw_ == 0) ? algorithm::pooling_avg_exclude_padding
56-
: algorithm::pooling_avg_include_padding;
52+
// paddle only use exclude_padding
53+
poolAlgo_ = algorithm::pooling_avg_exclude_padding;
5754
} else {
5855
LOG(FATAL) << "unknow pooling type!";
5956
}
@@ -178,12 +175,6 @@ void MKLDNNPoolLayer::resetFwdPD(std::shared_ptr<pool_fwd::primitive_desc>& pd,
178175
padR,
179176
padKind);
180177
pd.reset(new pool_fwd::primitive_desc(fwdDesc, engine_));
181-
if ((ph_ != 0 || pw_ != 0) && (padR[0] > padL[0] || padR[1] > padL[1])) {
182-
LOG(WARNING)
183-
<< "With this layer " << getName() << ", mkldnn_pool use "
184-
<< "inclusive pooling, while paddle mix inclusice and exclusive."
185-
<< "So they may have different results for this layer.";
186-
}
187178

188179
// prepare workspace if necessary
189180
workspace_ =

paddle/gserver/tests/test_MKLDNN.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,6 @@ void testPoolLayer(const testPoolDesc& pm) {
192192
}
193193

194194
TEST(MkldnnLayer, PoolLayer) {
195-
// For max pooling, MKLDNN has the same result with Paddle.
196-
// For avg pooling, MKLDNN use either inclusive or exclusive pooling, while
197-
// Paddle mixes these two types. So, when encountering some
198-
// test cases with padding>0, they may get different results.
199-
// Then MKLDNN layer will give warnning for these cases.
200195
/* bs, ch, ih, iw, oh, ow, fh, fw, ph, pw, sh, sw*/
201196
testPoolLayer({2, 1, 4, 4, 2, 2, 3, 3, 0, 0, 2, 2});
202197
testPoolLayer({10, 8, 16, 16, 8, 8, 2, 2, 0, 0, 2, 2});
@@ -205,6 +200,7 @@ TEST(MkldnnLayer, PoolLayer) {
205200
testPoolLayer({8, 16, 14, 14, 7, 7, 3, 3, 0, 0, 2, 2});
206201
testPoolLayer({4, 16, 7, 7, 1, 1, 7, 7, 0, 0, 1, 1});
207202
testPoolLayer({4, 2, 5, 5, 3, 3, 5, 5, 1, 1, 1, 1});
203+
testPoolLayer({2, 8, 56, 56, 29, 29, 3, 3, 1, 1, 2, 2});
208204
}
209205

210206
// TODO(TJ): add branch test

0 commit comments

Comments
 (0)