From fc1b140abaa3b7efc1280d6c20b6e3b23831d465 Mon Sep 17 00:00:00 2001 From: Bai Yifan Date: Tue, 14 Apr 2020 20:09:53 +0800 Subject: [PATCH] Refine error message, test=develop (#23823) * refine error message, test=develop --- paddle/fluid/operators/deformable_conv_op.cc | 62 +++++++++++------- .../fluid/operators/deformable_conv_v1_op.cc | 64 +++++++++++-------- .../detection/polygon_box_transform_op.cc | 2 +- .../teacher_student_sigmoid_loss_op.cc | 40 ++++++------ 4 files changed, 101 insertions(+), 67 deletions(-) diff --git a/paddle/fluid/operators/deformable_conv_op.cc b/paddle/fluid/operators/deformable_conv_op.cc index ed52ba7303a..21d069bc71a 100644 --- a/paddle/fluid/operators/deformable_conv_op.cc +++ b/paddle/fluid/operators/deformable_conv_op.cc @@ -138,40 +138,46 @@ class DeformableConvOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ(in_dims.size(), filter_dims.size(), platform::errors::InvalidArgument( "Conv input dimension and filter dimension should be " - "the same. The diff is [%d] vs [%d]", + "the same. The difference is [%d]: [%d]", in_dims.size(), filter_dims.size())); - PADDLE_ENFORCE_EQ( - in_dims.size() - strides.size(), 2U, - platform::errors::InvalidArgument("Conv input dimension and strides " - "dimension should be consistent.")); + PADDLE_ENFORCE_EQ(in_dims.size() - strides.size(), 2U, + platform::errors::InvalidArgument( + "Conv input dimension and strides " + "dimension should be consistent. But received input " + "dimension:[%d], strides dimension:[%d]", + in_dims.size(), strides.size())); PADDLE_ENFORCE_EQ(paddings.size(), strides.size(), platform::errors::InvalidArgument( "Conv paddings dimension and Conv strides dimension " - "should be the same. The diff is [%d] vs [%d]", + "should be the same. The difference is [%d]: [%d]", paddings.size(), strides.size())); PADDLE_ENFORCE_EQ( in_dims[1], filter_dims[1] * groups, platform::errors::InvalidArgument( "The number of input channels should be equal to filter " - "channels * groups. The diff is [%d] vs [%d]", + "channels * groups. The difference is [%d]: [%d]", in_dims[1], filter_dims[1] * groups)); PADDLE_ENFORCE_EQ( filter_dims[0] % groups, 0, platform::errors::InvalidArgument( - "The number of output channels should be divided by groups.")); + "The number of output channels should be divided by groups. But " + "received output channels:[%d], groups:[%d]", + filter_dims[0], groups)); PADDLE_ENFORCE_EQ( filter_dims[0] % deformable_groups, 0, platform::errors::InvalidArgument( "The number of output channels should be " - "divided by deformable groups. The diff is [%d] vs [%d]", + "divided by deformable groups. The difference is [%d]: [%d]", filter_dims[0] % groups, 0)); if (in_dims[0] > im2col_step) { PADDLE_ENFORCE_EQ( in_dims[0] % im2col_step, 0U, platform::errors::InvalidArgument( - "Input batchsize must be smaller than or divide im2col_step")); + "Input batchsize must be smaller than or divide im2col_step. But " + "received Input batchsize:[%d], im2col_step:[%d]", + in_dims[0], im2col_step)); } for (size_t i = 0; i < strides.size(); ++i) { @@ -198,46 +204,58 @@ class DeformableConvOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( output_shape[1] % deformable_groups, 0U, platform::errors::InvalidArgument( - "output num_filter must divide deformable group size.")); + "output num_filter must divide deformable group size. But received " + "output num_filter:[%d], deformable group size:[%d]", + output_shape[1], deformable_groups)); if (ctx->IsRuntime()) { PADDLE_ENFORCE_EQ(output_shape[2], offset_dims[2], platform::errors::InvalidArgument( "output height must equal to offset map height. " - "The diff is [%d] vs [%d]", + "The difference is [%d]: [%d]", output_shape[2], offset_dims[2])); PADDLE_ENFORCE_EQ(output_shape[3], offset_dims[3], platform::errors::InvalidArgument( "output width must equal to offset map width. The " - "diff is [%d] vs [%d]", + "difference is [%d]: [%d]", output_shape[3], offset_dims[3])); - PADDLE_ENFORCE_EQ( - offset_dims[1] % (filter_dims[2] * filter_dims[3]), 0U, - platform::errors::InvalidArgument( - "offset filter must divide deformable group size.")); + + PADDLE_ENFORCE_EQ(offset_dims[1] % (filter_dims[2] * filter_dims[3]), 0U, + platform::errors::InvalidArgument( + "offset filter must divide deformable group size. " + "But received [%d]: [%d]", + offset_dims[1], filter_dims[2] * filter_dims[3])); PADDLE_ENFORCE_EQ( offset_dims[1] / (2 * filter_dims[2] * filter_dims[3]), deformable_groups, platform::errors::InvalidArgument( - "offset filter must divide deformable group size.")); + "offset filter must divide deformable group size. But received " + "[%d]: [%d]", + offset_dims[1] / (2 * filter_dims[2] * filter_dims[3]), + deformable_groups)); PADDLE_ENFORCE_EQ(output_shape[2], mask_dims[2], platform::errors::InvalidArgument( "output height must equal to mask map height. The " - "diff is [%d] vs [%d]", + "difference is [%d] vs [%d]", output_shape[2], mask_dims[2])); PADDLE_ENFORCE_EQ(output_shape[3], mask_dims[3], platform::errors::InvalidArgument( "output width must equal to mask map width. The " - "diff is [%d] vs [%d]", + "difference is [%d] vs [%d]", output_shape[3], mask_dims[3])); PADDLE_ENFORCE_EQ(mask_dims[1] % (filter_dims[2] * filter_dims[3]), 0U, platform::errors::InvalidArgument( - "mask filter must divide deformable group size.")); + "mask filter must divide deformable group size. " + "But received [%d]: [%d]", + mask_dims[1], filter_dims[2] * filter_dims[3])); PADDLE_ENFORCE_EQ(mask_dims[1] / (filter_dims[2] * filter_dims[3]), deformable_groups, platform::errors::InvalidArgument( - "mask filter must divide deformable group size.")); + "mask filter must divide deformable group size. " + "But received [%d]: [%d]", + mask_dims[1] / (filter_dims[2] * filter_dims[3]), + deformable_groups)); } ctx->SetOutputDim("Output", framework::make_ddim(output_shape)); diff --git a/paddle/fluid/operators/deformable_conv_v1_op.cc b/paddle/fluid/operators/deformable_conv_v1_op.cc index 38b7cbb211d..dfba2070aac 100644 --- a/paddle/fluid/operators/deformable_conv_v1_op.cc +++ b/paddle/fluid/operators/deformable_conv_v1_op.cc @@ -142,36 +142,45 @@ class DeformableConvV1Op : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ(in_dims.size(), filter_dims.size(), platform::errors::InvalidArgument( "Conv input dimension and filter dimension should be " - "the same. the diff is [%d] vs [%d]", + "the same. the difference is [%d] vs [%d]", in_dims.size(), filter_dims.size())); PADDLE_ENFORCE_EQ( in_dims.size() - strides.size(), 2U, - platform::errors::InvalidArgument("Conv input dimension and strides " - "dimension should be consistent.")); + platform::errors::InvalidArgument( + "Conv input dimension and strides " + "dimension should be consistent., But received [%d]: [%d]", + in_dims.size(), strides.size())); PADDLE_ENFORCE_EQ(paddings.size(), strides.size(), platform::errors::InvalidArgument( "Conv paddings dimension and Conv strides dimension " - "should be the same. The diff is [%d] vs [%d]", + "should be the same. The difference is [%d] vs [%d]", paddings.size(), strides.size())); PADDLE_ENFORCE_EQ( in_dims[1], filter_dims[1] * groups, platform::errors::InvalidArgument( "The number of input channels should be equal to filter " - "channels * groups.")); + "channels * groups. The difference is [%d]: [%d]", + in_dims[1], filter_dims[1] * groups)); PADDLE_ENFORCE_EQ( filter_dims[0] % groups, 0, - "The number of output channels should be divided by groups."); - PADDLE_ENFORCE_EQ(filter_dims[0] % deformable_groups, 0, - platform::errors::InvalidArgument( - "The number of output channels should be " - "divided by deformable groups.")); + platform::errors::InvalidArgument( + "The number of output channels should be divided by groups. But" + "received output channels: [%d], groups: [%d]", + filter_dims[0], groups)); + PADDLE_ENFORCE_EQ( + filter_dims[0] % deformable_groups, 0, + platform::errors::InvalidArgument( + "The number of output channels should be " + "divided by deformable groups. But received [%d]: [%d]", + filter_dims[0], deformable_groups)); if (in_dims[0] > im2col_step) { - PADDLE_ENFORCE_EQ( - in_dims[0] % im2col_step, 0U, - platform::errors::InvalidArgument( - "Input batchsize must be smaller than or divide im2col_step")); + PADDLE_ENFORCE_EQ(in_dims[0] % im2col_step, 0U, + platform::errors::InvalidArgument( + "Input batchsize must be smaller than or divide " + "im2col_step, But received [%d]: [%d]", + in_dims[0], im2col_step)); } for (size_t i = 0; i < strides.size(); ++i) { @@ -195,29 +204,34 @@ class DeformableConvV1Op : public framework::OperatorWithKernel { } } if (ctx->IsRuntime()) { - PADDLE_ENFORCE_EQ( - output_shape[1] % deformable_groups, 0U, - platform::errors::InvalidArgument( - "output num_filter must divide deformable group size.")); + PADDLE_ENFORCE_EQ(output_shape[1] % deformable_groups, 0U, + platform::errors::InvalidArgument( + "output num_filter must divide deformable group " + "size. But received [%d]: [%d]", + output_shape[1], deformable_groups)); PADDLE_ENFORCE_EQ(output_shape[2], offset_dims[2], platform::errors::InvalidArgument( "output height must equal to offset map height. " - "The diff is [%d] vs [%d]", + "The difference is [%d]: [%d]", output_shape[2], offset_dims[2])); PADDLE_ENFORCE_EQ(output_shape[3], offset_dims[3], platform::errors::InvalidArgument( "output width must equal to offset map width. The " - "diff is [%d] vs [%d]", + "difference is [%d]: [%d]", output_shape[3], offset_dims[3])); - PADDLE_ENFORCE_EQ( - offset_dims[1] % (filter_dims[2] * filter_dims[3]), 0U, - platform::errors::InvalidArgument( - "offset filter must divide deformable group size.")); + PADDLE_ENFORCE_EQ(offset_dims[1] % (filter_dims[2] * filter_dims[3]), 0U, + platform::errors::InvalidArgument( + "offset filter must divide deformable group size. " + "But received [%d]: [%d]", + offset_dims[1], filter_dims[2] * filter_dims[3])); PADDLE_ENFORCE_EQ( offset_dims[1] / (2 * filter_dims[2] * filter_dims[3]), deformable_groups, platform::errors::InvalidArgument( - "offset filter must divide deformable group size.")); + "offset filter must divide deformable group size. But received " + "[%d]: [%d]", + offset_dims[1] / (2 * filter_dims[2] * filter_dims[3]), + deformable_groups)); } ctx->SetOutputDim("Output", framework::make_ddim(output_shape)); } diff --git a/paddle/fluid/operators/detection/polygon_box_transform_op.cc b/paddle/fluid/operators/detection/polygon_box_transform_op.cc index 1fcd6cec9b8..3e4963003cf 100644 --- a/paddle/fluid/operators/detection/polygon_box_transform_op.cc +++ b/paddle/fluid/operators/detection/polygon_box_transform_op.cc @@ -72,7 +72,7 @@ class PolygonBoxTransformOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ(in_dim[1] % 2, 0, platform::errors::InvalidArgument( "input's second dimension must be even. But " - "received: Input 2nd dim is [%d]", + "received: Input 2nd dimension is [%d]", in_dim[1])); ctx->SetOutputDim("Output", in_dim); diff --git a/paddle/fluid/operators/teacher_student_sigmoid_loss_op.cc b/paddle/fluid/operators/teacher_student_sigmoid_loss_op.cc index f8d7dfdfbed..0e0a594846f 100644 --- a/paddle/fluid/operators/teacher_student_sigmoid_loss_op.cc +++ b/paddle/fluid/operators/teacher_student_sigmoid_loss_op.cc @@ -37,22 +37,22 @@ class TeacherStudentSigmoidLossOp : public framework::OperatorWithKernel { auto x_dims = ctx->GetInputDim("X"); auto label_dims = ctx->GetInputDim("Label"); - PADDLE_ENFORCE_EQ( - x_dims.size(), 2UL, - platform::errors::NotFound("Input(X)'s rank should be 2. But received: " - "Input(X)'s rank is [%d]", - x_dims.size())); - PADDLE_ENFORCE_EQ( - label_dims.size(), 2UL, - platform::errors::NotFound("Input(Label)'s rank should be 2. But " - "received Input(Label)'s rank is [%d]", - label_dims.size())); + PADDLE_ENFORCE_EQ(x_dims.size(), 2UL, + platform::errors::InvalidArgument( + "Input(X)'s rank should be 2. But received: " + "Input(X)'s rank is [%d]", + x_dims.size())); + PADDLE_ENFORCE_EQ(label_dims.size(), 2UL, + platform::errors::InvalidArgument( + "Input(Label)'s rank should be 2. But " + "received Input(Label)'s rank is [%d]", + label_dims.size())); if (ctx->IsRuntime()) { PADDLE_ENFORCE_EQ( x_dims[0], label_dims[0], platform::errors::InvalidArgument( "The 1st dimension of Input(X) and Input(Label) should " - "be equal. The diff is [%d] vs [%d]", + "be equal. The difference is [%d]: [%d]", x_dims[0], label_dims[0])); PADDLE_ENFORCE_EQ(label_dims[1], 1UL, platform::errors::InvalidArgument( @@ -135,24 +135,26 @@ class TeacherStudentSigmoidLossGradientOp x_dims[0], label_dims[0], platform::errors::InvalidArgument( "The 1st dimension of Input(X) and Input(Label) should " - "be equal. The diff is [%d] vs [%d]", + "be equal. The difference is [%d]: [%d]", x_dims[0], label_dims[0])); PADDLE_ENFORCE_EQ( x_dims[0], dy_dims[0], platform::errors::InvalidArgument( "The 1st dimension of Input(X) and Input(Y@Grad) should " - "be equal. The diff is [%d] vs [%d]", + "be equal. The difference is [%d]: [%d]", x_dims[0], dy_dims[0])); - PADDLE_ENFORCE_EQ(dy_dims[1], 1, - platform::errors::InvalidArgument( - "The 2nd dimension of Input(Y@Grad) should be 1. " - "But received Input(Y@Grad)'s 2nd dim is [%d]", - dy_dims[1])); + PADDLE_ENFORCE_EQ( + dy_dims[1], 1, + platform::errors::InvalidArgument( + "The 2nd dimension of Input(Y@Grad) should be 1. " + "But received Input(Y@Grad)'s 2nd dimension is [%d]", + dy_dims[1])); PADDLE_ENFORCE_EQ( label_dims[1], 1, platform::errors::InvalidArgument( "When Attr(soft_label) == false, the 2nd dimension of " - "Input(Label) should be 1. But received Input(Label)'s 2nd dim " + "Input(Label) should be 1. But received Input(Label)'s 2nd " + "dimemsion " "is [%d]", label_dims[1])); } -- GitLab