Skip to content

Commit

Permalink
fix valid padding pooling, fix #121
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Sep 13, 2017
1 parent f57018d commit ba6026d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/layer/arm/pooling_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ int Pooling_arm::forward(const Mat& bottom_blob, Mat& top_blob) const

int wtail = (w - kernel_size) % stride;
int htail = (h - kernel_size) % stride;
if (pad != -233 && (wtail != 0 || htail != 0))
if (pad == -233 || pad == -2333)
{
wtail = 0;
htail = 0;
}
if (wtail != 0 || htail != 0)
{
int wtailpad = 0;
int htailpad = 0;
Expand Down
11 changes: 8 additions & 3 deletions src/layer/pooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ int Pooling::forward(const Mat& bottom_blob, Mat& top_blob) const

int wtail = (w - kernel_size) % stride;
int htail = (h - kernel_size) % stride;
if (pad != -233 && (wtail != 0 || htail != 0))
if (pad == -233 || pad == -2333)
{
wtail = 0;
htail = 0;
}
if (wtail != 0 || htail != 0)
{
int wtailpad = 0;
int htailpad = 0;
Expand Down Expand Up @@ -277,7 +282,7 @@ int Pooling::forward(const Mat& bottom_blob, Mat& top_blob) const
}

// fix tail pad
if (pad != -233 && wtail != 0)
if (wtail != 0)
{
const float scale = (float)kernel_size / wtail;

Expand All @@ -288,7 +293,7 @@ int Pooling::forward(const Mat& bottom_blob, Mat& top_blob) const
outptr += outw;
}
}
if (pad != -233 && htail != 0)
if (htail != 0)
{
const float scale = (float)kernel_size / htail;

Expand Down
2 changes: 1 addition & 1 deletion tools/tensorflow/tensorflow2ncnn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ int main(int argc, char** argv)
{
if (value_padding.s() == "VALID")
{
pad = 0;
pad = -2333;
}
else if (value_padding.s() == "SAME")
{
Expand Down

0 comments on commit ba6026d

Please sign in to comment.