Skip to content

Commit 5c08d23

Browse files
Fix infer_shape in pad2d_op (#16911)
test=develop
1 parent 391649e commit 5c08d23

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

paddle/fluid/operators/pad2d_op.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,10 @@ class Pad2dOp : public framework::OperatorWithKernel {
480480
PADDLE_ENFORCE_EQ(
481481
paddings_dim.size(), 1,
482482
"Size of Input(Paddings)'s dimension should be equal to 1.");
483-
PADDLE_ENFORCE_EQ(paddings_dim[0], 4,
484-
"Shape of Input(Paddings) should be equal to [4].");
483+
if (ctx->IsRuntime()) {
484+
PADDLE_ENFORCE_EQ(paddings_dim[0], 4,
485+
"Shape of Input(Paddings) should be equal to [4].");
486+
}
485487
out_dims[1] = x_dim[1];
486488
out_dims[2] = x_dim[2];
487489
out_dims[3] = x_dim[3];
@@ -501,11 +503,7 @@ class Pad2dOp : public framework::OperatorWithKernel {
501503
}
502504

503505
ctx->SetOutputDim("Out", framework::make_ddim(out_dims));
504-
if (out_dims[0] == x_dim[0]) {
505-
// Only pass LoD when the first dimension is equal between
506-
// output and input.
507-
ctx->ShareLoD("X", /*->*/ "Out");
508-
}
506+
ctx->ShareLoD("X", /*->*/ "Out");
509507
}
510508

511509
protected:

0 commit comments

Comments
 (0)