Skip to content

Commit c49e604

Browse files
authored
Merge pull request #16213 from qingqing01/compile_infer_shape
Skip compile infer shape in box_coder_op
2 parents 81b4fad + e5e7628 commit c49e604

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

paddle/fluid/operators/detection/box_coder_op.cc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ class BoxCoderOp : public framework::OperatorWithKernel {
6060
} else if (code_type == BoxCodeType::kDecodeCenterSize) {
6161
PADDLE_ENFORCE_EQ(target_box_dims.size(), 3,
6262
"The rank of Input TargetBox must be 3");
63-
if (axis == 0) {
64-
PADDLE_ENFORCE_EQ(target_box_dims[1], prior_box_dims[0]);
65-
} else if (axis == 1) {
66-
PADDLE_ENFORCE_EQ(target_box_dims[0], prior_box_dims[0]);
67-
} else {
68-
PADDLE_THROW("axis must be 0 or 1.");
63+
PADDLE_ENFORCE(axis == 0 || axis == 1, "axis must be 0 or 1");
64+
if (ctx->IsRuntime()) {
65+
if (axis == 0) {
66+
PADDLE_ENFORCE_EQ(target_box_dims[1], prior_box_dims[0]);
67+
} else if (axis == 1) {
68+
PADDLE_ENFORCE_EQ(target_box_dims[0], prior_box_dims[0]);
69+
}
70+
PADDLE_ENFORCE_EQ(target_box_dims[2], prior_box_dims[1]);
6971
}
70-
PADDLE_ENFORCE_EQ(target_box_dims[2], prior_box_dims[1]);
7172
ctx->ShareDim("TargetBox", /*->*/ "OutputBox");
7273
}
7374

0 commit comments

Comments
 (0)