diff --git a/paddle/operators/prior_box_op.cc b/paddle/operators/prior_box_op.cc index 286afa8b4f2e9e5766ea20f6d5508c2210c32f19..105ff4ac3e3ba889aad880f4204af15829c6da47 100644 --- a/paddle/operators/prior_box_op.cc +++ b/paddle/operators/prior_box_op.cc @@ -98,16 +98,14 @@ class PriorBoxOpMaker : public framework::OpProtoAndCheckerMaker { "the input image data of PriorBoxOp, The layout is NCHW."); AddOutput("Boxes", "(Tensor, default Tensor), the output prior boxes of " - "PriorBoxOp. The layout is [layer_height, layer_width, " - "num_priors, 4]. layer_height is the height of input, " - "layer_width is the width of input, num_priors is the box " - "count of each position."); + "PriorBoxOp. The layout is [H, W, num_priors, 4]. " + "H is the height of input, W is the width of input, num_priors " + "is the box count of each position."); AddOutput("Variances", "(Tensor, default Tensor), the expanded variances of " - "PriorBoxOp. The layout is [layer_height, layer_width, " - "num_priors, 4]. layer_height is the height of input, " - "layer_width is the width of input, num_priors is the box " - "count of each position."); + "PriorBoxOp. The layout is [H, W, num_priors, 4]. " + "H is the height of input, W is the width of input, num_priors " + "is the box count of each position."); AddAttr>("min_sizes", "(vector) ", "List of min sizes of generated prior boxes."); AddAttr>("max_sizes", "(vector) ", diff --git a/paddle/operators/prior_box_op.h b/paddle/operators/prior_box_op.h index 1869807dc89ab100607d0a7732e828ced84e7c0f..e0a663ace8f38c2d08fd4714c1247d3313ffae3e 100644 --- a/paddle/operators/prior_box_op.h +++ b/paddle/operators/prior_box_op.h @@ -77,13 +77,13 @@ class PriorBoxOpKernel : public framework::OpKernel { auto img_width = image->dims()[3]; auto img_height = image->dims()[2]; - auto layer_width = input->dims()[3]; - auto layer_height = input->dims()[2]; + auto feature_width = input->dims()[3]; + auto feature_height = input->dims()[2]; T step_width, step_height; if (step_w == 0 || step_h == 0) { - step_width = static_cast(img_width) / layer_width; - step_height = static_cast(img_height) / layer_height; + step_width = static_cast(img_width) / feature_width; + step_height = static_cast(img_height) / feature_height; } else { step_width = step_w; step_height = step_h; @@ -98,8 +98,8 @@ class PriorBoxOpKernel : public framework::OpKernel { vars->mutable_data(ctx.GetPlace()); auto e_boxes = framework::EigenTensor::From(*boxes); - for (int h = 0; h < layer_height; ++h) { - for (int w = 0; w < layer_width; ++w) { + for (int h = 0; h < feature_height; ++h) { + for (int w = 0; w < feature_width; ++w) { T center_x = (w + offset) * step_width; T center_y = (h + offset) * step_height; T box_width, box_height; @@ -164,12 +164,16 @@ class PriorBoxOpKernel : public framework::OpKernel { boxes->data(), clip_func); } - Eigen::Tensor var_et(1, variances.size()); + framework::Tensor var_t; + var_t.mutable_data( + framework::make_ddim({1, static_cast(variances.size())}), + ctx.GetPlace()); + auto var_et = framework::EigenTensor::From(var_t); for (size_t i = 0; i < variances.size(); ++i) { var_et(0, i) = variances[i]; } - int box_num = layer_height * layer_width * num_priors; + int box_num = feature_height * feature_width * num_priors; auto var_dim = vars->dims(); vars->Resize({box_num, static_cast(variances.size())});