Skip to content

Commit

Permalink
Merge "Merge the fix to correctly compute output size for 1x1 stride …
Browse files Browse the repository at this point in the history
…2 pooling"
  • Loading branch information
hshen14 authored and Gerrit Code Review committed Sep 21, 2017
2 parents b113551 + 6ca55a0 commit 36e7817
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/caffe/layers/mkl_pooling_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void MKLPoolingLayer<Dtype>::Init(
pooled_width_ = static_cast<int>(ceil(static_cast<float>(
bottom[0]->width() + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
bool force_exclude_padding_flag_ = false;
if (pad_h_ || pad_w_) {
if (pad_h_ || pad_w_ || kernel_h_ == 1 || kernel_w_ == 1) {
// If we have padding, ensure that the last pooling starts strictly
// inside the image (instead of at the padding); otherwise clip the last.
if ((pooled_height_ - 1) * stride_h_ >= bottom[0]->height() + pad_h_) {
Expand Down
2 changes: 1 addition & 1 deletion src/caffe/layers/mkldnn_pooling_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void MKLDNNPoolingLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom
width_out_ = static_cast<int>(ceil(static_cast<float>(
bottom[0]->width() + pad_r_ + pad_l_ - kernel_w_) / stride_w_)) + 1;

if (pad_t_ || pad_b_ || pad_r_ || pad_l_) {
if (pad_t_ || pad_b_ || pad_r_ || pad_l_ || kernel_h_ == 1 || kernel_w_ == 1) {
// If we have padding, ensure that the last pooling starts strictly
// inside the image (instead of at the padding); otherwise clip the last.
if ((height_out_ - 1) * stride_h_ >= bottom[0]->height() + pad_t_) {
Expand Down
2 changes: 1 addition & 1 deletion src/caffe/layers/pooling_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void PoolingLayer<Dtype>::Reshape(const vector<Blob<Dtype>*>& bottom,
height_ + 2 * pad_h_ - kernel_h_) / stride_h_)) + 1;
pooled_width_ = static_cast<int>(ceil(static_cast<float>(
width_ + 2 * pad_w_ - kernel_w_) / stride_w_)) + 1;
if (pad_h_ || pad_w_) {
if (pad_h_ || pad_w_ || kernel_h_ == 1 || kernel_w_ == 1) {
// If we have padding, ensure that the last pooling starts strictly
// inside the image (instead of at the padding); otherwise clip the last.
if ((pooled_height_ - 1) * stride_h_ >= height_ + pad_h_) {
Expand Down

0 comments on commit 36e7817

Please sign in to comment.