Skip to content

Commit 2644cb8

Browse files
authored
Remove extraneous comma in error messages (#24478)
which messes up the formatting test=develop
1 parent 05c9642 commit 2644cb8

File tree

4 files changed

+73
-71
lines changed

4 files changed

+73
-71
lines changed

paddle/fluid/operators/conv_shift_op.cc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ class ConvShiftOp : public framework::OperatorWithKernel {
3838
PADDLE_ENFORCE_EQ(
3939
x_dims.size(), 2,
4040
platform::errors::InvalidArgument(
41-
"Input(X)'s dimensions of ConvShiftOp should be 2."
41+
"Input(X)'s dimensions of ConvShiftOp should be 2. "
4242
"But received X's shape = [%s] and the dimension is %d.",
4343
x_dims, x_dims.size()));
4444
PADDLE_ENFORCE_EQ(
4545
y_dims.size(), 2,
4646
platform::errors::InvalidArgument(
47-
"Input(Y)'s dimensions of ConvShiftOp should be 2.",
48-
"But received Y's shape = [%s] and the dimension is %d.", y_dims,
49-
y_dims.size()));
47+
"Input(Y)'s dimensions of ConvShiftOp should be 2. "
48+
"But received Y's shape = [%s] and the dimension is %d.",
49+
y_dims, y_dims.size()));
5050
if (ctx->IsRuntime() || (x_dims[0] > 0 && y_dims[0] > 0))
5151
PADDLE_ENFORCE_EQ(
5252
x_dims[0], y_dims[0],
5353
platform::errors::InvalidArgument(
54-
"The first dimension of Input(X) and Input(Y) of ConvShiftOp ",
55-
"should be equal.",
56-
"But received X's shape = [%s], Y's shape = [%s],",
57-
"and the first dimensions are %d and %d respectively.", x_dims,
58-
y_dims, x_dims[0], y_dims[0]));
54+
"The first dimension of Input(X) and Input(Y) of ConvShiftOp "
55+
"should be equal. "
56+
"But received X's shape = [%s], Y's shape = [%s], "
57+
"and the first dimensions are %d and %d respectively.",
58+
x_dims, y_dims, x_dims[0], y_dims[0]));
5959
if (ctx->IsRuntime() || y_dims[1] > 0)
6060
PADDLE_ENFORCE_EQ(
6161
y_dims[1] % 2, 1,
@@ -68,11 +68,10 @@ class ConvShiftOp : public framework::OperatorWithKernel {
6868
y_dims[1], x_dims[1],
6969
platform::errors::InvalidArgument(
7070
"The second dimension of Input(Y) of ConvShiftOp should be less "
71-
"than or "
72-
"equal to the 2nd dimension of Input(X)."
73-
"But received X's shape = [%s], Y's shape = [%s],",
74-
"and the second dimensions are %d and %d respectively.", x_dims,
75-
y_dims, x_dims[1], y_dims[1]));
71+
"than or equal to the 2nd dimension of Input(X)."
72+
"But received X's shape = [%s], Y's shape = [%s], "
73+
"and the second dimensions are %d and %d respectively.",
74+
x_dims, y_dims, x_dims[1], y_dims[1]));
7675
ctx->ShareDim("X", /*->*/ "Out");
7776
ctx->ShareLoD("X", /*->*/ "Out");
7877
}

