40 : _memory_group(memory_manager),
51 _cpp_nms(memory_manager),
56 _deltas_flattened_f32(),
62 _all_proposals_quantized(),
64 _classes_nms_unused(),
65 _proposals_4_roi_values(),
66 _all_proposals_to_use(nullptr),
67 _num_valid_proposals(nullptr),
83 num_valid_proposals,
info);
97 proposals->
info(), scores_out->
info(),
110 const int total_num_anchors = num_anchors * feat_width * feat_height;
111 const int pre_nms_topN =
info.pre_nms_topN();
112 const int post_nms_topN =
info.post_nms_topN();
113 const size_t values_per_roi =
info.values_per_roi();
121 _memory_group.
manage(&_all_anchors);
122 _compute_anchors_kernel->configure(compile_context, anchors, &_all_anchors,
125 const TensorShape flatten_shape_deltas(values_per_roi, total_num_anchors);
130 _memory_group.
manage(&_deltas_flattened);
133 _memory_group.
manage(&_deltas_permuted);
135 _flatten_deltas.
configure(compile_context, &_deltas_permuted, &_deltas_flattened);
140 _flatten_deltas.
configure(compile_context, deltas, &_deltas_flattened);
143 const TensorShape flatten_shape_scores(1, total_num_anchors);
147 _memory_group.
manage(&_scores_flattened);
150 _memory_group.
manage(&_scores_permuted);
152 _flatten_scores.
configure(compile_context, &_scores_permuted, &_scores_flattened);
157 _flatten_scores.
configure(compile_context, scores, &_scores_flattened);
160 CLTensor *anchors_to_use = &_all_anchors;
161 CLTensor *deltas_to_use = &_deltas_flattened;
166 _memory_group.
manage(&_all_anchors_f32);
167 _memory_group.
manage(&_deltas_flattened_f32);
169 _dequantize_anchors->configure(compile_context, &_all_anchors, &_all_anchors_f32);
171 anchors_to_use = &_all_anchors_f32;
173 _dequantize_deltas->configure(compile_context, &_deltas_flattened, &_deltas_flattened_f32);
175 deltas_to_use = &_deltas_flattened_f32;
178 _memory_group.
manage(&_all_proposals);
180 _bounding_box_kernel->configure(compile_context, anchors_to_use, &_all_proposals, deltas_to_use, bbox_info);
184 _all_proposals_to_use = &_all_proposals;
187 _memory_group.
manage(&_all_proposals_quantized);
191 _quantize_all_proposals->configure(compile_context, &_all_proposals, &_all_proposals_quantized);
193 _all_proposals_to_use = &_all_proposals_quantized;
199 const int scores_nms_size = std::min<int>(std::min<int>(post_nms_topN, pre_nms_topN), total_num_anchors);
200 const float min_size_scaled =
info.min_size() *
info.im_scale();
201 _memory_group.
manage(&_classes_nms_unused);
202 _memory_group.
manage(&_keeps_nms_unused);
215 _scores_out = scores_out;
216 _num_valid_proposals = num_valid_proposals;
218 _memory_group.
manage(&_proposals_4_roi_values);
219 _cpp_nms.
configure(&_scores_flattened, _all_proposals_to_use,
nullptr, scores_out, &_proposals_4_roi_values,
220 &_classes_nms_unused,
nullptr, &_keeps_nms_unused, num_valid_proposals,
222 true, min_size_scaled,
info.im_width(),
info.im_height()));
229 _pad_kernel->configure(compile_context, &_proposals_4_roi_values, proposals,
PaddingList{{1, 0}});
247 const int num_anchors =
249 const int feat_width =
251 const int feat_height =
253 const int num_images = scores->
dimension(3);
254 const int total_num_anchors = num_anchors * feat_width * feat_height;
255 const int values_per_roi =
info.values_per_roi();
269 anchors->
clone()->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(
true));
275 ->set_tensor_shape(
TensorShape(values_per_roi * num_anchors, feat_width, feat_height))
276 .set_is_resizable(
true);
278 scores->
clone()->set_tensor_shape(
TensorShape(num_anchors, feat_width, feat_height)).set_is_resizable(
true);
291 deltas->
clone()->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(
true));
295 scores->
clone()->set_tensor_shape(
TensorShape(1, total_num_anchors)).set_is_resizable(
true));
297 deltas->
clone()->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(
true));
301 TensorInfo *proposals_4_roi_values_to_use = &proposals_4_roi_values;
303 deltas->
clone()->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(
true));
309 ->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors))
310 .set_is_resizable(
true)
315 ->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors))
316 .set_is_resizable(
true)
322 ->set_tensor_shape(
TensorShape(values_per_roi, total_num_anchors))
323 .set_is_resizable(
true)
326 &all_anchors_f32_info, &proposals_4_roi_values_f32, &deltas_flattened_f32_info,
331 proposals_4_roi_values_to_use = &proposals_4_roi_values_quantized;
378 void CLGenerateProposalsLayer::run_cpp_nms_kernel()
381 _scores_flattened.
map(
true);
382 _all_proposals_to_use->
map(
true);
388 _keeps_nms_unused.
map(
true);
389 _classes_nms_unused.
map(
true);
395 _keeps_nms_unused.
unmap();
396 _classes_nms_unused.
unmap();
402 _scores_flattened.
unmap();
403 _all_proposals_to_use->
unmap();
417 _permute_deltas.
run();
418 _permute_scores.
run();
420 _flatten_deltas.
run();
421 _flatten_scores.
run();
425 _dequantize_anchors->run();
426 _dequantize_deltas->run();
434 _quantize_all_proposals->run();
438 run_cpp_nms_kernel();