diff --git a/paddle/fluid/operators/detection/iou_similarity_op.cc b/paddle/fluid/operators/detection/iou_similarity_op.cc index 6f8a8b0a08516a4df0b4064e2231094cb0f19051..e290bb3243eede17f654247c24fbb472c31ab3bd 100644 --- a/paddle/fluid/operators/detection/iou_similarity_op.cc +++ b/paddle/fluid/operators/detection/iou_similarity_op.cc @@ -23,17 +23,29 @@ class IOUSimilarityOp : public framework::OperatorWithKernel { protected: void InferShape(framework::InferShapeContext *ctx) const override { - PADDLE_ENFORCE(ctx->HasInput("X"), - "Input(X) of IOUSimilarityOp should not be null."); - PADDLE_ENFORCE(ctx->HasInput("Y"), - "Input(Y) of IOUSimilarityOp should not be null."); + OP_INOUT_CHECK(ctx->HasInput("X"), "Input", "X", "iou_similarity"); + OP_INOUT_CHECK(ctx->HasInput("Y"), "Input", "Y", "iou_similarity"); auto x_dims = ctx->GetInputDim("X"); auto y_dims = ctx->GetInputDim("Y"); - PADDLE_ENFORCE_EQ(x_dims.size(), 2UL, "The rank of Input(X) must be 2."); - PADDLE_ENFORCE_EQ(x_dims[1], 4UL, "The shape of X is [N, 4]"); - PADDLE_ENFORCE_EQ(y_dims.size(), 2UL, "The rank of Input(Y) must be 2."); - PADDLE_ENFORCE_EQ(y_dims[1], 4UL, "The shape of Y is [M, 4]"); + PADDLE_ENFORCE_EQ( + x_dims.size(), 2UL, + platform::errors::InvalidArgument( + "The rank of Input(X) must be 2, but got dimension = %d.", + x_dims.size())); + PADDLE_ENFORCE_EQ( + x_dims[1], 4UL, + platform::errors::InvalidArgument( + "The shape of X is [N, 4], bug got dimension = %d.", x_dims[1])); + PADDLE_ENFORCE_EQ( + y_dims.size(), 2UL, + platform::errors::InvalidArgument( + "The rank of Input(Y) must be 2, but got dimension = %d.", + y_dims.size())); + PADDLE_ENFORCE_EQ( + y_dims[1], 4UL, + platform::errors::InvalidArgument( + "The shape of Y is [M, 4], but got dimension = %d.", y_dims[1])); ctx->ShareLoD("X", /*->*/ "Out"); ctx->SetOutputDim("Out", framework::make_ddim({x_dims[0], y_dims[0]})); diff --git a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc index 5d05d089f5366765db90bf4372942ccf9d576a6b..f57b34cf998aef322dacea2e1e3eb93410211bb0 100644 --- a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc @@ -130,12 +130,18 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { auto* output = ctx.Output("Output"); PADDLE_ENFORCE_EQ(input->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Input tensor"); - PADDLE_ENFORCE_NE(input->format(), MKLDNNMemoryFormat::undef, - "Wrong format set for Input tensor"); + platform::errors::InvalidArgument( + "The input tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, input->layout())); + PADDLE_ENFORCE_NE( + input->format(), MKLDNNMemoryFormat::undef, + platform::errors::InvalidArgument("Wrong format set for Input tensor")); - PADDLE_ENFORCE_EQ(filter->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Filter tensor"); + PADDLE_ENFORCE_EQ( + filter->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The Filter tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, filter->layout())); PADDLE_ENFORCE_NE(filter->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Filter tensor"); @@ -154,8 +160,11 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { "Filter must be with 4 or 5 dimensions, i.e. OIHW or OIDHW"); if (bias) { - PADDLE_ENFORCE_EQ(bias->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Bias tensor"); + PADDLE_ENFORCE_EQ( + bias->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The Bias tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, bias->layout())); PADDLE_ENFORCE_NE(bias->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Bias tensor"); @@ -371,7 +380,9 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { auto* output = ctx.Output("Output"); PADDLE_ENFORCE_EQ(input->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Input tensor"); + platform::errors::InvalidArgument( + "The input tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, input->layout())); PADDLE_ENFORCE_NE(input->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Input tensor"); @@ -438,8 +449,11 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { auto* filter = ctx.Input("Filter"); - PADDLE_ENFORCE_EQ(filter->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Filter tensor"); + PADDLE_ENFORCE_EQ( + filter->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The filter tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, filter->layout())); PADDLE_ENFORCE_NE(filter->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Filter tensor"); @@ -457,8 +471,11 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { auto* bias = ctx.HasInput("Bias") ? ctx.Input("Bias") : nullptr; if (bias) { - PADDLE_ENFORCE_EQ(bias->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Bias tensor"); + PADDLE_ENFORCE_EQ( + bias->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The bias tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, bias->layout())); PADDLE_ENFORCE_NE(bias->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Bias tensor"); @@ -743,17 +760,25 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel { Tensor* filter_grad = ctx.Output(framework::GradVarName("Filter")); PADDLE_ENFORCE_EQ(input->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Input tensor"); + platform::errors::InvalidArgument( + "The input tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, input->layout())); PADDLE_ENFORCE_NE(input->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Input tensor"); - PADDLE_ENFORCE_EQ(filter->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Filter tensor"); + PADDLE_ENFORCE_EQ( + filter->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The filter tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, filter->layout())); PADDLE_ENFORCE_NE(filter->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Filter tensor"); - PADDLE_ENFORCE_EQ(output_grad->layout(), DataLayout::kMKLDNN, - "Wrong layout set for output_grad tensor"); + PADDLE_ENFORCE_EQ( + output_grad->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The output_grad tensor's layout should be %d, but got %d.", + DataLayout::kMKLDNN, output_grad->layout())); PADDLE_ENFORCE_NE(output_grad->format(), MKLDNNMemoryFormat::undef, "Wrong format set for output_grad tensor"); diff --git a/paddle/fluid/operators/mkldnn/conv_transpose_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/conv_transpose_mkldnn_op.cc index d1ef629ee24b2d007a46c33b1c812e57d23907ca..9637bd9828749f555c9a1860854bb52151c72fae 100644 --- a/paddle/fluid/operators/mkldnn/conv_transpose_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/conv_transpose_mkldnn_op.cc @@ -51,8 +51,11 @@ class ConvTransposeMKLDNNOpKernel : public paddle::framework::OpKernel { PADDLE_ENFORCE_NE(input->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Input tensor"); - PADDLE_ENFORCE_EQ(filter->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Filter tensor"); + PADDLE_ENFORCE_EQ( + filter->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The filter tensor's laytout should be %d, but got %d.", + DataLayout::kMKLDNN, filter->layout())); PADDLE_ENFORCE_NE(filter->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Filter tensor"); @@ -62,8 +65,11 @@ class ConvTransposeMKLDNNOpKernel : public paddle::framework::OpKernel { "Filter must be with 4 dimensions, i.e. OIHW"); if (bias) { - PADDLE_ENFORCE_EQ(bias->layout(), DataLayout::kMKLDNN, - "Wrong layout set for Bias tensor"); + PADDLE_ENFORCE_EQ( + bias->layout(), DataLayout::kMKLDNN, + platform::errors::InvalidArgument( + "The bias tensor's laytout should be %d, but got %d.", + DataLayout::kMKLDNN, bias->layout())); PADDLE_ENFORCE_NE(bias->format(), MKLDNNMemoryFormat::undef, "Wrong format set for Bias tensor");