paddle/fluid/operators/sample_logits_op.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,12 @@ class SampleLogitsOp : public framework::OperatorWithKernel {
135135

136136
PADDLE_ENFORCE_EQ(logits_dims.size(), 2UL,
137137
platform::errors::InvalidArgument(
138-
"Input(Logits) of SampleLogitsOp should be 2D.",
138+
"Input(Logits) of SampleLogitsOp should be 2D. "
139139
"But received shape = [%s] and dimension is %d.",
140140
logits_dims, logits_dims.size()));
141141
PADDLE_ENFORCE_EQ(labels_dims.size(), 2UL,
142142
platform::errors::InvalidArgument(
143-
"Input(Labels) of SampleLogitsOp should be 2D.",
143+
"Input(Labels) of SampleLogitsOp should be 2D. "
144144
"But received shape = [%s] and dimension is %d.",
145145
labels_dims, labels_dims.size()));
146146

@@ -198,15 +198,15 @@ class SampleLogitsOpGrad : public framework::OperatorWithKernel {
198198
PADDLE_ENFORCE_EQ(
199199
logits_dims.size(), 2UL,
200200
platform::errors::InvalidArgument(
201-
"Input(LogitsDim) of SampleLogitsOpGrad should be 2D.",
202-
"But received shape = [%s] and dimension is %d.", logits_dims,
203-
logits_dims.size()));
201+
"Input(LogitsDim) of SampleLogitsOpGrad should be 2D. "
202+
"But received shape = [%s] and dimension is %d.",
203+
logits_dims, logits_dims.size()));
204204
PADDLE_ENFORCE_EQ(
205205
labels_dims.size(), 2UL,
206206
platform::errors::InvalidArgument(
207-
"Input(LabelsDim) of SampleLogitsOpGrad should be 2D.",
208-
"But received shape = [%s] and dimension is %d.", labels_dims,
209-
labels_dims.size()));
207+
"Input(LabelsDim) of SampleLogitsOpGrad should be 2D. "
208+
"But received shape = [%s] and dimension is %d.",
209+
labels_dims, labels_dims.size()));
210210

211211
ctx->SetOutputDim(framework::GradVarName("Logits"), logits_dims);
212212
}

paddle/fluid/operators/sample_logits_op.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,27 @@ static void CPUTakeAlongD1(const platform::DeviceContext& ctx,
5959
const auto idx_dims = index.dims();
6060
PADDLE_ENFORCE_EQ(idx_dims.size(), 2,
6161
platform::errors::InvalidArgument(
62-
"index of CPUTakeAlongD1 should be 2D.",
62+
"index of CPUTakeAlongD1 should be 2D. "
6363
"But received shape = [%s] and dimension is %d.",
6464
idx_dims, idx_dims.size()));
6565
PADDLE_ENFORCE_EQ(array_dims.size(), 2,
6666
platform::errors::InvalidArgument(
67-
"array of CPUTakeAlongD1 should be 2D.",
67+
"array of CPUTakeAlongD1 should be 2D. "
6868
"But received shape = [%s] and dimension is %d.",
6969
array_dims, array_dims.size()));
7070
PADDLE_ENFORCE_EQ(idx_dims[0], array_dims[0],
7171
platform::errors::InvalidArgument(
72-
"The first dimension of index and array of ",
73-
"CPUTakeAlongD1 should be equal.",
74-
"But received index shape = [%s], array shape = [%s],",
75-
"and the first dimensions are %d and %d.", idx_dims,
76-
array_dims, idx_dims[0], array_dims[0]));
72+
"The first dimension of index and array of "
73+
"CPUTakeAlongD1 should be equal. "
74+
"But received index shape = [%s], array shape = [%s], "
75+
"and the first dimensions are %d and %d.",
76+
idx_dims, array_dims, idx_dims[0], array_dims[0]));
7777
PADDLE_ENFORCE_EQ(
7878
idx_dims, value->dims(),
7979
platform::errors::InvalidArgument(
80-
"index and array of CPUTakeAlongD1 should have ", "the same shape.",
81-
"But received index shape = [%s], array shape = [%s].", idx_dims,
82-
value->dims()));
80+
"index and array of CPUTakeAlongD1 should have the same shape. "
81+
"But received index shape = [%s], array shape = [%s].",
82+
idx_dims, value->dims()));
8383

8484
// UNDERSTAND: no allocations here
8585
const T* p_array = array.data<T>();
@@ -119,27 +119,27 @@ static void CPUPutAlongD1(const platform::DeviceContext& ctx,
119119
auto idx_dims = index.dims();
120120
PADDLE_ENFORCE_EQ(idx_dims.size(), 2,
121121
platform::errors::InvalidArgument(
122-
"index of CPUPutAlongD1 should be 2D.",
122+
"index of CPUPutAlongD1 should be 2D. "
123123
"But received shape = [%s] and dimension is %d.",
124124
idx_dims, idx_dims.size()));
125125
PADDLE_ENFORCE_EQ(array_dims.size(), 2,
126126
platform::errors::InvalidArgument(
127-
"array of CPUPutAlongD1 should be 2D.",
127+
"array of CPUPutAlongD1 should be 2D. "
128128
"But received shape = [%s] and dimension is %d.",
129129
array_dims, array_dims.size()));
130130
PADDLE_ENFORCE_EQ(idx_dims[0], array_dims[0],
131131
platform::errors::InvalidArgument(
132-
"The first dimension of index and array of ",
133-
"CPUPutAlongD1 should be equal.",
134-
"But received index shape = [%s], array shape = [%s],",
135-
"and the first dimensions are %d and %d.", idx_dims,
136-
array_dims, idx_dims[0], array_dims[0]));
132+
"The first dimension of index and array of "
133+
"CPUPutAlongD1 should be equal. "
134+
"But received index shape = [%s], array shape = [%s], "
135+
"and the first dimensions are %d and %d.",
136+
idx_dims, array_dims, idx_dims[0], array_dims[0]));
137137
PADDLE_ENFORCE_EQ(
138138
idx_dims, value.dims(),
139139
platform::errors::InvalidArgument(
140-
"index and array of CPUPutAlongD1 should have ", "the same shape.",
141-
"But received index shape = [%s], array shape = [%s].", idx_dims,
142-
value.dims()));
140+
"index and array of CPUPutAlongD1 should have the same shape. "
141+
"But received index shape = [%s], array shape = [%s].",
142+
idx_dims, value.dims()));
143143

144144
// UNDERSTAND: no allocations here
145145
T* p_array = array->data<T>();

paddle/fluid/operators/squared_l2_distance_op.cc

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
3636
auto x_dims = ctx->GetInputDim("X");
3737
auto y_dims = ctx->GetInputDim("Y");
3838

39-
PADDLE_ENFORCE_EQ(
40-
framework::arity(x_dims), framework::arity(y_dims),
41-
platform::errors::InvalidArgument(
42-
"Input(X) and Input(X) of SquaredL2DistanceOp should ",
43-
"have same dimensions.",
44-
"But received X's shape = [%s] and Y's shape = [%s],",
45-
"the dimensions are %d and %d respectively", x_dims, y_dims,
46-
framework::arity(x_dims), framework::arity(y_dims)));
39+
PADDLE_ENFORCE_EQ(framework::arity(x_dims), framework::arity(y_dims),
40+
platform::errors::InvalidArgument(
41+
"Input(X) and Input(X) of SquaredL2DistanceOp should "
42+
"have same dimensions. "
43+
"But received X's shape = [%s] and Y's shape = [%s], "
44+
"the dimensions are %d and %d respectively",
45+
x_dims, y_dims, framework::arity(x_dims),
46+
framework::arity(y_dims)));
4747

