diff --git a/cmake/flags.cmake b/cmake/flags.cmake index 337db53b37fa378abef9f43c745047df0ae92212..e087770991aefc17535d50c0539c50f6316520d7 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -65,9 +65,9 @@ endif() set(COMMON_FLAGS -fPIC -fno-omit-frame-pointer -# -Wall -# -Wextra -# -Werror + -Wall + -Wextra + -Werror -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-unused-parameter diff --git a/paddle/gserver/layers/BilinearInterpLayer.cpp b/paddle/gserver/layers/BilinearInterpLayer.cpp index 9f0c01a838562af1c77e4b5e34479e19bf4c6c86..f37efc824a2ec20161e18aefec37667496d4c5af 100644 --- a/paddle/gserver/layers/BilinearInterpLayer.cpp +++ b/paddle/gserver/layers/BilinearInterpLayer.cpp @@ -23,7 +23,22 @@ REGISTER_LAYER(bilinear_interp, BilinearInterpLayer); size_t BilinearInterpLayer::getSize() { inImgH_ = inputLayers_[0]->getOutput().getFrameHeight(); inImgW_ = inputLayers_[0]->getOutput().getFrameWidth(); + + const BilinearInterpConfig& conf = config_.inputs(0).bilinear_interp_conf(); + if (inImgH_ == 0) { + inImgH_ = conf.img_size_y(); + } + if (inImgW_ == 0) { + inImgW_ = conf.img_size_x(); + } + + outImgH_ = conf.out_size_y(); + outImgW_ = conf.out_size_x(); + numChannels_ = conf.num_channels(); + + CHECK(outImgH_ > 0 && outImgW_ > 0); CHECK(inImgH_ > 0 && inImgW_ > 0); + CHECK(numChannels_); getOutput().setFrameHeight(outImgH_); getOutput().setFrameWidth(outImgW_); @@ -37,15 +52,6 @@ bool BilinearInterpLayer::init(const LayerMap& layerMap, CHECK_EQ(1, config_.inputs_size()); - const BilinearInterpConfig& conf = config_.inputs(0).bilinear_interp_conf(); - - outImgH_ = conf.out_size_y(); - outImgW_ = conf.out_size_x(); - numChannels_ = conf.num_channels(); - - CHECK(outImgH_ > 0 && outImgW_ > 0); - CHECK(numChannels_); - return true; } diff --git a/paddle/gserver/tests/test_LayerGrad.cpp b/paddle/gserver/tests/test_LayerGrad.cpp index 8ee89992ddf1e9b8d67acb59b53a0c64af5981e7..b5b944833e47f2b874c865fe245cec900e08ad7f 100644 --- a/paddle/gserver/tests/test_LayerGrad.cpp +++ b/paddle/gserver/tests/test_LayerGrad.cpp @@ -40,6 +40,8 @@ TEST(Layer, BilinearInterpLayer) { LayerInputConfig* input = config.layerConfig.add_inputs(); BilinearInterpConfig* bilinear = input->mutable_bilinear_interp_conf(); + bilinear->set_img_size_x(32); + bilinear->set_img_size_y(32); bilinear->set_out_size_x(64); bilinear->set_out_size_y(64); bilinear->set_num_channels(4); diff --git a/proto/ModelConfig.proto.m4 b/proto/ModelConfig.proto.m4 index 41d081942778e2bd1c11452c41825cc4eb3e1848..479b457e55a7dac58ff390cce8d67d46da3b474d 100644 --- a/proto/ModelConfig.proto.m4 +++ b/proto/ModelConfig.proto.m4 @@ -213,10 +213,13 @@ message OperatorConfig { } message BilinearInterpConfig { - // The size if output feature map. - required uint32 out_size_x = 1; - required uint32 out_size_y = 2; - required uint32 num_channels = 3; + // The size of input feature map. + optional uint32 img_size_x = 1; + optional uint32 img_size_y = 2; + // The size of output feature map. + required uint32 out_size_x = 3; + required uint32 out_size_y = 4; + required uint32 num_channels = 5; } message ImageConfig {