Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix seven error message #32397

Merged
merged 21 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions paddle/fluid/operators/scatter_nd_add_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ 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"));
"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"));
"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<int64_t> r_updates_dims;
Expand All @@ -66,12 +71,21 @@ 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) "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shape.The 这种建议中间加一个空格

"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 "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

"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");
Expand Down
21 changes: 15 additions & 6 deletions paddle/fluid/operators/scatter_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,24 @@ 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");
}
Expand Down