From ebc6959c9becf0bf0eab6eb260da45b96afc80ea Mon Sep 17 00:00:00 2001 From: wangxinxin08 <69842442+wangxinxin08@users.noreply.github.com> Date: Wed, 2 Mar 2022 19:35:10 +0800 Subject: [PATCH] modify infershape of yolo_box (#40056) * modify infershape of yolo_box --- paddle/fluid/operators/detection/yolo_box_op.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/detection/yolo_box_op.cc b/paddle/fluid/operators/detection/yolo_box_op.cc index 48b0d511d9..511d8e0eed 100644 --- a/paddle/fluid/operators/detection/yolo_box_op.cc +++ b/paddle/fluid/operators/detection/yolo_box_op.cc @@ -102,7 +102,12 @@ class YoloBoxOp : public framework::OperatorWithKernel { "But received class_num (%s)", class_num)); - int box_num = dim_x[2] * dim_x[3] * anchor_num; + int box_num; + if ((dim_x[2] > 0 && dim_x[3] > 0) || ctx->IsRuntime()) { + box_num = dim_x[2] * dim_x[3] * anchor_num; + } else { + box_num = -1; + } std::vector dim_boxes({dim_x[0], box_num, 4}); ctx->SetOutputDim("Boxes", phi::make_ddim(dim_boxes)); -- GitLab