Skip to content

Commit 6abac88

Browse files
committed
Merge pull request #16258 from phlrain/fix_concat_1
Fix concat
1 parent e61d724 commit 6abac88

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

paddle/fluid/operators/concat_op.cc

+13-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,19 @@ class ConcatOp : public framework::OperatorWithKernel {
5050
if (j == axis) {
5151
out_dims[axis] += ins[i][j];
5252
} else {
53-
PADDLE_ENFORCE_EQ(out_dims[j], ins[i][j],
54-
"Input tensors should have the same "
55-
"elements except the specify axis.");
53+
if (ctx->IsRuntime()) {
54+
// check all shape in run time
55+
PADDLE_ENFORCE_EQ(out_dims[j], ins[i][j],
56+
"Input tensors should have the same "
57+
"elements except the specify axis.");
58+
} else {
59+
// not check -1 with other in compile time
60+
if (out_dims[j] != -1 && ins[i][j] != -1) {
61+
PADDLE_ENFORCE_EQ(out_dims[j], ins[i][j],
62+
"Input tensors should have the same "
63+
"elements except the specify axis.");
64+
}
65+
}
5666
}
5767
}
5868
}

0 commit comments

Comments
 (0)