提交 37268dbd 编写于 作者: T tensor-tang

update using exclusive padding for avg-pool

上级 cc28fb4b
......@@ -49,11 +49,8 @@ bool MKLDNNPoolLayer::init(const LayerMap& layerMap,
if (type == "max-projection") {
poolAlgo_ = algorithm::pooling_max;
} else if (type == "avg-projection") {
// TODO(TJ): support choosing exclusive or inclusive when paddle support it
// only can make sure that paddle use exclude when ph==pw==0
// otherwise, paddle may used mixed or only include.
poolAlgo_ = (ph_ == 0 && pw_ == 0) ? algorithm::pooling_avg_exclude_padding
: algorithm::pooling_avg_include_padding;
// paddle only use exclude_padding
poolAlgo_ = algorithm::pooling_avg_exclude_padding;
} else {
LOG(FATAL) << "unknow pooling type!";
}
......@@ -178,12 +175,6 @@ void MKLDNNPoolLayer::resetFwdPD(std::shared_ptr<pool_fwd::primitive_desc>& pd,
padR,
padKind);
pd.reset(new pool_fwd::primitive_desc(fwdDesc, engine_));
if ((ph_ != 0 || pw_ != 0) && (padR[0] > padL[0] || padR[1] > padL[1])) {
LOG(WARNING)
<< "With this layer " << getName() << ", mkldnn_pool use "
<< "inclusive pooling, while paddle mix inclusice and exclusive."
<< "So they may have different results for this layer.";
}
// prepare workspace if necessary
workspace_ =
......
......@@ -192,11 +192,6 @@ void testPoolLayer(const testPoolDesc& pm) {
}
TEST(MkldnnLayer, PoolLayer) {
// For max pooling, MKLDNN has the same result with Paddle.
// For avg pooling, MKLDNN use either inclusive or exclusive pooling, while
// Paddle mixes these two types. So, when encountering some
// test cases with padding>0, they may get different results.
// Then MKLDNN layer will give warnning for these cases.
/* bs, ch, ih, iw, oh, ow, fh, fw, ph, pw, sh, sw*/
testPoolLayer({2, 1, 4, 4, 2, 2, 3, 3, 0, 0, 2, 2});
testPoolLayer({10, 8, 16, 16, 8, 8, 2, 2, 0, 0, 2, 2});
......@@ -205,6 +200,7 @@ TEST(MkldnnLayer, PoolLayer) {
testPoolLayer({8, 16, 14, 14, 7, 7, 3, 3, 0, 0, 2, 2});
testPoolLayer({4, 16, 7, 7, 1, 1, 7, 7, 0, 0, 1, 1});
testPoolLayer({4, 2, 5, 5, 3, 3, 5, 5, 1, 1, 1, 1});
testPoolLayer({2, 8, 56, 56, 29, 29, 3, 3, 1, 1, 2, 2});
}
// TODO(TJ): add branch test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册