diff --git a/lite/backends/arm/math/prior_box.cc b/lite/backends/arm/math/prior_box.cc old mode 100644 new mode 100755 index 4ef7356e67cee4c47ddf3eb16ed5286b4271b41a..fd0729d8fce344f0360526fd38a9d7ce4064d01d --- a/lite/backends/arm/math/prior_box.cc +++ b/lite/backends/arm/math/prior_box.cc @@ -21,7 +21,7 @@ namespace lite { namespace arm { namespace math { -const int MALLOC_ALIGN = 16; +const int MALLOC_ALIGN = 64; void* fast_malloc(size_t size) { size_t offset = sizeof(void*) + MALLOC_ALIGN - 1; @@ -46,8 +46,8 @@ void fast_free(void* ptr) { void density_prior_box(const lite::Tensor* input, const lite::Tensor* image, - lite::Tensor** boxes, - lite::Tensor** variances, + lite::Tensor* boxes, + lite::Tensor* variances, const std::vector& min_size_, const std::vector& fixed_size_, const std::vector& fixed_ratio_, @@ -69,11 +69,11 @@ void density_prior_box(const lite::Tensor* input, int win1 = input->dims()[3]; int hin1 = input->dims()[2]; DDim shape_out({hin1, win1, prior_num_, 4}); - (*boxes)->Resize(shape_out); - (*variances)->Resize(shape_out); + boxes->Resize(shape_out); + variances->Resize(shape_out); - float* _cpu_data = (*boxes)->mutable_data(); - float* _variance_data = (*variances)->mutable_data(); + float* _cpu_data = boxes->mutable_data(); + float* _variance_data = variances->mutable_data(); const int width = win1; const int height = hin1; @@ -329,8 +329,8 @@ void density_prior_box(const lite::Tensor* input, void prior_box(const lite::Tensor* input, const lite::Tensor* image, - lite::Tensor** boxes, - lite::Tensor** variances, + lite::Tensor* boxes, + lite::Tensor* variances, const std::vector& min_size, const std::vector& max_size, const std::vector& aspect_ratio, diff --git a/lite/backends/arm/math/prior_box.h b/lite/backends/arm/math/prior_box.h old mode 100644 new mode 100755 index 03fd62751081e491ddfb23f196d52153db5d3a5f..2a22854a6194818b23a355cc0111402312c1fcf2 --- a/lite/backends/arm/math/prior_box.h +++ b/lite/backends/arm/math/prior_box.h @@ -25,8 +25,8 @@ namespace math { void density_prior_box(const lite::Tensor* input, const lite::Tensor* image, - lite::Tensor** boxes, - lite::Tensor** variances, + lite::Tensor* boxes, + lite::Tensor* variances, const std::vector& min_size_, const std::vector& fixed_size_, const std::vector& fixed_ratio_, @@ -47,8 +47,8 @@ void density_prior_box(const lite::Tensor* input, void prior_box(const lite::Tensor* input, const lite::Tensor* image, - lite::Tensor** boxes, - lite::Tensor** variances, + lite::Tensor* boxes, + lite::Tensor* variances, const std::vector& min_size, const std::vector& max_size, const std::vector& aspect_ratio, diff --git a/lite/kernels/arm/prior_box_compute.cc b/lite/kernels/arm/prior_box_compute.cc index 48ae1e94dd74453c9160604a94ecfabd0e516034..7ac1c5c2e009d33897ce6bc5c2176a648f517a3c 100644 --- a/lite/kernels/arm/prior_box_compute.cc +++ b/lite/kernels/arm/prior_box_compute.cc @@ -46,7 +46,7 @@ inline void ExpandAspectRatios(const std::vector& input_aspect_ratior, } } -void PriorBoxCompute::Run() { +void PriorBoxCompute::PrepareForRun() { auto& param = Param(); bool is_flip = param.flip; @@ -69,8 +69,8 @@ void PriorBoxCompute::Run() { lite::arm::math::prior_box(param.input, param.image, - ¶m.boxes, - ¶m.variances, + &out_boxes, + &variances, min_size, max_size, aspect_ratios_vec, @@ -85,6 +85,22 @@ void PriorBoxCompute::Run() { is_clip, order, min_max_aspect_ratios_order); + this->_flag_init = true; +} + +void PriorBoxCompute::Run() { + if (!this->_flag_init) { + LOG(FATAL) << "ERROR: init priorbox first\n"; + } + auto& param = Param(); + param.boxes->Resize(out_boxes.dims()); + param.variances->Resize(out_boxes.dims()); + memcpy(param.boxes->mutable_data(), + out_boxes.data(), + param.boxes->numel()); + memcpy(param.variances->mutable_data(), + variances.data(), + param.variances->numel()); } } // namespace arm diff --git a/lite/kernels/arm/prior_box_compute.h b/lite/kernels/arm/prior_box_compute.h index d44406a98fa4d6ec142fb8cf1a83205599eeb5b2..277c3ed37c78a9e79bbb874b662f4ce100d88551 100644 --- a/lite/kernels/arm/prior_box_compute.h +++ b/lite/kernels/arm/prior_box_compute.h @@ -24,10 +24,15 @@ namespace arm { class PriorBoxCompute : public KernelLite { public: using param_t = operators::PriorBoxParam; - + void PrepareForRun() override; void Run() override; virtual ~PriorBoxCompute() = default; + + private: + bool _flag_init{false}; + lite::Tensor out_boxes; + lite::Tensor variances; }; } // namespace arm