From 8e55736a207a22d2ea1737d0cc9be4ca89707c3a Mon Sep 17 00:00:00 2001 From: zchen0211 Date: Thu, 19 Oct 2017 21:46:02 -0700 Subject: [PATCH] deconv2d --- paddle/operators/deconv2d_op.cc | 16 +++++++++------- paddle/operators/deconv2d_op.h | 8 ++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/paddle/operators/deconv2d_op.cc b/paddle/operators/deconv2d_op.cc index 331fbd59825..8481aefdc1a 100644 --- a/paddle/operators/deconv2d_op.cc +++ b/paddle/operators/deconv2d_op.cc @@ -31,12 +31,14 @@ void Deconv2DOp::InferShape(framework::InferShapeContext* ctx) const { std::vector strides = ctx->Attrs().Get>("strides"); std::vector paddings = ctx->Attrs().Get>("paddings"); - for (int i = 0; i < paddings.size(); ++i) { + for (size_t i = 0; i < paddings.size(); ++i) { PADDLE_ENFORCE_EQ(paddings[i], 0, "No Padding allowed in deconv op."); } - PADDLE_ENFORCE_EQ(in_dims.size(), 4, "Deconv2DOp input should be 4-D."); - PADDLE_ENFORCE_EQ(filter_dims.size(), 4, "Deconv2DOp filter should be 4-D."); + PADDLE_ENFORCE_EQ(in_dims.size(), 4, + "Deconv2DOp input should be 4-D tensor."); + PADDLE_ENFORCE_EQ(filter_dims.size(), 4, + "Deconv2DOp filter should be 4-D tensor."); PADDLE_ENFORCE_EQ(in_dims[1], filter_dims[0], "input and kernel input dimension should be equal."); @@ -52,14 +54,14 @@ Deconv2DOpMaker::Deconv2DOpMaker(framework::OpProto* proto, AddInput( "Input", "The input tensor of deconvolution operator. " - "The format of input tensor is NMHW. Where N is batch size, M is the " + "The format of input tensor is NCHW. Where N is batch size, C is the " "number of input channels, H and W is the height and width of image."); AddInput("Filter", "The filter tensor of deconvolution operator." - "The format of the filter tensor is MCHW, where M is the number of " - "input image channels, C is the number of output image channels, " + "The format of the filter tensor is MCHW, where C is the number of " + "output image channels, M is the number of input image channels, " "H and W is height and width of filter. " - "We enforce groups number == 1 and padding == 0 in our " + "We enforce groups number == 1 and padding == 0 in " "deconvolution Scenario."); AddOutput("Output", "The output tensor of deconvolution operator." diff --git a/paddle/operators/deconv2d_op.h b/paddle/operators/deconv2d_op.h index 71254c9524f..973190efab4 100644 --- a/paddle/operators/deconv2d_op.h +++ b/paddle/operators/deconv2d_op.h @@ -55,7 +55,7 @@ class GemmDeconv2DKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& context) const override { const Tensor* input = context.Input("Input"); - // filter will be reshaped, so we do not use constant pointer here + // The filter will be reshaped, so it should not be constant pointer Tensor filter = *context.Input("Filter"); Tensor* output = context.Output("Output"); @@ -132,8 +132,8 @@ class GemmDeconvGrad2DKernel : public framework::OpKernel { const Tensor* output_grad = context.Input(framework::GradVarName("Output")); - // For filter, we do not use const pointer b/c we will do reshape - // but we should avoid modifying its value + // For filter, we do not use const pointer b/c we will do reshape, + // but we should avoid modifying its value. Tensor filter = *context.Input("Filter"); Tensor* input_grad = @@ -142,7 +142,7 @@ class GemmDeconvGrad2DKernel : public framework::OpKernel { context.Output(framework::GradVarName("Filter")); std::vector strides = context.Attr>("strides"); - // Actually, no paddings and groups allowed in deconv + // Actually, no paddings and groups allowed in deconv. std::vector paddings = context.Attr>("paddings"); int N = input->dims()[0]; -- GitLab