未验证 提交 203ac4f3 编写于 作者: K Kqnonrime 提交者: GitHub

Fix seven error message (#32397)

* fix two error message

* fix two error message

* fix error

* fix error

* fix error

* fix error

* fix some error message

* fix some error

* fix error

* fix some error

* fix some error

* fix some error

* fix one error

* fix some error

* fix seven error message

* fix error

* fix error

* fix error

* fix error
上级 f8ca5a9d
...@@ -50,10 +50,15 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { ...@@ -50,10 +50,15 @@ class ScatterNdAddOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_LE( PADDLE_ENFORCE_LE(
index_dims[index_dims_size - 1], ref_dims_size, index_dims[index_dims_size - 1], ref_dims_size,
platform::errors::InvalidArgument( 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, PADDLE_ENFORCE_GE(index_dims_size, 2UL,
platform::errors::InvalidArgument( 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]:] // update.shape = index.shape[:-1] + output.shape[index.shape[-1]:]
std::vector<int64_t> r_updates_dims; std::vector<int64_t> r_updates_dims;
...@@ -66,12 +71,21 @@ class ScatterNdAddOp : public framework::OperatorWithKernel { ...@@ -66,12 +71,21 @@ class ScatterNdAddOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
r_updates_dims.size(), updates_dims_size, 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) { for (int64_t i = 0; i < updates_dims_size; ++i) {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
r_updates_dims[i], updates_dims[i], 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->SetOutputDim("Out", ref_dims);
ctx->ShareLoD("X", /*->*/ "Out"); ctx->ShareLoD("X", /*->*/ "Out");
......
...@@ -41,15 +41,24 @@ class ScatterOp : public framework::OperatorWithKernel { ...@@ -41,15 +41,24 @@ class ScatterOp : public framework::OperatorWithKernel {
auto ref_dims = ctx->GetInputDim("X"); auto ref_dims = ctx->GetInputDim("X");
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
ctx->GetInputDim("Ids").size(), 1, 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( PADDLE_ENFORCE_EQ(
ref_dims.size(), updates_dims.size(), ref_dims.size(), updates_dims.size(),
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"Rerence and Updates should have the same shape size.")); "Input(X) and Input(Updates) should have the same shape size, "
PADDLE_ENFORCE_EQ(ctx->GetInputDim("Updates")[0], "but received the size of Input(x)'s shape is %d, the size of "
ctx->GetInputDim("Ids")[0], "Input(Updates)'s shape is %d.",
platform::errors::InvalidArgument( ref_dims.size(), updates_dims.size()));
"Updates and Ids should have same batch-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->SetOutputDim("Out", ref_dims);
ctx->ShareLoD("X", /*->*/ "Out"); ctx->ShareLoD("X", /*->*/ "Out");
} }
......
...@@ -242,7 +242,7 @@ class TestScatterNdOpRaise(unittest.TestCase): ...@@ -242,7 +242,7 @@ class TestScatterNdOpRaise(unittest.TestCase):
output5 = fluid.layers.scatter_nd_add(ref5, index5, updates5) output5 = fluid.layers.scatter_nd_add(ref5, index5, updates5)
except Exception as e: except Exception as e:
t = \ 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 "
if t in str(e): if t in str(e):
raise IndexError raise IndexError
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册