Skip to content

Commit

Permalink
add round_mode into pooling param
Browse files Browse the repository at this point in the history
origin is BVLC/caffe@24b0905 and we have some fix
  • Loading branch information
vera121 committed Jan 10, 2022
1 parent 7e78f94 commit e73a136
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/caffe/layers/pooling_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PoolingLayer : public Layer<Dtype> {
Blob<int> max_idx_;
int pad_type_; //CUSTOMIZATION
bool ceil_mode_;
PoolingParameter_RoundMode round_mode_;
int pad_l_; //CUSTOMIZATION
int pad_r_; //CUSTOMIZATION
int pad_t_; //CUSTOMIZATION
Expand Down
20 changes: 19 additions & 1 deletion src/caffe/layers/pooling_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,25 @@ void PoolingLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
|| (!pool_param.has_stride_h() && !pool_param.has_stride_w()))
<< "Stride is stride OR stride_h and stride_w are required.";
global_pooling_ = pool_param.global_pooling();
ceil_mode_ = pool_param.ceil_mode();

if(pool_param.has_round_mode())
{
round_mode_ = pool_param.round_mode();
switch (round_mode_) {
case PoolingParameter_RoundMode_CEIL:
ceil_mode_ = true;
break;
case PoolingParameter_RoundMode_FLOOR:
ceil_mode_ = false;
break;
default:
LOG(FATAL) << "Unknown rounding mode.";
}
}
else{
ceil_mode_ = pool_param.ceil_mode();
}

if (global_pooling_) {
kernel_h_ = bottom[0]->height();
kernel_w_ = bottom[0]->width();
Expand Down
6 changes: 6 additions & 0 deletions src/caffe/proto/caffe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,12 @@ message PoolingParameter {
optional bool global_pooling = 12 [default = false];

optional bool ceil_mode = 14 [default = true]; // Specify floor/ceil mode rounding
// How to calculate the output size - using ceil (default) or floor rounding.
enum RoundMode {
CEIL = 0;
FLOOR = 1;
}
optional RoundMode round_mode = 15 [default = CEIL]; // functionality similar to ceil_mode; higher priority than ceil_mode
}

message Pooling3DParameter {
Expand Down

0 comments on commit e73a136

Please sign in to comment.