diff --git a/lite/backends/arm/math/prior_box.cc b/lite/backends/arm/math/prior_box.cc index f262e6e1d7318e6c42e8b666239be4ae500788fe..6daab69ebf00da24d67132afba4b9abef0afbd39 100644 --- a/lite/backends/arm/math/prior_box.cc +++ b/lite/backends/arm/math/prior_box.cc @@ -63,7 +63,8 @@ void density_prior_box(const lite::Tensor* input, int prior_num_, bool is_flip_, bool is_clip_, - const std::vector& order_) { + const std::vector& order_, + bool min_max_aspect_ratios_order) { // compute output shape int win1 = input->dims()[3]; int hin1 = input->dims()[2]; @@ -284,12 +285,21 @@ void density_prior_box(const lite::Tensor* input, //! ymax com_buf[com_idx++] = (center_y + box_height / 2.f) / img_height; } - memcpy(_cpu_data + idx, min_buf, sizeof(float) * min_idx); - idx += min_idx; - memcpy(_cpu_data + idx, com_buf, sizeof(float) * com_idx); - idx += com_idx; - memcpy(_cpu_data + idx, max_buf, sizeof(float) * max_idx); - idx += max_idx; + if (min_max_aspect_ratios_order) { + memcpy(_cpu_data + idx, min_buf, sizeof(float) * min_idx); + idx += min_idx; + memcpy(_cpu_data + idx, max_buf, sizeof(float) * max_idx); + idx += max_idx; + memcpy(_cpu_data + idx, com_buf, sizeof(float) * com_idx); + idx += com_idx; + } else { + memcpy(_cpu_data + idx, min_buf, sizeof(float) * min_idx); + idx += min_idx; + memcpy(_cpu_data + idx, com_buf, sizeof(float) * com_idx); + idx += com_idx; + memcpy(_cpu_data + idx, max_buf, sizeof(float) * max_idx); + idx += max_idx; + } } fast_free(min_buf); fast_free(max_buf); @@ -333,7 +343,8 @@ void prior_box(const lite::Tensor* input, int prior_num, bool is_flip, bool is_clip, - const std::vector& order) { + const std::vector& order, + bool min_max_aspect_ratios_order) { density_prior_box(input, image, boxes, @@ -353,7 +364,8 @@ void prior_box(const lite::Tensor* input, prior_num, is_flip, is_clip, - order); + order, + min_max_aspect_ratios_order); } } // namespace math diff --git a/lite/backends/arm/math/prior_box.h b/lite/backends/arm/math/prior_box.h index ffa821b75e54ee3e2329e4dcced8ddee2a003802..03fd62751081e491ddfb23f196d52153db5d3a5f 100644 --- a/lite/backends/arm/math/prior_box.h +++ b/lite/backends/arm/math/prior_box.h @@ -42,7 +42,8 @@ void density_prior_box(const lite::Tensor* input, int prior_num_, bool is_flip_, bool is_clip_, - const std::vector& order_); + const std::vector& order_, + bool min_max_aspect_ratios_order); void prior_box(const lite::Tensor* input, const lite::Tensor* image, @@ -60,7 +61,8 @@ void prior_box(const lite::Tensor* input, int prior_num, bool is_flip, bool is_clip, - const std::vector& order); + const std::vector& order, + bool min_max_aspect_ratios_order); } // namespace math } // namespace arm diff --git a/lite/kernels/arm/density_prior_box_compute.cc b/lite/kernels/arm/density_prior_box_compute.cc index 3a9fa85411464081e7b006afffe4e80d87ef90f6..e45fd5ba4d3c120140de13d00f074fd3526ac3f5 100644 --- a/lite/kernels/arm/density_prior_box_compute.cc +++ b/lite/kernels/arm/density_prior_box_compute.cc @@ -100,7 +100,8 @@ void DensityPriorBoxCompute::Run() { prior_num, is_flip, is_clip, - order); + order, + false); } } // namespace arm diff --git a/lite/kernels/arm/prior_box_compute.cc b/lite/kernels/arm/prior_box_compute.cc index 203f483351a27650b8ccb27c930dcdc5d2a5ceb9..48ae1e94dd74453c9160604a94ecfabd0e516034 100644 --- a/lite/kernels/arm/prior_box_compute.cc +++ b/lite/kernels/arm/prior_box_compute.cc @@ -65,6 +65,7 @@ void PriorBoxCompute::Run() { size_t prior_num = aspect_ratios_vec.size() * min_size.size(); prior_num += max_size.size(); std::vector order = param.order; + bool min_max_aspect_ratios_order = param.min_max_aspect_ratios_order; lite::arm::math::prior_box(param.input, param.image, @@ -82,7 +83,8 @@ void PriorBoxCompute::Run() { prior_num, is_flip, is_clip, - order); + order, + min_max_aspect_ratios_order); } } // namespace arm diff --git a/lite/operators/op_params.h b/lite/operators/op_params.h index 392ed6296aade8534b686abc8dd5e441f047ceac..9c39ef9a9ca119c8304c49ad25941bd76015de37 100644 --- a/lite/operators/op_params.h +++ b/lite/operators/op_params.h @@ -540,6 +540,7 @@ struct PriorBoxParam { int prior_num{0}; // priortype: prior_min, prior_max, prior_com std::vector order; + bool min_max_aspect_ratios_order{false}; }; struct DensityPriorBoxParam : public PriorBoxParam { diff --git a/lite/operators/prior_box_op.cc b/lite/operators/prior_box_op.cc index 3cc8938f4eb3ffc5720a6e1cfc1746e1defd048e..c4717c8185b24cfd9f6a551dcb932dc325a502d2 100644 --- a/lite/operators/prior_box_op.cc +++ b/lite/operators/prior_box_op.cc @@ -67,6 +67,10 @@ bool PriorBoxOpLite::AttachImpl(const cpp::OpDesc& opdesc, lite::Scope* scope) { if (opdesc.HasAttr("order")) { param_.order = opdesc.GetAttr>("order"); } + if (opdesc.HasAttr("min_max_aspect_ratios_order")) { + param_.min_max_aspect_ratios_order = + opdesc.GetAttr("min_max_aspect_ratios_order"); + } return true; }