diff --git a/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h b/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h index abd0d6b09901a7cd124c245e359f9d38f52bda26..3afcc6fa85a4a6a03697663719b6ab685897b68b 100644 --- a/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h +++ b/paddle/cuda/include/stub/hl_cuda_cudnn_stub.h @@ -78,7 +78,9 @@ inline void hl_create_convolution_descriptor(hl_convolution_descriptor* conv, int padding_height, int padding_width, int stride_height, - int stride_width) {} + int stride_width, + int dilation_h, + int dilation_w) {} inline void hl_reset_convolution_descriptor(hl_convolution_descriptor conv, hl_tensor_descriptor image, @@ -86,7 +88,9 @@ inline void hl_reset_convolution_descriptor(hl_convolution_descriptor conv, int padding_height, int padding_width, int stride_height, - int stride_width) {} + int stride_width, + int dilation_h, + int dilation_w) {} inline void hl_destroy_convolution_descriptor(hl_convolution_descriptor conv) {} @@ -99,7 +103,8 @@ inline void hl_conv_workspace(hl_tensor_descriptor input, int* convBwdDataAlgo, size_t* bwdDataLimitBytes, int* convBwdFilterAlgo, - size_t* bwdFilterLimitBytes) {} + size_t* bwdFilterLimitBytes, + bool useDilation) {} inline void hl_convolution_forward(hl_tensor_descriptor input, real* input_data, diff --git a/paddle/cuda/src/hl_cuda_cudnn.cc b/paddle/cuda/src/hl_cuda_cudnn.cc index f55fa523e14432af8e59021c7c6e067bb1f4e4a3..f38ef692558b908ed65d2c84821bbb7c3b439742 100644 --- a/paddle/cuda/src/hl_cuda_cudnn.cc +++ b/paddle/cuda/src/hl_cuda_cudnn.cc @@ -640,7 +640,8 @@ void hl_create_convolution_descriptor(hl_convolution_descriptor* conv, #else if (dilation_h > 1 || dilation_w > 1) { LOG(FATAL) - << "Current cudnn version does't support for dilation convolution."; + << "Current cuDNN version does't support for dilation convolution. " + << "The dilation convolution requires cuDNN >= v6.0."; } CHECK_CUDNN(dynload::cudnnSetConvolution2dDescriptor(hl_conv->desc, diff --git a/paddle/gserver/tests/test_LayerGrad.cpp b/paddle/gserver/tests/test_LayerGrad.cpp index 9348c47bd4f0a54a345b794674f1daf80a9664f3..9946f7666498e27a3149816c67ff4c9a9f3bb02a 100644 --- a/paddle/gserver/tests/test_LayerGrad.cpp +++ b/paddle/gserver/tests/test_LayerGrad.cpp @@ -12,7 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ +#ifndef PADDLE_ONLY_CPU #include +#endif #include #include #include @@ -262,8 +264,8 @@ TEST(Projection, conv) { testProjectionConv(1, false); testProjectionConv(3, false); /// test ConvTransProjection - /// testProjectionConv(1, true); - /// testProjectionConv(3, true); + testProjectionConv(1, true); + testProjectionConv(3, true); } #endif diff --git a/python/paddle/trainer/config_parser.py b/python/paddle/trainer/config_parser.py index 33a20afb183240c027b4b4a6663fd5ff8de6f79f..ddfd615d84b2c888e52ca86ca6e26af51442143d 100644 --- a/python/paddle/trainer/config_parser.py +++ b/python/paddle/trainer/config_parser.py @@ -862,7 +862,6 @@ class Conv(Cfg): filter_size, channels, padding=None, - dilation=None, stride=None, groups=None, filter_channels=None, @@ -871,8 +870,9 @@ class Conv(Cfg): caffe_mode=True, filter_size_y=None, padding_y=None, - dilation_y=None, - stride_y=None): + stride_y=None, + dilation=None, + dilation_y=None): self.add_keys(locals()) if filter_size_y is None: self.filter_size_y = filter_size diff --git a/python/paddle/trainer_config_helpers/layers.py b/python/paddle/trainer_config_helpers/layers.py index 74b88cd4f876f7596916f4c46006fc8b57f98297..987679855816e155ed8d020f78f927ee8f29f22a 100755 --- a/python/paddle/trainer_config_helpers/layers.py +++ b/python/paddle/trainer_config_helpers/layers.py @@ -2340,7 +2340,7 @@ def img_conv_layer(input, groups=1, stride=1, padding=0, - dilation=0, + dilation=1, bias_attr=None, param_attr=None, shared_biases=True, @@ -2472,9 +2472,6 @@ def img_conv_layer(input, else: dilation_y = dilation - if dilation > 1 or dilation_y > 1: - assert layer_type in ["cudnn_conv", "cudnn_convt"] - if param_attr.attr.get('initial_smart'): # special initial for conv layers. init_w = (2.0 / (filter_size**2 * num_channels))**0.5 @@ -2484,6 +2481,8 @@ def img_conv_layer(input, param_attr.attr["initial_smart"] = False if layer_type: + if dilation > 1 or dilation_y > 1: + assert layer_type in ["cudnn_conv", "cudnn_convt"] if trans: assert layer_type in ["exconvt", "cudnn_convt"] else: