提交 07844e3b 编写于 作者: S SunGaofeng

modify in pad_op and pad_constant

上级 fc884379
...@@ -42,7 +42,10 @@ class PadConstantLikeOp : public framework::OperatorWithKernel { ...@@ -42,7 +42,10 @@ class PadConstantLikeOp : public framework::OperatorWithKernel {
if ((!ctx->IsRuntime()) && ((x_dim[i] == -1) || (y_dim[i] == -1))) { if ((!ctx->IsRuntime()) && ((x_dim[i] == -1) || (y_dim[i] == -1))) {
continue; continue;
} else { } else {
PADDLE_ENFORCE_GE(x_dim[i], y_dim[i]); PADDLE_ENFORCE_GE(
x_dim[i], y_dim[i],
"expected X_dim[i] >= Y_dim[i], but received %d < %d for dim %d",
x_dim[i], y_dim[i], i);
} }
} }
...@@ -171,7 +174,10 @@ class PadConstantLikeOpGrad : public framework::OperatorWithKernel { ...@@ -171,7 +174,10 @@ class PadConstantLikeOpGrad : public framework::OperatorWithKernel {
if ((!ctx->IsRuntime()) && ((dout_dim[i] == -1) || (y_dim[i] == -1))) { if ((!ctx->IsRuntime()) && ((dout_dim[i] == -1) || (y_dim[i] == -1))) {
continue; continue;
} else { } else {
PADDLE_ENFORCE_GE(dout_dim[i], y_dim[i]); PADDLE_ENFORCE_GE(dout_dim[i], y_dim[i],
"expected Out_dim[i] >= Y_dim[i], but received %d "
"< %d for dim %d",
dout_dim[i], y_dim[i], i);
} }
} }
} }
......
...@@ -34,6 +34,9 @@ class PadOp : public framework::OperatorWithKernel { ...@@ -34,6 +34,9 @@ class PadOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ(x_dim.size() * 2, int64_t(paddings.size()), PADDLE_ENFORCE_EQ(x_dim.size() * 2, int64_t(paddings.size()),
"Size of paddings should be equal to 2 * dimension size " "Size of paddings should be equal to 2 * dimension size "
"of input tensor."); "of input tensor.");
for (size_t i = 0; i < paddings.size(); ++i) {
PADDLE_ENFORCE_GE(paddings[i], 0, "paddings should >= 0.");
}
std::vector<int64_t> out_dims(x_dim.size()); std::vector<int64_t> out_dims(x_dim.size());
for (int i = 0; i < x_dim.size(); ++i) { for (int i = 0; i < x_dim.size(); ++i) {
if ((!ctx->IsRuntime()) && (x_dim[i] == -1)) { if ((!ctx->IsRuntime()) && (x_dim[i] == -1)) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册