From 57ff027b493a4571afa5bb72a18f598eb66b77f4 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 2 Apr 2021 11:06:57 +0800 Subject: [PATCH 01/19] fix two error message --- paddle/fluid/operators/scatter.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/scatter.h b/paddle/fluid/operators/scatter.h index cfa88b9808d64..80db9f1d1568c 100644 --- a/paddle/fluid/operators/scatter.h +++ b/paddle/fluid/operators/scatter.h @@ -104,7 +104,10 @@ void ScatterAssign(const platform::DeviceContext& ctx, const Tensor& src, for (int i = 1; i < src_dims.size(); i++) PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], platform::errors::InvalidArgument( - "src shape and dst shape should match")); + "src's shape and dst's shape should match." + "But received src_dims[%d]'s value = %d," + "dst_dims[%d]'s value = %d.", + i, src_dims[i], i, dst_dims[i])); // slice size size_t slice_size = 1; @@ -148,7 +151,10 @@ void ScatterAssignAdd(const framework::ExecutionContext& ctx, const Tensor& src, for (int i = 1; i < src_dims.size(); i++) PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], platform::errors::InvalidArgument( - "src shape and dst shape should match")); + "src's shape and dst's shape should match." + "But received src_dims[%d]'s value = %d," + "dst_dims[%d]'s value = %d.", + i, src_dims[i], i, dst_dims[i])); // slice size size_t slice_size = 1; From 310742370200fb5cb4366c1f5542110c5c70895a Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 2 Apr 2021 14:08:24 +0800 Subject: [PATCH 02/19] fix two error message --- paddle/fluid/operators/scatter.h | 10 +++++----- paddle/fluid/operators/unstack_op.cc | 9 +++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/operators/scatter.h b/paddle/fluid/operators/scatter.h index 80db9f1d1568c..c4a7816ecf2b5 100644 --- a/paddle/fluid/operators/scatter.h +++ b/paddle/fluid/operators/scatter.h @@ -105,8 +105,8 @@ void ScatterAssign(const platform::DeviceContext& ctx, const Tensor& src, PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], platform::errors::InvalidArgument( "src's shape and dst's shape should match." - "But received src_dims[%d]'s value = %d," - "dst_dims[%d]'s value = %d.", + "but received src %d dim is:%d not equal to" + " dst %d dim:%d.", i, src_dims[i], i, dst_dims[i])); // slice size @@ -151,9 +151,9 @@ void ScatterAssignAdd(const framework::ExecutionContext& ctx, const Tensor& src, for (int i = 1; i < src_dims.size(); i++) PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], platform::errors::InvalidArgument( - "src's shape and dst's shape should match." - "But received src_dims[%d]'s value = %d," - "dst_dims[%d]'s value = %d.", + "src's shape and dst's shape should match," + "but received src %d dim is:%d not equal to" + " dst %d dim:%d.", i, src_dims[i], i, dst_dims[i])); // slice size diff --git a/paddle/fluid/operators/unstack_op.cc b/paddle/fluid/operators/unstack_op.cc index 2f71f10a1c417..eed9fa372b470 100644 --- a/paddle/fluid/operators/unstack_op.cc +++ b/paddle/fluid/operators/unstack_op.cc @@ -101,14 +101,19 @@ class UnStackGradOp : public framework::OperatorWithKernel { void InferShape(framework::InferShapeContext *ctx) const override { PADDLE_ENFORCE_GT(ctx->Inputs(framework::GradVarName("Y")).size(), 0, platform::errors::InvalidArgument( - "Number of Inputs(Y@Grad) must be larger than 0")); + "Number of Inputs(Y@Grad) must be larger than 0." + "But received Inputs(Y@Grad)' size = %d .", + ctx->Inputs(framework::GradVarName("Y")).size())); OP_INOUT_CHECK(ctx->HasOutput(framework::GradVarName("X")), "Output", "X", "UnStackGrad"); auto input_dims = ctx->GetInputsDim(framework::GradVarName("Y")); for (size_t i = 1; i < input_dims.size(); ++i) { PADDLE_ENFORCE_EQ(input_dims[i], input_dims[0], platform::errors::InvalidArgument( - "Dims of all Inputs(Y@Grad) must be the same")); + "Dims of all Inputs(Y@Grad) must be the same," + "but received Inputs(Y@Grad) %d dim is:%d not " + "equal to Inputs(Y@Grad) 0 dim:%d.", + i, input_dims[i], input_dims[0])); } int axis = ctx->Attrs().Get("axis"); From 8cdb18ee7362e7647ac96dedd8a73fc27e7a9f5d Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 2 Apr 2021 17:34:32 +0800 Subject: [PATCH 03/19] fix error --- paddle/fluid/operators/scatter.h | 12 ++++++------ paddle/fluid/operators/unstack_op.cc | 12 +++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/paddle/fluid/operators/scatter.h b/paddle/fluid/operators/scatter.h index c4a7816ecf2b5..2d86e64a9c6e5 100644 --- a/paddle/fluid/operators/scatter.h +++ b/paddle/fluid/operators/scatter.h @@ -104,9 +104,9 @@ void ScatterAssign(const platform::DeviceContext& ctx, const Tensor& src, for (int i = 1; i < src_dims.size(); i++) PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], platform::errors::InvalidArgument( - "src's shape and dst's shape should match." - "but received src %d dim is:%d not equal to" - " dst %d dim:%d.", + "The dimensions of the source tensor and target tensor should" + " match, but received source tensor's %d-th dimension is %d," + "target tensor's %d-th dimension is %d.", i, src_dims[i], i, dst_dims[i])); // slice size @@ -151,9 +151,9 @@ void ScatterAssignAdd(const framework::ExecutionContext& ctx, const Tensor& src, for (int i = 1; i < src_dims.size(); i++) PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], platform::errors::InvalidArgument( - "src's shape and dst's shape should match," - "but received src %d dim is:%d not equal to" - " dst %d dim:%d.", + "The dimensions of the source tensor and target tensor should" + " match, but received source tensor's %d-th dimension is %d," + "target tensor's %d-th dimension is %d.", i, src_dims[i], i, dst_dims[i])); // slice size diff --git a/paddle/fluid/operators/unstack_op.cc b/paddle/fluid/operators/unstack_op.cc index eed9fa372b470..59f53bb1f7881 100644 --- a/paddle/fluid/operators/unstack_op.cc +++ b/paddle/fluid/operators/unstack_op.cc @@ -101,19 +101,17 @@ class UnStackGradOp : public framework::OperatorWithKernel { void InferShape(framework::InferShapeContext *ctx) const override { PADDLE_ENFORCE_GT(ctx->Inputs(framework::GradVarName("Y")).size(), 0, platform::errors::InvalidArgument( - "Number of Inputs(Y@Grad) must be larger than 0." - "But received Inputs(Y@Grad)' size = %d .", - ctx->Inputs(framework::GradVarName("Y")).size())); + "The Inputs(Y@Grad) of unstack operator are empty.")); OP_INOUT_CHECK(ctx->HasOutput(framework::GradVarName("X")), "Output", "X", "UnStackGrad"); auto input_dims = ctx->GetInputsDim(framework::GradVarName("Y")); for (size_t i = 1; i < input_dims.size(); ++i) { PADDLE_ENFORCE_EQ(input_dims[i], input_dims[0], platform::errors::InvalidArgument( - "Dims of all Inputs(Y@Grad) must be the same," - "but received Inputs(Y@Grad) %d dim is:%d not " - "equal to Inputs(Y@Grad) 0 dim:%d.", - i, input_dims[i], input_dims[0])); + "The dimensions of all Inputs(Y@Grad) must be the same," + "but received Inputs(Y@Grad)'s %d-th dimension is %d, " + "Inputs(Y@Grad)'s 0-th to %d-th dimension is %d.", + i, input_dims[i], i-1, input_dims[0])); } int axis = ctx->Attrs().Get("axis"); From 6945965ee15193ff23a181922787bf6dc6a95497 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 2 Apr 2021 19:43:06 +0800 Subject: [PATCH 04/19] fix error --- paddle/fluid/operators/scatter.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/paddle/fluid/operators/scatter.h b/paddle/fluid/operators/scatter.h index 2d86e64a9c6e5..864a94a4235e6 100644 --- a/paddle/fluid/operators/scatter.h +++ b/paddle/fluid/operators/scatter.h @@ -102,12 +102,13 @@ void ScatterAssign(const platform::DeviceContext& ctx, const Tensor& src, // check src shape and dst shape should match for (int i = 1; i < src_dims.size(); i++) - PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], - platform::errors::InvalidArgument( - "The dimensions of the source tensor and target tensor should" - " match, but received source tensor's %d-th dimension is %d," - "target tensor's %d-th dimension is %d.", - i, src_dims[i], i, dst_dims[i])); + PADDLE_ENFORCE_EQ( + src_dims[i], dst_dims[i], + platform::errors::InvalidArgument( + "The dimensions of the source tensor and target tensor should" + " match, but received source tensor's %d-th dimension is %d," + "target tensor's %d-th dimension is %d.", + i, src_dims[i], i, dst_dims[i])); // slice size size_t slice_size = 1; @@ -149,12 +150,13 @@ void ScatterAssignAdd(const framework::ExecutionContext& ctx, const Tensor& src, // check src shape and dst shape should match for (int i = 1; i < src_dims.size(); i++) - PADDLE_ENFORCE_EQ(src_dims[i], dst_dims[i], - platform::errors::InvalidArgument( - "The dimensions of the source tensor and target tensor should" - " match, but received source tensor's %d-th dimension is %d," - "target tensor's %d-th dimension is %d.", - i, src_dims[i], i, dst_dims[i])); + PADDLE_ENFORCE_EQ( + src_dims[i], dst_dims[i], + platform::errors::InvalidArgument( + "The dimensions of the source tensor and target tensor should" + " match, but received source tensor's %d-th dimension is %d," + "target tensor's %d-th dimension is %d.", + i, src_dims[i], i, dst_dims[i])); // slice size size_t slice_size = 1; From a7c07d100e6c388ce396369d29dceb7bce252d98 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 2 Apr 2021 20:17:16 +0800 Subject: [PATCH 05/19] fix error --- paddle/fluid/operators/unstack_op.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/operators/unstack_op.cc b/paddle/fluid/operators/unstack_op.cc index 59f53bb1f7881..5cccc4aa07dd5 100644 --- a/paddle/fluid/operators/unstack_op.cc +++ b/paddle/fluid/operators/unstack_op.cc @@ -106,12 +106,13 @@ class UnStackGradOp : public framework::OperatorWithKernel { "UnStackGrad"); auto input_dims = ctx->GetInputsDim(framework::GradVarName("Y")); for (size_t i = 1; i < input_dims.size(); ++i) { - PADDLE_ENFORCE_EQ(input_dims[i], input_dims[0], - platform::errors::InvalidArgument( - "The dimensions of all Inputs(Y@Grad) must be the same," - "but received Inputs(Y@Grad)'s %d-th dimension is %d, " - "Inputs(Y@Grad)'s 0-th to %d-th dimension is %d.", - i, input_dims[i], i-1, input_dims[0])); + PADDLE_ENFORCE_EQ( + input_dims[i], input_dims[0], + platform::errors::InvalidArgument( + "The dimensions of all Inputs(Y@Grad) must be the same," + "but received Inputs(Y@Grad)'s %d-th dimension is %d, " + "Inputs(Y@Grad)'s 0-th to %d-th dimension is %d.", + i, input_dims[i], i-1, input_dims[0])); } int axis = ctx->Attrs().Get("axis"); From 6526d129ccc183055b2981fa7327d37d19aa8ed2 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 2 Apr 2021 21:06:13 +0800 Subject: [PATCH 06/19] fix error --- paddle/fluid/operators/unstack_op.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/operators/unstack_op.cc b/paddle/fluid/operators/unstack_op.cc index 5cccc4aa07dd5..71cc586cb598f 100644 --- a/paddle/fluid/operators/unstack_op.cc +++ b/paddle/fluid/operators/unstack_op.cc @@ -112,7 +112,7 @@ class UnStackGradOp : public framework::OperatorWithKernel { "The dimensions of all Inputs(Y@Grad) must be the same," "but received Inputs(Y@Grad)'s %d-th dimension is %d, " "Inputs(Y@Grad)'s 0-th to %d-th dimension is %d.", - i, input_dims[i], i-1, input_dims[0])); + i, input_dims[i], i - 1, input_dims[0])); } int axis = ctx->Attrs().Get("axis"); From f7f568271d0682971b7e7cf74291f8d4f9d467b5 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 9 Apr 2021 13:32:51 +0800 Subject: [PATCH 07/19] fix some error message --- paddle/fluid/operators/interpolate_op.h | 5 ++- paddle/fluid/operators/interpolate_v2_op.h | 49 +++++++++++----------- paddle/fluid/operators/py_func_op.cc | 2 +- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index 5fbde701fcef6..371cefa6286c0 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -34,7 +34,10 @@ inline std::vector get_new_shape( auto tensor = list_new_shape_tensor[i]; PADDLE_ENFORCE_EQ( tensor->dims(), framework::make_ddim({1}), - platform::errors::InvalidArgument("shape of dim tensor should be [1]")); + platform::errors::InvalidArgument( + "The shape of dimension tensor should be [1]," + "but received d%.", + tensor->dims())); if (platform::is_gpu_place(tensor->place())) { framework::Tensor temp; TensorCopySync(*tensor, platform::CPUPlace(), &temp); diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index 4e4fd9ff63ba4..75cf6c9c490ba 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -34,7 +34,10 @@ inline std::vector get_new_shape( auto tensor = list_new_shape_tensor[i]; PADDLE_ENFORCE_EQ( tensor->dims(), framework::make_ddim({1}), - platform::errors::InvalidArgument("shape of dim tensor should be [1]")); + platform::errors::InvalidArgument( + "The shape of dimension tensor should be [1]," + "but received d%.", + tensor->dims())); if (platform::is_gpu_place(tensor->place())) { framework::Tensor temp; TensorCopySync(*tensor, platform::CPUPlace(), &temp); @@ -796,15 +799,13 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, auto scale_data = get_new_data_from_tensor(scale_tensor); scale_w = scale_data[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "scale of Op(interpolate) " - "should be greater than 0.")); + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 0) { scale_w = scale[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "scale of Op(interpolate) " - "should be greater than 0.")); + "The scale of interpolate operator are empty.")); } } if (scale_w > 0.) { @@ -883,8 +884,8 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, } PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_h = scale[0]; @@ -892,8 +893,8 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_h > 0. && scale_w > 0.) { @@ -999,8 +1000,8 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, } PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0 && scale_d, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_d = scale[0]; @@ -1009,8 +1010,8 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0 && scale_d, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_w > 0. && scale_h > 0. && scale_d > 0.) { @@ -1103,14 +1104,12 @@ static void Interpolate1DCPUBwd(const framework::ExecutionContext& ctx, auto scale_data = get_new_data_from_tensor(scale_tensor); scale_w = scale_data[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "scale of Op(interpolate) " - "should be greater than 0.")); + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 0) { scale_w = scale[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "scale of Op(interpolate) " - "should be greater than 0.")); + "The scale of interpolate operator are empty.")); } } if (scale_w > 0.) { @@ -1189,16 +1188,16 @@ static void Interpolate2DCPUBwd(const framework::ExecutionContext& ctx, } PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_h > 0. && scale_w > 0.) { @@ -1302,8 +1301,8 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, } PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0 && scale_d > 0, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_d = scale[0]; @@ -1311,8 +1310,8 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, scale_w = scale[2]; PADDLE_ENFORCE_EQ( scale_w > 0 && scale_h > 0 && scale_d > 0, true, - platform::errors::InvalidArgument("scale of Op(interpolate) " - "should be greater than 0.")); + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_d > 0. && scale_h > 0. && scale_w > 0.) { diff --git a/paddle/fluid/operators/py_func_op.cc b/paddle/fluid/operators/py_func_op.cc index b3622870d070e..277716af09159 100644 --- a/paddle/fluid/operators/py_func_op.cc +++ b/paddle/fluid/operators/py_func_op.cc @@ -180,7 +180,7 @@ class PyFuncOpShapeInference : public framework::InferShapeBase { void operator()(framework::InferShapeContext *ctx) const override { PADDLE_ENFORCE_EQ(!ctx->IsRuntime(), true, platform::errors::InvalidArgument( - "Infer shape cannot be called in runtime.")); + "Shape inference cannot be called at run time.")); } }; From d0a5683c730a8e95471b4b021cd4d2caf320fda9 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 9 Apr 2021 14:57:08 +0800 Subject: [PATCH 08/19] fix some error --- paddle/fluid/operators/interpolate_op.h | 11 ++- paddle/fluid/operators/interpolate_v2_op.h | 87 ++++++++++------------ 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index 371cefa6286c0..0c90a3869a2a2 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -32,12 +32,11 @@ inline std::vector get_new_shape( std::vector vec_new_shape; for (size_t i = 0; i < list_new_shape_tensor.size(); ++i) { auto tensor = list_new_shape_tensor[i]; - PADDLE_ENFORCE_EQ( - tensor->dims(), framework::make_ddim({1}), - platform::errors::InvalidArgument( - "The shape of dimension tensor should be [1]," - "but received d%.", - tensor->dims())); + PADDLE_ENFORCE_EQ(tensor->dims(), framework::make_ddim({1}), + platform::errors::InvalidArgument( + "The shape of dimension tensor should be [1]," + "but received d%.", + tensor->dims())); if (platform::is_gpu_place(tensor->place())) { framework::Tensor temp; TensorCopySync(*tensor, platform::CPUPlace(), &temp); diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index 75cf6c9c490ba..d08454d9e8163 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -32,12 +32,11 @@ inline std::vector get_new_shape( std::vector vec_new_shape; for (size_t i = 0; i < list_new_shape_tensor.size(); ++i) { auto tensor = list_new_shape_tensor[i]; - PADDLE_ENFORCE_EQ( - tensor->dims(), framework::make_ddim({1}), - platform::errors::InvalidArgument( - "The shape of dimension tensor should be [1]," - "but received d%.", - tensor->dims())); + PADDLE_ENFORCE_EQ(tensor->dims(), framework::make_ddim({1}), + platform::errors::InvalidArgument( + "The shape of dimension tensor should be [1]," + "but received d%.", + tensor->dims())); if (platform::is_gpu_place(tensor->place())) { framework::Tensor temp; TensorCopySync(*tensor, platform::CPUPlace(), &temp); @@ -798,14 +797,16 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, if (scale_tensor != nullptr) { auto scale_data = get_new_data_from_tensor(scale_tensor); scale_w = scale_data[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 0) { scale_w = scale[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_w > 0.) { @@ -882,19 +883,17 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_h > 0. && scale_w > 0.) { @@ -998,20 +997,18 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0 && scale_d, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_d = scale[0]; scale_h = scale[1]; scale_w = scale[2]; - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0 && scale_d, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_w > 0. && scale_h > 0. && scale_d > 0.) { @@ -1103,13 +1100,15 @@ static void Interpolate1DCPUBwd(const framework::ExecutionContext& ctx, if (scale_tensor != nullptr) { auto scale_data = get_new_data_from_tensor(scale_tensor); scale_w = scale_data[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 0) { scale_w = scale[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_w > 0.) { @@ -1186,18 +1185,16 @@ static void Interpolate2DCPUBwd(const framework::ExecutionContext& ctx, scale_w = scale_data[0]; scale_h = scale_data[0]; } - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_h > 0. && scale_w > 0.) { @@ -1299,19 +1296,17 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0 && scale_d > 0, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } else { if (scale.size() > 1) { scale_d = scale[0]; scale_h = scale[1]; scale_w = scale[2]; - PADDLE_ENFORCE_EQ( - scale_w > 0 && scale_h > 0 && scale_d > 0, true, - platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d > 0, true, + platform::errors::InvalidArgument( + "The scale of interpolate operator are empty.")); } } if (scale_d > 0. && scale_h > 0. && scale_w > 0.) { From fcfa08f783e7e1aa5b73f95c94a26bb9c4822b33 Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 9 Apr 2021 15:59:33 +0800 Subject: [PATCH 09/19] fix error --- paddle/fluid/operators/interpolate_v2_op.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index d08454d9e8163..2a4beb27ba490 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -34,9 +34,9 @@ inline std::vector get_new_shape( auto tensor = list_new_shape_tensor[i]; PADDLE_ENFORCE_EQ(tensor->dims(), framework::make_ddim({1}), platform::errors::InvalidArgument( - "The shape of dimension tensor should be [1]," - "but received d%.", - tensor->dims())); + "The shape of dimension tensor should be [1]," + "but received d%.", + tensor->dims())); if (platform::is_gpu_place(tensor->place())) { framework::Tensor temp; TensorCopySync(*tensor, platform::CPUPlace(), &temp); From 0f16f775ad4cba91f0ed1e5f038129a8a9cdb9af Mon Sep 17 00:00:00 2001 From: Kanon Date: Tue, 13 Apr 2021 15:30:28 +0800 Subject: [PATCH 10/19] fix some error --- paddle/fluid/operators/interpolate_v2_op.h | 124 +++++++++++++++++---- paddle/fluid/operators/py_func_op.cc | 2 +- 2 files changed, 105 insertions(+), 21 deletions(-) diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index 2a4beb27ba490..92c053693fe9c 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -799,14 +799,18 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, scale_w = scale_data[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } else { if (scale.size() > 0) { scale_w = scale[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } } if (scale_w > 0.) { @@ -883,17 +887,31 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } } if (scale_h > 0. && scale_w > 0.) { @@ -997,18 +1015,42 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ(scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } else { if (scale.size() > 1) { scale_d = scale[0]; scale_h = scale[1]; scale_w = scale[2]; - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ(scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } } if (scale_w > 0. && scale_h > 0. && scale_d > 0.) { @@ -1102,13 +1144,17 @@ static void Interpolate1DCPUBwd(const framework::ExecutionContext& ctx, scale_w = scale_data[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } else { if (scale.size() > 0) { scale_w = scale[0]; PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } } if (scale_w > 0.) { @@ -1185,16 +1231,30 @@ static void Interpolate2DCPUBwd(const framework::ExecutionContext& ctx, scale_w = scale_data[0]; scale_h = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } } if (scale_h > 0. && scale_w > 0.) { @@ -1296,17 +1356,41 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d > 0, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ(scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } else { if (scale.size() > 1) { scale_d = scale[0]; scale_h = scale[1]; scale_w = scale[2]; - PADDLE_ENFORCE_EQ(scale_w > 0 && scale_h > 0 && scale_d > 0, true, + PADDLE_ENFORCE_EQ(scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ(scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ(scale_d > 0, true, platform::errors::InvalidArgument( - "The scale of interpolate operator are empty.")); + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } } if (scale_d > 0. && scale_h > 0. && scale_w > 0.) { diff --git a/paddle/fluid/operators/py_func_op.cc b/paddle/fluid/operators/py_func_op.cc index 277716af09159..d3ee98520f993 100644 --- a/paddle/fluid/operators/py_func_op.cc +++ b/paddle/fluid/operators/py_func_op.cc @@ -180,7 +180,7 @@ class PyFuncOpShapeInference : public framework::InferShapeBase { void operator()(framework::InferShapeContext *ctx) const override { PADDLE_ENFORCE_EQ(!ctx->IsRuntime(), true, platform::errors::InvalidArgument( - "Shape inference cannot be called at run time.")); + "Shape inference cannot be called at run time in 'py_func' operator.")); } }; From 6b3337493da1330201f0719b4e718e101ed442c0 Mon Sep 17 00:00:00 2001 From: Kanon Date: Tue, 13 Apr 2021 17:51:15 +0800 Subject: [PATCH 11/19] fix some error --- paddle/fluid/operators/interpolate_v2_op.h | 264 +++++++++++---------- paddle/fluid/operators/py_func_op.cc | 7 +- 2 files changed, 148 insertions(+), 123 deletions(-) diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index 92c053693fe9c..5cc767d21844d 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -797,20 +797,22 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, if (scale_tensor != nullptr) { auto scale_data = get_new_data_from_tensor(scale_tensor); scale_w = scale_data[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } else { if (scale.size() > 0) { scale_w = scale[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } } if (scale_w > 0.) { @@ -887,31 +889,35 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } } if (scale_h > 0. && scale_w > 0.) { @@ -1015,42 +1021,48 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); - PADDLE_ENFORCE_EQ(scale_d > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_d)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ( + scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } else { if (scale.size() > 1) { scale_d = scale[0]; scale_h = scale[1]; scale_w = scale[2]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); - PADDLE_ENFORCE_EQ(scale_d > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_d)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ( + scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } } if (scale_w > 0. && scale_h > 0. && scale_d > 0.) { @@ -1142,19 +1154,21 @@ static void Interpolate1DCPUBwd(const framework::ExecutionContext& ctx, if (scale_tensor != nullptr) { auto scale_data = get_new_data_from_tensor(scale_tensor); scale_w = scale_data[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } else { if (scale.size() > 0) { scale_w = scale[0]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); } } if (scale_w > 0.) { @@ -1231,30 +1245,34 @@ static void Interpolate2DCPUBwd(const framework::ExecutionContext& ctx, scale_w = scale_data[0]; scale_h = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } else { if (scale.size() > 1) { scale_h = scale[0]; scale_w = scale[1]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } } if (scale_h > 0. && scale_w > 0.) { @@ -1356,41 +1374,47 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, scale_h = scale_data[0]; scale_w = scale_data[0]; } - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); - PADDLE_ENFORCE_EQ(scale_d > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_d)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ( + scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } else { if (scale.size() > 1) { scale_d = scale[0]; scale_h = scale[1]; scale_w = scale[2]; - PADDLE_ENFORCE_EQ(scale_w > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); - PADDLE_ENFORCE_EQ(scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); - PADDLE_ENFORCE_EQ(scale_d > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_d)); + PADDLE_ENFORCE_EQ( + scale_w > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); + PADDLE_ENFORCE_EQ( + scale_d > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_d' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_d)); } } if (scale_d > 0. && scale_h > 0. && scale_w > 0.) { diff --git a/paddle/fluid/operators/py_func_op.cc b/paddle/fluid/operators/py_func_op.cc index d3ee98520f993..f676348bc0af2 100644 --- a/paddle/fluid/operators/py_func_op.cc +++ b/paddle/fluid/operators/py_func_op.cc @@ -178,9 +178,10 @@ class PyFuncOpVarTypeInference : public framework::StaticGraphVarTypeInference { class PyFuncOpShapeInference : public framework::InferShapeBase { public: void operator()(framework::InferShapeContext *ctx) const override { - PADDLE_ENFORCE_EQ(!ctx->IsRuntime(), true, - platform::errors::InvalidArgument( - "Shape inference cannot be called at run time in 'py_func' operator.")); + PADDLE_ENFORCE_EQ( + !ctx->IsRuntime(), true, + platform::errors::InvalidArgument("Shape inference cannot be called at " + "run time in 'py_func' operator.")); } }; From bb18a829bd132f7232fce1340abafff928f94cb5 Mon Sep 17 00:00:00 2001 From: Kanon Date: Tue, 13 Apr 2021 18:55:22 +0800 Subject: [PATCH 12/19] fix some error --- paddle/fluid/operators/interpolate_v2_op.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index 5cc767d21844d..b40616c94409a 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -1024,9 +1024,9 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_w)); + "The input 'scale_w' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( @@ -1050,7 +1050,7 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, platform::errors::InvalidArgument( "The input 'scale_w' Tensor's value in Operator(interpolate) " "should be greater than 0, but received value is %d.", - scale_w)); + scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( From 05d4a426124d647a3bf0430fd90573367435b59f Mon Sep 17 00:00:00 2001 From: Kanon Date: Tue, 13 Apr 2021 20:38:29 +0800 Subject: [PATCH 13/19] fix one error --- paddle/fluid/operators/interpolate_v2_op.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index b40616c94409a..3d088791c7788 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -912,12 +912,12 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, "The input 'scale_w' Tensor's value in Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); - PADDLE_ENFORCE_EQ( - scale_h > 0, true, - platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " - "should be greater than 0, but received value is %d.", - scale_h)); + PADDLE_ENFORCE_EQ( + scale_h > 0, true, + platform::errors::InvalidArgument( + "The input 'scale_h' Tensor's value in Operator(interpolate) " + "should be greater than 0, but received value is %d.", + scale_h)); } } if (scale_h > 0. && scale_w > 0.) { From d67d774e5d2b6c95ca0213e92f88057211e9680c Mon Sep 17 00:00:00 2001 From: Kanon Date: Wed, 14 Apr 2021 21:33:35 +0800 Subject: [PATCH 14/19] fix some error --- paddle/fluid/operators/interpolate_v2_op.h | 48 +++++++++++----------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/paddle/fluid/operators/interpolate_v2_op.h b/paddle/fluid/operators/interpolate_v2_op.h index 3d088791c7788..ebab5794edc51 100644 --- a/paddle/fluid/operators/interpolate_v2_op.h +++ b/paddle/fluid/operators/interpolate_v2_op.h @@ -800,7 +800,7 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale' Tensor's value in Operator(interpolate) " + "The scale_w in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); } else { @@ -810,7 +810,7 @@ static void Interpolate1DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale' Tensor's value in Operator(interpolate) " + "The scale_w in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); } @@ -892,13 +892,13 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); } else { @@ -909,13 +909,13 @@ static void Interpolate2DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); } @@ -1024,19 +1024,19 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); PADDLE_ENFORCE_EQ( scale_d > 0, true, platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " + "The scale_d in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_d)); } else { @@ -1048,19 +1048,19 @@ static void Interpolate3DCPUFwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); PADDLE_ENFORCE_EQ( scale_d > 0, true, platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " + "The scale_d in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_d)); } @@ -1157,7 +1157,7 @@ static void Interpolate1DCPUBwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); } else { @@ -1166,7 +1166,7 @@ static void Interpolate1DCPUBwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); } @@ -1248,13 +1248,13 @@ static void Interpolate2DCPUBwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); } else { @@ -1264,13 +1264,13 @@ static void Interpolate2DCPUBwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); } @@ -1377,19 +1377,19 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); PADDLE_ENFORCE_EQ( scale_d > 0, true, platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " + "The scale_d in input 'Scale' Tensor of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_d)); } else { @@ -1400,19 +1400,19 @@ static void Interpolate3DCPUBwd(const framework::ExecutionContext& ctx, PADDLE_ENFORCE_EQ( scale_w > 0, true, platform::errors::InvalidArgument( - "The input 'scale_w' Tensor's value in Operator(interpolate) " + "The scale_w in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_w)); PADDLE_ENFORCE_EQ( scale_h > 0, true, platform::errors::InvalidArgument( - "The input 'scale_h' Tensor's value in Operator(interpolate) " + "The scale_h in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_h)); PADDLE_ENFORCE_EQ( scale_d > 0, true, platform::errors::InvalidArgument( - "The input 'scale_d' Tensor's value in Operator(interpolate) " + "The scale_d in Attr(scale) of Operator(interpolate) " "should be greater than 0, but received value is %d.", scale_d)); } From 4fdd4ef11a74c6fe67ebea397d05b43086fcff18 Mon Sep 17 00:00:00 2001 From: Kanon Date: Tue, 20 Apr 2021 22:03:11 +0800 Subject: [PATCH 15/19] fix seven error message --- paddle/fluid/operators/scatter_nd_add_op.cc | 26 ++++++++++++++++----- paddle/fluid/operators/scatter_op.cc | 22 ++++++++++++----- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/paddle/fluid/operators/scatter_nd_add_op.cc b/paddle/fluid/operators/scatter_nd_add_op.cc index 144e7ceae20c1..5b2f5f3848c8b 100644 --- a/paddle/fluid/operators/scatter_nd_add_op.cc +++ b/paddle/fluid/operators/scatter_nd_add_op.cc @@ -50,10 +50,16 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_LE( index_dims[index_dims_size - 1], ref_dims_size, platform::errors::InvalidArgument( - "Input(Index).shape[-1] should be no greater than Input(X).rank")); - PADDLE_ENFORCE_GE(index_dims_size, 2UL, - platform::errors::InvalidArgument( - "The rank of Input(Index) should be greater than 1")); + "The last dimension of Input(Index)'s shape should be no greater " + "than the rank of Input(X), but received the last dimension of " + "Input(Index)'s shape is %d, the rank of Input(X) is %d.", + index_dims[index_dims_size - 1], ref_dims_size)); + PADDLE_ENFORCE_GE( + index_dims_size, 2UL, + platform::errors::InvalidArgument( + "The rank of Input(Index) should be greater than 1, " + "but received the rank of Input(Index) is %d.", + index_dims_size)); // update.shape = index.shape[:-1] + output.shape[index.shape[-1]:] std::vector r_updates_dims; @@ -66,12 +72,20 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( r_updates_dims.size(), updates_dims_size, - platform::errors::InvalidArgument("Updates has wrong shape")); + platform::errors::InvalidArgument( + "Updates has wrong shape.The shape of Updates and Input(Updates) " + "should be same, but received the shape of Updates is %d, " + "the shape of Input(Updates) is %d.", + r_updates_dims.size(), updates_dims_size)); for (int64_t i = 0; i < updates_dims_size; ++i) { PADDLE_ENFORCE_EQ( r_updates_dims[i], updates_dims[i], - platform::errors::InvalidArgument("Updates has wrong shape")); + platform::errors::InvalidArgument( + "Updates has wrong shape.The dimensions of Updates and Input(Updates) " + "should match, but received Updates's %d-th dimension is %d, " + "Input(Updates)'s %d-th dimension is %d." + i, r_updates_dims[i], i, updates_dims[i])); } ctx->SetOutputDim("Out", ref_dims); ctx->ShareLoD("X", /*->*/ "Out"); diff --git a/paddle/fluid/operators/scatter_op.cc b/paddle/fluid/operators/scatter_op.cc index 3fc40d41c3081..8b6790d0a2409 100644 --- a/paddle/fluid/operators/scatter_op.cc +++ b/paddle/fluid/operators/scatter_op.cc @@ -41,15 +41,25 @@ class ScatterOp : public framework::OperatorWithKernel { auto ref_dims = ctx->GetInputDim("X"); PADDLE_ENFORCE_EQ( ctx->GetInputDim("Ids").size(), 1, - platform::errors::InvalidArgument("Update Ids should be 1-D.")); + platform::errors::InvalidArgument( + "The size of Input(Ids)'s shape should be equal to 1, but " + "received the rank of Input(Ids) is %d.", + ctx->GetInputDim("Ids").size())); PADDLE_ENFORCE_EQ( ref_dims.size(), updates_dims.size(), platform::errors::InvalidArgument( - "Rerence and Updates should have the same shape size.")); - PADDLE_ENFORCE_EQ(ctx->GetInputDim("Updates")[0], - ctx->GetInputDim("Ids")[0], - platform::errors::InvalidArgument( - "Updates and Ids should have same batch-size.")); + "Input(X) and Input(Updates) should have the same shape size, " + "but received the size of Input(x)'s shape is %d, the size of " + "Input(Updates)'s shape is %d.", + ref_dims.size(), updates_dims.size())); + PADDLE_ENFORCE_EQ( + ctx->GetInputDim("Updates")[0], + ctx->GetInputDim("Ids")[0], + platform::errors::InvalidArgument( + "Input(Updates) and Input(Ids) should have same batch-size, but" + " received Input(Updates)'s batch-size is %d, Input(Ids)'s " + "batch-size is %d." + ctx->GetInputDim("Updates")[0], ctx->GetInputDim("Ids")[0])); ctx->SetOutputDim("Out", ref_dims); ctx->ShareLoD("X", /*->*/ "Out"); } From a01297655624c18f5352ec0bf6d790d71c60f77f Mon Sep 17 00:00:00 2001 From: Kanon Date: Wed, 21 Apr 2021 10:45:28 +0800 Subject: [PATCH 16/19] fix error --- paddle/fluid/operators/scatter_nd_add_op.cc | 2 +- paddle/fluid/operators/scatter_op.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/scatter_nd_add_op.cc b/paddle/fluid/operators/scatter_nd_add_op.cc index 5b2f5f3848c8b..41cc8da61db5b 100644 --- a/paddle/fluid/operators/scatter_nd_add_op.cc +++ b/paddle/fluid/operators/scatter_nd_add_op.cc @@ -84,7 +84,7 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { platform::errors::InvalidArgument( "Updates has wrong shape.The dimensions of Updates and Input(Updates) " "should match, but received Updates's %d-th dimension is %d, " - "Input(Updates)'s %d-th dimension is %d." + "Input(Updates)'s %d-th dimension is %d.", i, r_updates_dims[i], i, updates_dims[i])); } ctx->SetOutputDim("Out", ref_dims); diff --git a/paddle/fluid/operators/scatter_op.cc b/paddle/fluid/operators/scatter_op.cc index 8b6790d0a2409..f1e10b0ebd4a4 100644 --- a/paddle/fluid/operators/scatter_op.cc +++ b/paddle/fluid/operators/scatter_op.cc @@ -58,7 +58,7 @@ class ScatterOp : public framework::OperatorWithKernel { platform::errors::InvalidArgument( "Input(Updates) and Input(Ids) should have same batch-size, but" " received Input(Updates)'s batch-size is %d, Input(Ids)'s " - "batch-size is %d." + "batch-size is %d.", ctx->GetInputDim("Updates")[0], ctx->GetInputDim("Ids")[0])); ctx->SetOutputDim("Out", ref_dims); ctx->ShareLoD("X", /*->*/ "Out"); From e4bc0622468e4f3f17b44f24b072cd79ba9cfba6 Mon Sep 17 00:00:00 2001 From: Kanon Date: Wed, 21 Apr 2021 14:22:10 +0800 Subject: [PATCH 17/19] fix error --- paddle/fluid/operators/scatter_nd_add_op.cc | 18 +++++++++--------- paddle/fluid/operators/scatter_op.cc | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/paddle/fluid/operators/scatter_nd_add_op.cc b/paddle/fluid/operators/scatter_nd_add_op.cc index 41cc8da61db5b..b680e151c8981 100644 --- a/paddle/fluid/operators/scatter_nd_add_op.cc +++ b/paddle/fluid/operators/scatter_nd_add_op.cc @@ -54,12 +54,11 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { "than the rank of Input(X), but received the last dimension of " "Input(Index)'s shape is %d, the rank of Input(X) is %d.", index_dims[index_dims_size - 1], ref_dims_size)); - PADDLE_ENFORCE_GE( - index_dims_size, 2UL, - platform::errors::InvalidArgument( - "The rank of Input(Index) should be greater than 1, " - "but received the rank of Input(Index) is %d.", - index_dims_size)); + PADDLE_ENFORCE_GE(index_dims_size, 2UL, + platform::errors::InvalidArgument( + "The rank of Input(Index) should be greater than 1, " + "but received the rank of Input(Index) is %d.", + index_dims_size)); // update.shape = index.shape[:-1] + output.shape[index.shape[-1]:] std::vector r_updates_dims; @@ -82,9 +81,10 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( r_updates_dims[i], updates_dims[i], platform::errors::InvalidArgument( - "Updates has wrong shape.The dimensions of Updates and Input(Updates) " - "should match, but received Updates's %d-th dimension is %d, " - "Input(Updates)'s %d-th dimension is %d.", + "Updates has wrong shape.The dimensions of Updates and " + "Input(Updates) should match, but received Updates's" + "%d-th dimension is %d, Input(Updates)'s %d-th " + "dimension is %d.", i, r_updates_dims[i], i, updates_dims[i])); } ctx->SetOutputDim("Out", ref_dims); diff --git a/paddle/fluid/operators/scatter_op.cc b/paddle/fluid/operators/scatter_op.cc index f1e10b0ebd4a4..f0faa0c579833 100644 --- a/paddle/fluid/operators/scatter_op.cc +++ b/paddle/fluid/operators/scatter_op.cc @@ -53,8 +53,7 @@ class ScatterOp : public framework::OperatorWithKernel { "Input(Updates)'s shape is %d.", ref_dims.size(), updates_dims.size())); PADDLE_ENFORCE_EQ( - ctx->GetInputDim("Updates")[0], - ctx->GetInputDim("Ids")[0], + ctx->GetInputDim("Updates")[0], ctx->GetInputDim("Ids")[0], platform::errors::InvalidArgument( "Input(Updates) and Input(Ids) should have same batch-size, but" " received Input(Updates)'s batch-size is %d, Input(Ids)'s " From 29cb2db224c090a0a437339e4b86b529b9b46819 Mon Sep 17 00:00:00 2001 From: Kanon Date: Thu, 22 Apr 2021 21:22:42 +0800 Subject: [PATCH 18/19] fix error --- paddle/fluid/operators/scatter_nd_add_op.cc | 4 ++-- python/paddle/fluid/tests/unittests/test_scatter_nd_op.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/scatter_nd_add_op.cc b/paddle/fluid/operators/scatter_nd_add_op.cc index b680e151c8981..2d23e81717abb 100644 --- a/paddle/fluid/operators/scatter_nd_add_op.cc +++ b/paddle/fluid/operators/scatter_nd_add_op.cc @@ -72,7 +72,7 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( r_updates_dims.size(), updates_dims_size, platform::errors::InvalidArgument( - "Updates has wrong shape.The shape of Updates and Input(Updates) " + "Updates has wrong shape. The shape of Updates and Input(Updates) " "should be same, but received the shape of Updates is %d, " "the shape of Input(Updates) is %d.", r_updates_dims.size(), updates_dims_size)); @@ -81,7 +81,7 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { PADDLE_ENFORCE_EQ( r_updates_dims[i], updates_dims[i], platform::errors::InvalidArgument( - "Updates has wrong shape.The dimensions of Updates and " + "Updates has wrong shape. The dimensions of Updates and " "Input(Updates) should match, but received Updates's" "%d-th dimension is %d, Input(Updates)'s %d-th " "dimension is %d.", diff --git a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py index 35bb4487c6aae..549a38d9b47ff 100644 --- a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py +++ b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py @@ -242,7 +242,7 @@ def check_raise_is_test(): output5 = fluid.layers.scatter_nd_add(ref5, index5, updates5) except Exception as e: t = \ - "Input(Index).shape[-1] should be no greater than Input(X).rank" + "The last dimension of Input(Index)'s shape should be no greater than the rank of Input(X)" if t in str(e): raise IndexError From 4e690a0d7d03e050872293c71e66e907cf45f6ea Mon Sep 17 00:00:00 2001 From: Kanon Date: Fri, 23 Apr 2021 00:40:04 +0800 Subject: [PATCH 19/19] fix error --- python/paddle/fluid/tests/unittests/test_scatter_nd_op.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py index 549a38d9b47ff..59d1ede5a0b53 100644 --- a/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py +++ b/python/paddle/fluid/tests/unittests/test_scatter_nd_op.py @@ -242,7 +242,7 @@ def check_raise_is_test(): output5 = fluid.layers.scatter_nd_add(ref5, index5, updates5) except Exception as e: t = \ - "The last dimension of Input(Index)'s shape should be no greater than the rank of Input(X)" + "The last dimension of Input(Index)'s shape should be no greater " if t in str(e): raise IndexError