Skip to content

Commit ebc6959

Browse files
authored
modify infershape of yolo_box (#40056)
* modify infershape of yolo_box
1 parent 7ef6178 commit ebc6959

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

paddle/fluid/operators/detection/yolo_box_op.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ class YoloBoxOp : public framework::OperatorWithKernel {
102102
"But received class_num (%s)",
103103
class_num));
104104

105-
int box_num = dim_x[2] * dim_x[3] * anchor_num;
105+
int box_num;
106+
if ((dim_x[2] > 0 && dim_x[3] > 0) || ctx->IsRuntime()) {
107+
box_num = dim_x[2] * dim_x[3] * anchor_num;
108+
} else {
109+
box_num = -1;
110+
}
106111
std::vector<int64_t> dim_boxes({dim_x[0], box_num, 4});
107112
ctx->SetOutputDim("Boxes", phi::make_ddim(dim_boxes));
108113

0 commit comments

Comments
 (0)