MCPcopy Create free account
hub / github.com/OAID/Tengine / Run

Method Run

executor/operator/common/rpn.cpp:241–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239struct RPNOps : public NodeOps
240{
241 bool Run(Node* node)
242 {
243 const Tensor* score_tensor = node->GetInputTensor(0);
244 const Tensor* featmap_tensor = node->GetInputTensor(1);
245 const Tensor* info_tensor = node->GetInputTensor(2);
246 Tensor* output_tensor = node->GetOutputTensor(0);
247 TShape& out_shape = output_tensor->GetShape();
248
249 float* output = ( float* )get_tensor_mem(output_tensor);
250 const float* im_info = ( float* )get_tensor_mem(info_tensor);
251 const float* m_score_ = ( float* )get_tensor_mem(score_tensor);
252 const float* m_box_ = ( float* )get_tensor_mem(featmap_tensor);
253
254 const TShape& featmap_shape = featmap_tensor->GetShape();
255 const TShape& score_shape = score_tensor->GetShape();
256 const int feat_height = featmap_shape.GetH();
257 const int feat_width = featmap_shape.GetW();
258 const int feat_channel = featmap_shape.GetC();
259 const int score_channel = score_shape.GetC();
260 const int feat_size = feat_height * feat_width;
261 int src_height_ = im_info[0];
262 int src_width_ = im_info[1];
263 int src_scale_ = im_info[2];
264
265 RPN* RPN_op = dynamic_cast<RPN*>(node->GetOp());
266 RPNParam* param_ = RPN_op->GetParam();
267 int feat_stride = param_->feat_stride;
268 int num_anchors = ( int )param_->anchors_.size();
269
270 // local_anchors (1, anchors_nums_ * 4, map_height_, map_width_);
271 float* local_anchors = new float[num_anchors * 4 * feat_size];
272 proposal_local_anchor(feat_height, feat_width, feat_stride, param_->anchors_, local_anchors);
273
274 float* m_box = new float[feat_channel * feat_size];
275 for(int i = 0; i < feat_channel * feat_size; i++)
276 m_box[i] = m_box_[i];
277 bbox_tranform_inv(m_box, local_anchors, feat_height, feat_width, feat_channel, num_anchors);
278
279 delete[] local_anchors;
280 std::vector<SBox> boxes;
281 float* m_score = new float[score_channel * feat_size];
282 for(int i = 0; i < score_channel * feat_size; i++)
283 m_score[i] = m_score_[i];
284 filter_boxs(boxes, m_box, m_score, param_->min_size, src_scale_, src_width_, src_height_, feat_width,
285 feat_height, num_anchors, feat_channel);
286 delete[] m_box;
287 delete[] m_score;
288
289 std::sort(boxes.rbegin(), boxes.rend());
290
291 if(param_->per_nms_topn > 0)
292 {
293 int tmp = MIN(param_->per_nms_topn, ( int )boxes.size());
294 boxes.erase(boxes.begin() + tmp, boxes.end());
295 }
296 nms_rpn(boxes, param_->nms_thresh);
297
298 if(param_->post_nms_topn > 0)

Callers

nothing calls this directly

Calls 15

get_tensor_memFunction · 0.85
proposal_local_anchorFunction · 0.85
filter_boxsFunction · 0.85
nms_rpnFunction · 0.85
GetHMethod · 0.80
GetWMethod · 0.80
GetCMethod · 0.80
GetOpMethod · 0.80
GetParamMethod · 0.80
rbeginMethod · 0.80
rendMethod · 0.80
beginMethod · 0.80

Tested by

no test coverage detected