提交 74aecd48 编写于 作者: Y yongqiang

change priorbox. test=develop

上级 b6c88f70
......@@ -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<float>& min_size_,
const std::vector<float>& fixed_size_,
const std::vector<float>& 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>();
float* _variance_data = (*variances)->mutable_data<float>();
float* _cpu_data = boxes->mutable_data<float>();
float* _variance_data = variances->mutable_data<float>();
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<float>& min_size,
const std::vector<float>& max_size,
const std::vector<float>& aspect_ratio,
......
......@@ -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<float>& min_size_,
const std::vector<float>& fixed_size_,
const std::vector<float>& 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<float>& min_size,
const std::vector<float>& max_size,
const std::vector<float>& aspect_ratio,
......
......@@ -46,7 +46,7 @@ inline void ExpandAspectRatios(const std::vector<float>& input_aspect_ratior,
}
}
void PriorBoxCompute::Run() {
void PriorBoxCompute::PrepareForRun() {
auto& param = Param<operators::PriorBoxParam>();
bool is_flip = param.flip;
......@@ -69,8 +69,8 @@ void PriorBoxCompute::Run() {
lite::arm::math::prior_box(param.input,
param.image,
&param.boxes,
&param.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<operators::PriorBoxParam>();
param.boxes->Resize(out_boxes.dims());
param.variances->Resize(out_boxes.dims());
memcpy(param.boxes->mutable_data<float>(),
out_boxes.data<float>(),
param.boxes->numel());
memcpy(param.variances->mutable_data<float>(),
variances.data<float>(),
param.variances->numel());
}
} // namespace arm
......
......@@ -24,10 +24,15 @@ namespace arm {
class PriorBoxCompute : public KernelLite<TARGET(kARM), PRECISION(kFloat)> {
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册