4848
int rank = framework::arity(x_dims);
4949
PADDLE_ENFORCE_GE(
5050
rank, 2,
5151
platform::errors::InvalidArgument(
52-
"Input dimensions of SquaredL2DistanceOp should be ", "at least 2.",
53-
"But received shape = [%s] and dimension is %d.", x_dims, rank));
52+
"Input dimensions of SquaredL2DistanceOp should be at least 2."
53+
"But received shape = [%s] and dimension is %d.",
54+
x_dims, rank));
5455
bool check = true;
5556
if ((!ctx->IsRuntime()) &&
5657
(framework::product(x_dims) <= 0 || framework::product(y_dims) <= 0)) {
@@ -60,11 +61,12 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
6061
PADDLE_ENFORCE_EQ(
6162
product(x_dims) / x_dims[0], product(y_dims) / y_dims[0],
6263
platform::errors::InvalidArgument(
63-
"Input(X) and Input(Y) of SquaredL2DistanceOp should ",
64-
"have same dimensions.",
65-
"But received X's shape = [%s] and Y's shape = [%s]",
66-
", the products are %d and %d respectively", x_dims, y_dims,
67-
product(x_dims) / x_dims[0], product(y_dims) / y_dims[0]));
64+
"Input(X) and Input(Y) of SquaredL2DistanceOp should "
65+
"have same dimensions."
66+
"But received X's shape = [%s] and Y's shape = [%s]"
67+
", the products are %d and %d respectively",
68+
x_dims, y_dims, product(x_dims) / x_dims[0],
69+
product(y_dims) / y_dims[0]));
6870
}
6971
check = true;
7072
if ((!ctx->IsRuntime()) && (y_dims[0] <= 0 || x_dims[0] <= 0)) {
@@ -74,11 +76,11 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
7476
PADDLE_ENFORCE_EQ(
7577
y_dims[0] == 1 || y_dims[0] == x_dims[0], true,
7678
platform::errors::InvalidArgument(
77-
"First dimension of Input(Y) of SquaredL2DistanceOp ",
78-
"must be equal to 1", "or to first dimension of Input(X).",
79-
"But received X's shape = [%s] and Y's shape = [%s],",
80-
"the first dimensions are %d and %d respectively", x_dims, y_dims,
81-
x_dims[0], y_dims[0]));
79+
"First dimension of Input(Y) of SquaredL2DistanceOp "
80+
"must be equal to 1 or to first dimension of Input(X)."
81+
"But received X's shape = [%s] and Y's shape = [%s],"
82+
"the first dimensions are %d and %d respectively",
83+
x_dims, y_dims, x_dims[0], y_dims[0]));
8284
}
8385
ctx->SetOutputDim("sub_result", {x_dims[0], product(x_dims) / x_dims[0]});
8486
ctx->SetOutputDim("Out", {x_dims[0], 1});
@@ -152,17 +154,18 @@ class SquaredL2DistanceGradOp : public framework::OperatorWithKernel {
152154
PADDLE_ENFORCE_EQ(
153155
out_dims[0], x_dims[0],
154156
platform::errors::InvalidArgument(
155-
"First dimension of output gradient and Input(X) ",
156-
"of SquaredL2DistanceGradOp must be equal",
157-
"But received X's shape = [%s] and grad's shape = [%s],",
158-
"the first dimensions are %d and %d respectively", x_dims,
159-
out_dims, x_dims[0], out_dims[0]));
157+
"First dimension of output gradient and Input(X) "
158+
"of SquaredL2DistanceGradOp must be equal "
159+
"But received X's shape = [%s] and grad's shape = [%s], "
160+
"the first dimensions are %d and %d respectively",
161+
x_dims, out_dims, x_dims[0], out_dims[0]));
160162
PADDLE_ENFORCE_EQ(out_dims[1], 1,
161163
platform::errors::InvalidArgument(
162-
"Second dimension of output gradient of ",
163-
"SquaredL2DistanceGradOp must be 1."
164-
"But received grad's shape = [%s],",
165-
"with first dimensions %d", out_dims, out_dims[1]));
164+
"Second dimension of output gradient of "
165+
"SquaredL2DistanceGradOp must be 1. "
166+
"But received grad's shape = [%s], "
167+
"with second dimension %d",
168+
out_dims, out_dims[1]));
166169
}
167170
auto x_grad_name = framework::GradVarName("X");
168171
auto y_grad_name = framework::GradVarName("Y");

0 commit comments

Comments
 (0)