blob: 2997b593c63773958f7e92f55565404f3041d756 [file] [log] [blame]
Isabella Gottardia7acb3c2019-01-08 13:48:44 +00001/*
2 * Copyright (c) 2019 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/runtime/CPP/functions/CPPDetectionPostProcessLayer.h"
25
26#include "arm_compute/core/Error.h"
27#include "arm_compute/core/Helpers.h"
28#include "arm_compute/core/Validate.h"
29#include "support/ToolchainSupport.h"
30
31#include <cstddef>
32#include <ios>
33#include <list>
34
35namespace arm_compute
36{
37namespace
38{
39Status validate_arguments(const ITensorInfo *input_box_encoding, const ITensorInfo *input_class_score, const ITensorInfo *input_anchors,
40 ITensorInfo *output_boxes, ITensorInfo *output_classes, ITensorInfo *output_scores, ITensorInfo *num_detection,
41 DetectionPostProcessLayerInfo info, const unsigned int kBatchSize, const unsigned int kNumCoordBox)
42{
43 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input_box_encoding, input_class_score, input_anchors);
44 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input_box_encoding, 1, DataType::F32, DataType::QASYMM8);
45 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input_box_encoding, input_class_score, input_anchors);
46 ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_box_encoding->num_dimensions() > 3, "The location input tensor shape should be [4, N, kBatchSize].");
47 if(input_box_encoding->num_dimensions() > 2)
48 {
49 ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_box_encoding->dimension(2) != kBatchSize, "The third dimension of the input box_encoding tensor should be equal to %d.", kBatchSize);
50 }
51 ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_box_encoding->dimension(0) != kNumCoordBox, "The first dimension of the input box_encoding tensor should be equal to %d.", kNumCoordBox);
52 ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_class_score->dimension(0) != (info.num_classes() + 1),
53 "The first dimension of the input class_prediction should be equal to the number of classes plus one.");
54
55 ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_anchors->num_dimensions() > 3, "The anchors input tensor shape should be [4, N, kBatchSize].");
56 if(input_anchors->num_dimensions() > 2)
57 {
58 ARM_COMPUTE_RETURN_ERROR_ON_MSG(input_anchors->dimension(0) != kNumCoordBox, "The first dimension of the input anchors tensor should be equal to %d.", kNumCoordBox);
59 }
60 ARM_COMPUTE_RETURN_ERROR_ON_MSG((input_box_encoding->dimension(1) != input_class_score->dimension(1))
61 || (input_box_encoding->dimension(1) != input_anchors->dimension(1)),
62 "The second dimension of the inputs should be the same.");
63 ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_detection->num_dimensions() > 1, "The num_detection output tensor shape should be [M].");
64 ARM_COMPUTE_RETURN_ERROR_ON_MSG((info.iou_threshold() <= 0.0f) || (info.iou_threshold() > 1.0f), "The intersection over union should be positive and less than 1.");
65 ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.max_classes_per_detection() <= 0, "The number of max classes per detection should be positive.");
66
67 const unsigned int num_detected_boxes = info.max_detections() * info.max_classes_per_detection();
68
69 // Validate configured outputs
70 if(output_boxes->total_size() != 0)
71 {
72 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output_boxes->tensor_shape(), TensorShape(4U, num_detected_boxes, 1U));
73 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output_boxes, 1, DataType::F32);
74 }
75 if(output_classes->total_size() != 0)
76 {
77 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output_classes->tensor_shape(), TensorShape(num_detected_boxes, 1U));
78 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output_classes, 1, DataType::F32);
79 }
80 if(output_scores->total_size() != 0)
81 {
82 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output_scores->tensor_shape(), TensorShape(num_detected_boxes, 1U));
83 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(output_scores, 1, DataType::F32);
84 }
85 if(num_detection->total_size() != 0)
86 {
87 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(num_detection->tensor_shape(), TensorShape(1U));
88 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(num_detection, 1, DataType::F32);
89 }
90
91 return Status{};
92}
93
94/** Decode a bbox according to a anchors and scale info.
95 *
96 * @param[in] input_box_encoding The input prior bounding boxes.
97 * @param[in] input_anchors The corresponding input variance.
98 * @param[in] info The detection informations
99 * @param[out] decoded_boxes The decoded bboxes.
100 */
101void DecodeCenterSizeBoxes(const ITensor *input_box_encoding, const ITensor *input_anchors, DetectionPostProcessLayerInfo info, Tensor *decoded_boxes)
102{
103 const QuantizationInfo &qi_box = input_box_encoding->info()->quantization_info();
104 const QuantizationInfo &qi_anchors = input_anchors->info()->quantization_info();
105 BBox box_centersize;
106 BBox anchor;
107
108 Window win;
109 win.use_tensor_dimensions(input_box_encoding->info()->tensor_shape());
110 win.set_dimension_step(0U, 4U);
111 win.set_dimension_step(1U, 1U);
112 Iterator box_it(input_box_encoding, win);
113 Iterator anchor_it(input_anchors, win);
114 Iterator decoded_it(decoded_boxes, win);
115
116 const float half_factor = 0.5f;
117
118 execute_window_loop(win, [&](const Coordinates &)
119 {
120 if(is_data_type_quantized(input_box_encoding->info()->data_type()))
121 {
122 const auto box_ptr = reinterpret_cast<const qasymm8_t *>(box_it.ptr());
123 const auto anchor_ptr = reinterpret_cast<const qasymm8_t *>(anchor_it.ptr());
124 box_centersize = BBox({ dequantize_qasymm8(*box_ptr, qi_box), dequantize_qasymm8(*(box_ptr + 1), qi_box),
125 dequantize_qasymm8(*(2 + box_ptr), qi_box), dequantize_qasymm8(*(3 + box_ptr), qi_box)
126 });
127 anchor = BBox({ dequantize_qasymm8(*anchor_ptr, qi_anchors), dequantize_qasymm8(*(anchor_ptr + 1), qi_anchors),
128 dequantize_qasymm8(*(2 + anchor_ptr), qi_anchors), dequantize_qasymm8(*(3 + anchor_ptr), qi_anchors)
129 });
130 }
131 else
132 {
133 const auto box_ptr = reinterpret_cast<const float *>(box_it.ptr());
134 const auto anchor_ptr = reinterpret_cast<const float *>(anchor_it.ptr());
135 box_centersize = BBox({ *box_ptr, *(box_ptr + 1), *(2 + box_ptr), *(3 + box_ptr) });
136 anchor = BBox({ *anchor_ptr, *(anchor_ptr + 1), *(2 + anchor_ptr), *(3 + anchor_ptr) });
137 }
138
139 // BBox is equavalent to CenterSizeEncoding [y,x,h,w]
140 const float y_center = box_centersize[0] / info.scale_value_y() * anchor[2] + anchor[0];
141 const float x_center = box_centersize[1] / info.scale_value_x() * anchor[3] + anchor[1];
142 const float half_h = half_factor * static_cast<float>(std::exp(box_centersize[2] / info.scale_value_h())) * anchor[2];
143 const float half_w = half_factor * static_cast<float>(std::exp(box_centersize[3] / info.scale_value_w())) * anchor[3];
144
145 // Box Corner encoding boxes are saved as [xmin, ymin, xmax, ymax]
146 auto decoded_ptr = reinterpret_cast<float *>(decoded_it.ptr());
147 *(decoded_ptr) = x_center - half_w; // xmin
148 *(1 + decoded_ptr) = y_center - half_h; // ymin
149 *(2 + decoded_ptr) = x_center + half_w; // xmax
150 *(3 + decoded_ptr) = y_center + half_h; // ymax
151 },
152 box_it, anchor_it, decoded_it);
153}
154
155void SaveOutputs(const Tensor *decoded_boxes, const std::vector<int> &result_idx_boxes_after_nms, const std::vector<float> &result_scores_after_nms, const std::vector<int> &result_classes_after_nms,
156 std::vector<unsigned int> &sorted_indices, const unsigned int num_output, const unsigned int max_detections, ITensor *output_boxes, ITensor *output_classes, ITensor *output_scores,
157 ITensor *num_detection)
158{
159 // ymin,xmin,ymax,xmax -> xmin,ymin,xmax,ymax
160 unsigned int i = 0;
161 for(; i < num_output; ++i)
162 {
163 const unsigned int box_in_idx = result_idx_boxes_after_nms[sorted_indices[i]];
164 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(0, i)))) = *(reinterpret_cast<float *>(decoded_boxes->ptr_to_element(Coordinates(1, box_in_idx))));
165 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(1, i)))) = *(reinterpret_cast<float *>(decoded_boxes->ptr_to_element(Coordinates(0, box_in_idx))));
166 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(2, i)))) = *(reinterpret_cast<float *>(decoded_boxes->ptr_to_element(Coordinates(3, box_in_idx))));
167 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(3, i)))) = *(reinterpret_cast<float *>(decoded_boxes->ptr_to_element(Coordinates(2, box_in_idx))));
168 *(reinterpret_cast<float *>(output_classes->ptr_to_element(Coordinates(i)))) = static_cast<float>(result_classes_after_nms[sorted_indices[i]]);
169 *(reinterpret_cast<float *>(output_scores->ptr_to_element(Coordinates(i)))) = result_scores_after_nms[sorted_indices[i]];
170 }
171 for(; i < max_detections; ++i)
172 {
173 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(1, i)))) = 0.0f;
174 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(0, i)))) = 0.0f;
175 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(3, i)))) = 0.0f;
176 *(reinterpret_cast<float *>(output_boxes->ptr_to_element(Coordinates(2, i)))) = 0.0f;
177 *(reinterpret_cast<float *>(output_classes->ptr_to_element(Coordinates(i)))) = 0.0f;
178 *(reinterpret_cast<float *>(output_scores->ptr_to_element(Coordinates(i)))) = 0.0f;
179 }
180 *(reinterpret_cast<float *>(num_detection->ptr_to_element(Coordinates(0)))) = num_output;
181}
182} // namespace
183
184CPPDetectionPostProcessLayer::CPPDetectionPostProcessLayer(std::shared_ptr<IMemoryManager> memory_manager)
185 : _memory_group(std::move(memory_manager)), _nms(), _input_box_encoding(nullptr), _input_scores(nullptr), _input_anchors(nullptr), _output_boxes(nullptr), _output_classes(nullptr),
186 _output_scores(nullptr), _num_detection(nullptr), _info(), _num_boxes(), _num_classes_with_background(), _num_max_detected_boxes(), _decoded_boxes(), _decoded_scores(), _selected_indices(),
187 _class_scores(), _input_scores_to_use(nullptr), _result_idx_boxes_after_nms(), _result_classes_after_nms(), _result_scores_after_nms(), _sorted_indices(), _box_scores()
188{
189}
190
191void CPPDetectionPostProcessLayer::configure(const ITensor *input_box_encoding, const ITensor *input_scores, const ITensor *input_anchors,
192 ITensor *output_boxes, ITensor *output_classes, ITensor *output_scores, ITensor *num_detection, DetectionPostProcessLayerInfo info)
193{
194 ARM_COMPUTE_ERROR_ON_NULLPTR(input_box_encoding, input_scores, input_anchors, output_boxes, output_classes, output_scores);
195 _num_max_detected_boxes = info.max_detections() * info.max_classes_per_detection();
196
197 auto_init_if_empty(*output_boxes->info(), TensorInfo(TensorShape(_kNumCoordBox, _num_max_detected_boxes, _kBatchSize), 1, DataType::F32));
198 auto_init_if_empty(*output_classes->info(), TensorInfo(TensorShape(_num_max_detected_boxes, _kBatchSize), 1, DataType::F32));
199 auto_init_if_empty(*output_scores->info(), TensorInfo(TensorShape(_num_max_detected_boxes, _kBatchSize), 1, DataType::F32));
200 auto_init_if_empty(*num_detection->info(), TensorInfo(TensorShape(1U), 1, DataType::F32));
201
202 // Perform validation step
203 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input_box_encoding->info(), input_scores->info(), input_anchors->info(), output_boxes->info(), output_classes->info(), output_scores->info(),
204 num_detection->info(),
205 info, _kBatchSize, _kNumCoordBox));
206
207 _input_box_encoding = input_box_encoding;
208 _input_scores = input_scores;
209 _input_anchors = input_anchors;
210 _output_boxes = output_boxes;
211 _output_classes = output_classes;
212 _output_scores = output_scores;
213 _num_detection = num_detection;
214 _info = info;
215 _num_boxes = input_box_encoding->info()->dimension(1);
216 _num_classes_with_background = _input_scores->info()->dimension(0);
217
218 auto_init_if_empty(*_decoded_boxes.info(), TensorInfo(TensorShape(_kNumCoordBox, _input_box_encoding->info()->dimension(1), _kBatchSize), 1, DataType::F32));
219 auto_init_if_empty(*_decoded_scores.info(), TensorInfo(TensorShape(_input_scores->info()->dimension(0), _input_scores->info()->dimension(1), _kBatchSize), 1, DataType::F32));
220 auto_init_if_empty(*_selected_indices.info(), TensorInfo(TensorShape(info.max_detections()), 1, DataType::S32));
221
222 const unsigned int num_classes_per_box = std::min(info.max_classes_per_detection(), info.num_classes());
223 auto_init_if_empty(*_class_scores.info(), TensorInfo(info.use_regular_nms() ? TensorShape(_num_boxes) : TensorShape(_num_boxes * num_classes_per_box), 1, DataType::F32));
224
225 _input_scores_to_use = is_data_type_quantized(input_box_encoding->info()->data_type()) ? &_decoded_scores : _input_scores;
226
227 // Manage intermediate buffers
228 _memory_group.manage(&_decoded_boxes);
229 _memory_group.manage(&_decoded_scores);
230 _memory_group.manage(&_selected_indices);
231 _memory_group.manage(&_class_scores);
232 _nms.configure(&_decoded_boxes, &_class_scores, &_selected_indices, info.use_regular_nms() ? info.detection_per_class() : info.max_detections(), info.nms_score_threshold(), info.iou_threshold());
233
234 // Allocate and reserve intermediate tensors and vectors
235 _decoded_boxes.allocator()->allocate();
236 _decoded_scores.allocator()->allocate();
237 _selected_indices.allocator()->allocate();
238 _class_scores.allocator()->allocate();
239
240 if(info.use_regular_nms())
241 {
242 _result_idx_boxes_after_nms.reserve(_info.detection_per_class() * _info.num_classes());
243 _result_classes_after_nms.reserve(_info.detection_per_class() * _info.num_classes());
244 _result_scores_after_nms.reserve(_info.detection_per_class() * _info.num_classes());
245 }
246 else
247 {
248 _result_scores_after_nms.reserve(num_classes_per_box * _num_boxes);
249 _result_classes_after_nms.reserve(num_classes_per_box * _num_boxes);
250 _result_scores_after_nms.reserve(num_classes_per_box * _num_boxes);
251 _box_scores.reserve(_num_boxes);
252 }
253 _sorted_indices.resize(info.use_regular_nms() ? info.max_detections() : info.num_classes());
254}
255
256Status CPPDetectionPostProcessLayer::validate(const ITensorInfo *input_box_encoding, const ITensorInfo *input_class_score, const ITensorInfo *input_anchors,
257 ITensorInfo *output_boxes, ITensorInfo *output_classes, ITensorInfo *output_scores, ITensorInfo *num_detection, DetectionPostProcessLayerInfo info)
258{
259 constexpr unsigned int kBatchSize = 1;
260 constexpr unsigned int kNumCoordBox = 4;
261 const TensorInfo _decoded_boxes_info = TensorInfo(TensorShape(kNumCoordBox, input_box_encoding->dimension(1)), 1, DataType::F32);
262 const TensorInfo _decoded_scores_info = TensorInfo(TensorShape(input_box_encoding->dimension(1)), 1, DataType::F32);
263 const TensorInfo _selected_indices_info = TensorInfo(TensorShape(info.max_detections()), 1, DataType::S32);
264
265 ARM_COMPUTE_RETURN_ON_ERROR(CPPNonMaximumSuppression::validate(&_decoded_boxes_info, &_decoded_scores_info, &_selected_indices_info, info.max_detections(), info.nms_score_threshold(),
266 info.iou_threshold()));
267 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input_box_encoding, input_class_score, input_anchors, output_boxes, output_classes, output_scores, num_detection, info, kBatchSize, kNumCoordBox));
268
269 return Status{};
270}
271
272void CPPDetectionPostProcessLayer::run()
273{
274 const unsigned int num_classes = _info.num_classes();
275 const unsigned int max_detections = _info.max_detections();
276
277 DecodeCenterSizeBoxes(_input_box_encoding, _input_anchors, _info, &_decoded_boxes);
278
279 // Decode scores if necessary
280 if(is_data_type_quantized(_input_box_encoding->info()->data_type()))
281 {
282 for(unsigned int idx_c = 0; idx_c < _num_classes_with_background; ++idx_c)
283 {
284 for(unsigned int idx_b = 0; idx_b < _num_boxes; ++idx_b)
285 {
286 *(reinterpret_cast<float *>(_decoded_scores.ptr_to_element(Coordinates(idx_c, idx_b)))) =
287 dequantize_qasymm8(*(reinterpret_cast<qasymm8_t *>(_input_scores->ptr_to_element(Coordinates(idx_c, idx_b)))), _input_scores->info()->quantization_info());
288 }
289 }
290 }
291 // Regular NMS
292 if(_info.use_regular_nms())
293 {
294 for(unsigned int c = 0; c < num_classes; ++c)
295 {
296 // For each boxes get scores of the boxes for the class c
297 for(unsigned int i = 0; i < _num_boxes; ++i)
298 {
299 *(reinterpret_cast<float *>(_class_scores.ptr_to_element(Coordinates(i)))) =
300 *(reinterpret_cast<float *>(_input_scores_to_use->ptr_to_element(Coordinates(c + 1, i)))); // i * _num_classes_with_background + c + 1
301 }
302 _nms.run();
303
304 for(unsigned int i = 0; i < _info.detection_per_class(); ++i)
305 {
306 const auto selected_index = *(reinterpret_cast<int *>(_selected_indices.ptr_to_element(Coordinates(i))));
307 if(selected_index == -1)
308 {
309 // Nms will return -1 for all the last M-elements not valid
310 continue;
311 }
312 _result_idx_boxes_after_nms.emplace_back(selected_index);
313 _result_scores_after_nms.emplace_back((reinterpret_cast<float *>(_class_scores.buffer()))[selected_index]);
314 _result_classes_after_nms.emplace_back(c);
315 }
316 }
317
318 // We select the max detection numbers of the highest score of all classes
319 const auto num_selected = _result_idx_boxes_after_nms.size();
320 const auto num_output = std::min<unsigned int>(max_detections, num_selected);
321
322 // Sort selected indices based on result scores
323 std::iota(_sorted_indices.begin(), _sorted_indices.end(), 0);
324 std::partial_sort(_sorted_indices.data(),
325 _sorted_indices.data() + num_output,
326 _sorted_indices.data() + num_selected,
327 [&](unsigned int first, unsigned int second)
328 {
329
330 return _result_scores_after_nms[first] > _result_scores_after_nms[second];
331 });
332
333 SaveOutputs(&_decoded_boxes, _result_idx_boxes_after_nms, _result_scores_after_nms, _result_classes_after_nms,
334 _sorted_indices, num_output, max_detections, _output_boxes, _output_classes, _output_scores, _num_detection);
335 }
336 // Fast NMS
337 else
338 {
339 const unsigned int num_classes_per_box = std::min<unsigned int>(_info.max_classes_per_detection(), _info.num_classes());
340 for(unsigned int b = 0, index = 0; b < _num_boxes; ++b)
341 {
342 _box_scores.clear();
343 _sorted_indices.clear();
344 for(unsigned int c = 0; c < num_classes; ++c)
345 {
346 _box_scores.emplace_back(*(reinterpret_cast<float *>(_input_scores_to_use->ptr_to_element(Coordinates(c + 1, b)))));
347 _sorted_indices.push_back(c);
348 }
349 std::partial_sort(_sorted_indices.data(),
350 _sorted_indices.data() + num_classes_per_box,
351 _sorted_indices.data() + num_classes,
352 [&](unsigned int first, unsigned int second)
353 {
354 return _box_scores[first] > _box_scores[second];
355 });
356
357 for(unsigned int i = 0; i < num_classes_per_box; ++i, ++index)
358 {
359 const float score_to_add = _box_scores[_sorted_indices[i]];
360 *(reinterpret_cast<float *>(_class_scores.ptr_to_element(Coordinates(index)))) = score_to_add;
361 _result_scores_after_nms.emplace_back(score_to_add);
362 _result_idx_boxes_after_nms.emplace_back(b);
363 _result_classes_after_nms.emplace_back(_sorted_indices[i]);
364 }
365 }
366
367 // Run NMS
368 _nms.run();
369
370 _sorted_indices.clear();
371 for(unsigned int i = 0; i < max_detections; ++i)
372 {
373 // NMS returns M valid indices, the not valid tail is filled with -1
374 if(*(reinterpret_cast<int *>(_selected_indices.ptr_to_element(Coordinates(i)))) == -1)
375 {
376 // Nms will return -1 for all the last M-elements not valid
377 break;
378 }
379 _sorted_indices.emplace_back(*(reinterpret_cast<int *>(_selected_indices.ptr_to_element(Coordinates(i)))));
380 }
381 // We select the max detection numbers of the highest score of all classes
382 const auto num_output = std::min<unsigned int>(_info.max_detections(), _sorted_indices.size());
383
384 SaveOutputs(&_decoded_boxes, _result_idx_boxes_after_nms, _result_scores_after_nms, _result_classes_after_nms,
385 _sorted_indices, num_output, max_detections, _output_boxes, _output_classes, _output_scores, _num_detection);
386 }
387}
388} // namespace arm_compute