From fbd8a3307cd6be59fa0c78d204c32466cc675cdc Mon Sep 17 00:00:00 2001 From: xzl Date: Tue, 14 Nov 2017 17:50:33 +0800 Subject: [PATCH] regenerate the proto for support the dilation --- paddle/function/ConvOpTest.h | 9 +++++++-- paddle/function/Im2ColTest.cpp | 3 ++- .../tests/configs/protostr/test_roi_pool_layer.protostr | 2 ++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/paddle/function/ConvOpTest.h b/paddle/function/ConvOpTest.h index 85debb7ae3..d8d3c792df 100644 --- a/paddle/function/ConvOpTest.h +++ b/paddle/function/ConvOpTest.h @@ -81,8 +81,13 @@ void Convolution(const std::string& conv1, for (size_t padding : {0, 1}) { for (size_t dilation : {1, 3}) { if (padding >= filterSize) break; + size_t filterS = (filterSize - 1) * dilation + 1; - if ((conv1 == "NaiveConv-CPU" || conv2 == "NaiveConv-CPU") && + if (inputSize + 2 * padding < filterS) break; + + if ((conv1 == "NaiveConv-CPU" || conv2 == "NaiveConv-CPU" || + conv1 == "NNPACKConv-CPU" || + conv2 == "NNPACKConv-CPU") && dilation > 1) break; @@ -93,7 +98,7 @@ void Convolution(const std::string& conv1, break; size_t outputSize = - (inputSize - filterSize + 2 * padding + stride) / stride; + (inputSize - filterS + 2 * padding + stride) / stride; VLOG(3) << " batchSize=" << batchSize << " inputChannels=" << inputChannels << " inputHeight=" << inputSize diff --git a/paddle/function/Im2ColTest.cpp b/paddle/function/Im2ColTest.cpp index 28507b7e18..1f085538d8 100644 --- a/paddle/function/Im2ColTest.cpp +++ b/paddle/function/Im2ColTest.cpp @@ -32,7 +32,8 @@ void TestIm2ColFunctor() { for (size_t dilation : {1, 3}) { size_t filterSizeH = (filterHeight - 1) * dilation + 1; size_t filterSizeW = (filterWidth - 1) * dilation + 1; - if (inputHeight <= filterSizeH || inputWidth <= filterSizeW) + if (inputHeight + 2 * padding < filterSizeH || + inputWidth + 2 * padding < filterSizeW) break; if (padding >= filterSizeH || padding >= filterSizeW) break; size_t outputHeight = diff --git a/python/paddle/trainer_config_helpers/tests/configs/protostr/test_roi_pool_layer.protostr b/python/paddle/trainer_config_helpers/tests/configs/protostr/test_roi_pool_layer.protostr index f1bc65b3ae..0ec88aa998 100644 --- a/python/paddle/trainer_config_helpers/tests/configs/protostr/test_roi_pool_layer.protostr +++ b/python/paddle/trainer_config_helpers/tests/configs/protostr/test_roi_pool_layer.protostr @@ -36,6 +36,8 @@ layers { stride_y: 1 output_y: 14 img_size_y: 14 + dilation: 1 + dilation_y: 1 } } bias_parameter_name: "___conv_0__.wbias" -- GitLab