Compute Library
 20.08
NEGenerateProposalsLayer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2020 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  */
25 
26 #include "arm_compute/core/Types.h"
28 
29 namespace arm_compute
30 {
31 NEGenerateProposalsLayer::NEGenerateProposalsLayer(std::shared_ptr<IMemoryManager> memory_manager)
32  : _memory_group(memory_manager),
33  _permute_deltas_kernel(),
34  _flatten_deltas(),
35  _permute_scores_kernel(),
36  _flatten_scores(),
37  _compute_anchors_kernel(),
38  _bounding_box_kernel(),
39  _pad_kernel(),
40  _dequantize_anchors(),
41  _dequantize_deltas(),
42  _quantize_all_proposals(),
43  _cpp_nms(memory_manager),
44  _is_nhwc(false),
45  _is_qasymm8(false),
46  _deltas_permuted(),
47  _deltas_flattened(),
48  _deltas_flattened_f32(),
49  _scores_permuted(),
50  _scores_flattened(),
51  _all_anchors(),
52  _all_anchors_f32(),
53  _all_proposals(),
54  _all_proposals_quantized(),
55  _keeps_nms_unused(),
56  _classes_nms_unused(),
57  _proposals_4_roi_values(),
58  _all_proposals_to_use(nullptr),
59  _num_valid_proposals(nullptr),
60  _scores_out(nullptr)
61 {
62 }
63 
64 void NEGenerateProposalsLayer::configure(const ITensor *scores, const ITensor *deltas, const ITensor *anchors, ITensor *proposals, ITensor *scores_out, ITensor *num_valid_proposals,
66 {
67  ARM_COMPUTE_ERROR_ON_NULLPTR(scores, deltas, anchors, proposals, scores_out, num_valid_proposals);
68  ARM_COMPUTE_ERROR_THROW_ON(NEGenerateProposalsLayer::validate(scores->info(), deltas->info(), anchors->info(), proposals->info(), scores_out->info(), num_valid_proposals->info(), info));
69 
70  _is_nhwc = scores->info()->data_layout() == DataLayout::NHWC;
71  const DataType scores_data_type = scores->info()->data_type();
72  _is_qasymm8 = scores_data_type == DataType::QASYMM8;
73  const int num_anchors = scores->info()->dimension(get_data_layout_dimension_index(scores->info()->data_layout(), DataLayoutDimension::CHANNEL));
74  const int feat_width = scores->info()->dimension(get_data_layout_dimension_index(scores->info()->data_layout(), DataLayoutDimension::WIDTH));
75  const int feat_height = scores->info()->dimension(get_data_layout_dimension_index(scores->info()->data_layout(), DataLayoutDimension::HEIGHT));
76  const int total_num_anchors = num_anchors * feat_width * feat_height;
77  const int pre_nms_topN = info.pre_nms_topN();
78  const int post_nms_topN = info.post_nms_topN();
79  const size_t values_per_roi = info.values_per_roi();
80 
81  const QuantizationInfo scores_qinfo = scores->info()->quantization_info();
82  const DataType rois_data_type = (_is_qasymm8) ? DataType::QASYMM16 : scores_data_type;
83  const QuantizationInfo rois_qinfo = (_is_qasymm8) ? QuantizationInfo(0.125f, 0) : scores->info()->quantization_info();
84 
85  // Compute all the anchors
86  _memory_group.manage(&_all_anchors);
87  _compute_anchors_kernel.configure(anchors, &_all_anchors, ComputeAnchorsInfo(feat_width, feat_height, info.spatial_scale()));
88 
89  const TensorShape flatten_shape_deltas(values_per_roi, total_num_anchors);
90  _deltas_flattened.allocator()->init(TensorInfo(flatten_shape_deltas, 1, scores_data_type, deltas->info()->quantization_info()));
91 
92  // Permute and reshape deltas
93  _memory_group.manage(&_deltas_flattened);
94  if(!_is_nhwc)
95  {
96  _memory_group.manage(&_deltas_permuted);
97  _permute_deltas_kernel.configure(deltas, &_deltas_permuted, PermutationVector{ 2, 0, 1 });
98  _flatten_deltas.configure(&_deltas_permuted, &_deltas_flattened);
99  _deltas_permuted.allocator()->allocate();
100  }
101  else
102  {
103  _flatten_deltas.configure(deltas, &_deltas_flattened);
104  }
105 
106  const TensorShape flatten_shape_scores(1, total_num_anchors);
107  _scores_flattened.allocator()->init(TensorInfo(flatten_shape_scores, 1, scores_data_type, scores_qinfo));
108 
109  // Permute and reshape scores
110  _memory_group.manage(&_scores_flattened);
111  if(!_is_nhwc)
112  {
113  _memory_group.manage(&_scores_permuted);
114  _permute_scores_kernel.configure(scores, &_scores_permuted, PermutationVector{ 2, 0, 1 });
115  _flatten_scores.configure(&_scores_permuted, &_scores_flattened);
116  _scores_permuted.allocator()->allocate();
117  }
118  else
119  {
120  _flatten_scores.configure(scores, &_scores_flattened);
121  }
122 
123  Tensor *anchors_to_use = &_all_anchors;
124  Tensor *deltas_to_use = &_deltas_flattened;
125  if(_is_qasymm8)
126  {
127  _all_anchors_f32.allocator()->init(TensorInfo(_all_anchors.info()->tensor_shape(), 1, DataType::F32));
128  _deltas_flattened_f32.allocator()->init(TensorInfo(_deltas_flattened.info()->tensor_shape(), 1, DataType::F32));
129  _memory_group.manage(&_all_anchors_f32);
130  _memory_group.manage(&_deltas_flattened_f32);
131  // Dequantize anchors to float
132  _dequantize_anchors.configure(&_all_anchors, &_all_anchors_f32);
133  _all_anchors.allocator()->allocate();
134  anchors_to_use = &_all_anchors_f32;
135  // Dequantize deltas to float
136  _dequantize_deltas.configure(&_deltas_flattened, &_deltas_flattened_f32);
137  _deltas_flattened.allocator()->allocate();
138  deltas_to_use = &_deltas_flattened_f32;
139  }
140  // Bounding box transform
141  _memory_group.manage(&_all_proposals);
142  BoundingBoxTransformInfo bbox_info(info.im_width(), info.im_height(), 1.f);
143  _bounding_box_kernel.configure(anchors_to_use, &_all_proposals, deltas_to_use, bbox_info);
144  deltas_to_use->allocator()->allocate();
145  anchors_to_use->allocator()->allocate();
146 
147  _all_proposals_to_use = &_all_proposals;
148  if(_is_qasymm8)
149  {
150  _memory_group.manage(&_all_proposals_quantized);
151  // Requantize all_proposals to QASYMM16 with 0.125 scale and 0 offset
152  _all_proposals_quantized.allocator()->init(TensorInfo(_all_proposals.info()->tensor_shape(), 1, DataType::QASYMM16, QuantizationInfo(0.125f, 0)));
153  _quantize_all_proposals.configure(&_all_proposals, &_all_proposals_quantized);
154  _all_proposals.allocator()->allocate();
155  _all_proposals_to_use = &_all_proposals_quantized;
156  }
157  // The original layer implementation first selects the best pre_nms_topN anchors (thus having a lightweight sort)
158  // that are then transformed by bbox_transform. The boxes generated are then fed into a non-sorting NMS operation.
159  // Since we are reusing the NMS layer and we don't implement any CL/sort, we let NMS do the sorting (of all the input)
160  // and the filtering
161  const int scores_nms_size = std::min<int>(std::min<int>(post_nms_topN, pre_nms_topN), total_num_anchors);
162  const float min_size_scaled = info.min_size() * info.im_scale();
163  _memory_group.manage(&_classes_nms_unused);
164  _memory_group.manage(&_keeps_nms_unused);
165 
166  // Note that NMS needs outputs preinitialized.
167  auto_init_if_empty(*scores_out->info(), TensorShape(scores_nms_size), 1, scores_data_type, scores_qinfo);
168  auto_init_if_empty(*_proposals_4_roi_values.info(), TensorShape(values_per_roi, scores_nms_size), 1, rois_data_type, rois_qinfo);
169  auto_init_if_empty(*num_valid_proposals->info(), TensorShape(1), 1, DataType::U32);
170 
171  // Initialize temporaries (unused) outputs
172  _classes_nms_unused.allocator()->init(TensorInfo(TensorShape(scores_nms_size), 1, scores_data_type, scores_qinfo));
173  _keeps_nms_unused.allocator()->init(*scores_out->info());
174 
175  // Save the output (to map and unmap them at run)
176  _scores_out = scores_out;
177  _num_valid_proposals = num_valid_proposals;
178 
179  _memory_group.manage(&_proposals_4_roi_values);
180 
181  const BoxNMSLimitInfo box_nms_info(0.0f, info.nms_thres(), scores_nms_size, false, NMSType::LINEAR, 0.5f, 0.001f, true, min_size_scaled, info.im_width(), info.im_height());
182  _cpp_nms.configure(&_scores_flattened /*scores_in*/,
183  _all_proposals_to_use /*boxes_in,*/,
184  nullptr /* batch_splits_in*/,
185  scores_out /* scores_out*/,
186  &_proposals_4_roi_values /*boxes_out*/,
187  &_classes_nms_unused /*classes*/,
188  nullptr /*batch_splits_out*/,
189  &_keeps_nms_unused /*keeps*/,
190  num_valid_proposals /* keeps_size*/,
191  box_nms_info);
192 
193  _keeps_nms_unused.allocator()->allocate();
194  _classes_nms_unused.allocator()->allocate();
195  _all_proposals_to_use->allocator()->allocate();
196  _scores_flattened.allocator()->allocate();
197 
198  // Add the first column that represents the batch id. This will be all zeros, as we don't support multiple images
199  _pad_kernel.configure(&_proposals_4_roi_values, proposals, PaddingList{ { 1, 0 } });
200  _proposals_4_roi_values.allocator()->allocate();
201 }
202 
203 Status NEGenerateProposalsLayer::validate(const ITensorInfo *scores, const ITensorInfo *deltas, const ITensorInfo *anchors, const ITensorInfo *proposals, const ITensorInfo *scores_out,
204  const ITensorInfo *num_valid_proposals, const GenerateProposalsInfo &info)
205 {
206  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(scores, deltas, anchors, proposals, scores_out, num_valid_proposals);
211 
212  const int num_anchors = scores->dimension(get_data_layout_dimension_index(scores->data_layout(), DataLayoutDimension::CHANNEL));
213  const int feat_width = scores->dimension(get_data_layout_dimension_index(scores->data_layout(), DataLayoutDimension::WIDTH));
214  const int feat_height = scores->dimension(get_data_layout_dimension_index(scores->data_layout(), DataLayoutDimension::HEIGHT));
215  const int num_images = scores->dimension(3);
216  const int total_num_anchors = num_anchors * feat_width * feat_height;
217  const int values_per_roi = info.values_per_roi();
218 
219  const bool is_qasymm8 = scores->data_type() == DataType::QASYMM8;
220 
221  ARM_COMPUTE_RETURN_ERROR_ON(num_images > 1);
222 
223  if(is_qasymm8)
224  {
226  const UniformQuantizationInfo anchors_qinfo = anchors->quantization_info().uniform();
227  ARM_COMPUTE_RETURN_ERROR_ON(anchors_qinfo.scale != 0.125f);
228  }
229 
230  TensorInfo all_anchors_info(anchors->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true));
231  ARM_COMPUTE_RETURN_ON_ERROR(NEComputeAllAnchorsKernel::validate(anchors, &all_anchors_info, ComputeAnchorsInfo(feat_width, feat_height, info.spatial_scale())));
232 
233  TensorInfo deltas_permuted_info = deltas->clone()->set_tensor_shape(TensorShape(values_per_roi * num_anchors, feat_width, feat_height)).set_is_resizable(true);
234  TensorInfo scores_permuted_info = scores->clone()->set_tensor_shape(TensorShape(num_anchors, feat_width, feat_height)).set_is_resizable(true);
235  if(scores->data_layout() == DataLayout::NHWC)
236  {
237  ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(deltas, &deltas_permuted_info);
238  ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(scores, &scores_permuted_info);
239  }
240  else
241  {
242  ARM_COMPUTE_RETURN_ON_ERROR(NEPermuteKernel::validate(deltas, &deltas_permuted_info, PermutationVector{ 2, 0, 1 }));
243  ARM_COMPUTE_RETURN_ON_ERROR(NEPermuteKernel::validate(scores, &scores_permuted_info, PermutationVector{ 2, 0, 1 }));
244  }
245 
246  TensorInfo deltas_flattened_info(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true));
247  ARM_COMPUTE_RETURN_ON_ERROR(NEReshapeLayer::validate(&deltas_permuted_info, &deltas_flattened_info));
248 
249  TensorInfo scores_flattened_info(scores->clone()->set_tensor_shape(TensorShape(1, total_num_anchors)).set_is_resizable(true));
250  TensorInfo proposals_4_roi_values(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true));
251 
252  ARM_COMPUTE_RETURN_ON_ERROR(NEReshapeLayer::validate(&scores_permuted_info, &scores_flattened_info));
253 
254  TensorInfo *proposals_4_roi_values_to_use = &proposals_4_roi_values;
255  TensorInfo proposals_4_roi_values_quantized(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true));
256  proposals_4_roi_values_quantized.set_data_type(DataType::QASYMM16).set_quantization_info(QuantizationInfo(0.125f, 0));
257  if(is_qasymm8)
258  {
259  TensorInfo all_anchors_f32_info(anchors->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true).set_data_type(DataType::F32));
260  ARM_COMPUTE_RETURN_ON_ERROR(NEDequantizationLayerKernel::validate(&all_anchors_info, &all_anchors_f32_info));
261 
262  TensorInfo deltas_flattened_f32_info(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true).set_data_type(DataType::F32));
263  ARM_COMPUTE_RETURN_ON_ERROR(NEDequantizationLayerKernel::validate(&deltas_flattened_info, &deltas_flattened_f32_info));
264 
265  TensorInfo proposals_4_roi_values_f32(deltas->clone()->set_tensor_shape(TensorShape(values_per_roi, total_num_anchors)).set_is_resizable(true).set_data_type(DataType::F32));
266  ARM_COMPUTE_RETURN_ON_ERROR(NEBoundingBoxTransformKernel::validate(&all_anchors_f32_info, &proposals_4_roi_values_f32, &deltas_flattened_f32_info,
267  BoundingBoxTransformInfo(info.im_width(), info.im_height(), 1.f)));
268 
269  ARM_COMPUTE_RETURN_ON_ERROR(NEQuantizationLayerKernel::validate(&proposals_4_roi_values_f32, &proposals_4_roi_values_quantized));
270  proposals_4_roi_values_to_use = &proposals_4_roi_values_quantized;
271  }
272  else
273  {
274  ARM_COMPUTE_RETURN_ON_ERROR(NEBoundingBoxTransformKernel::validate(&all_anchors_info, &proposals_4_roi_values, &deltas_flattened_info,
275  BoundingBoxTransformInfo(info.im_width(), info.im_height(), 1.f)));
276  }
277 
278  ARM_COMPUTE_RETURN_ON_ERROR(NEPadLayerKernel::validate(proposals_4_roi_values_to_use, proposals, PaddingList{ { 1, 0 } }));
279 
280  if(num_valid_proposals->total_size() > 0)
281  {
282  ARM_COMPUTE_RETURN_ERROR_ON(num_valid_proposals->num_dimensions() > 1);
283  ARM_COMPUTE_RETURN_ERROR_ON(num_valid_proposals->dimension(0) > 1);
285  }
286 
287  if(proposals->total_size() > 0)
288  {
290  ARM_COMPUTE_RETURN_ERROR_ON(proposals->dimension(0) != size_t(values_per_roi) + 1);
291  ARM_COMPUTE_RETURN_ERROR_ON(proposals->dimension(1) != size_t(total_num_anchors));
292  if(is_qasymm8)
293  {
295  const UniformQuantizationInfo proposals_qinfo = proposals->quantization_info().uniform();
296  ARM_COMPUTE_RETURN_ERROR_ON(proposals_qinfo.scale != 0.125f);
297  ARM_COMPUTE_RETURN_ERROR_ON(proposals_qinfo.offset != 0);
298  }
299  else
300  {
302  }
303  }
304 
305  if(scores_out->total_size() > 0)
306  {
307  ARM_COMPUTE_RETURN_ERROR_ON(scores_out->num_dimensions() > 1);
308  ARM_COMPUTE_RETURN_ERROR_ON(scores_out->dimension(0) != size_t(total_num_anchors));
310  }
311 
312  return Status{};
313 }
314 
316 {
317  // Acquire all the temporaries
318  MemoryGroupResourceScope scope_mg(_memory_group);
319 
320  // Compute all the anchors
321  NEScheduler::get().schedule(&_compute_anchors_kernel, Window::DimY);
322 
323  // Transpose and reshape the inputs
324  if(!_is_nhwc)
325  {
326  NEScheduler::get().schedule(&_permute_deltas_kernel, Window::DimY);
327  NEScheduler::get().schedule(&_permute_scores_kernel, Window::DimY);
328  }
329 
330  _flatten_deltas.run();
331  _flatten_scores.run();
332 
333  if(_is_qasymm8)
334  {
335  NEScheduler::get().schedule(&_dequantize_anchors, Window::DimY);
336  NEScheduler::get().schedule(&_dequantize_deltas, Window::DimY);
337  }
338 
339  // Build the boxes
340  NEScheduler::get().schedule(&_bounding_box_kernel, Window::DimY);
341 
342  if(_is_qasymm8)
343  {
344  NEScheduler::get().schedule(&_quantize_all_proposals, Window::DimY);
345  }
346 
347  // Non maxima suppression
348  _cpp_nms.run();
349 
350  // Add dummy batch indexes
351  NEScheduler::get().schedule(&_pad_kernel, Window::DimY);
352 }
353 } // namespace arm_compute
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
Generate Proposals Information class.
Definition: Types.h:1319
Shape of a tensor.
Definition: TensorShape.h:39
void configure(const ITensor *input, ITensor *output)
Set input, output tensors.
quantized, symmetric fixed-point 16-bit number
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
std::vector< PaddingInfo > PaddingList
List of padding information.
Definition: Types.h:458
void configure(const ITensor *input, ITensor *output)
Set the input, output.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
Definition: Validate.h:494
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEReshapeLayer.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
BoxWithNonMaximaSuppressionLimit Information class.
Definition: Types.h:593
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
virtual DataType data_type() const =0
Data type used for each element of the tensor.
void run() override
Run the kernels contained in the function.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
1 channel, 1 F32 per channel
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEQuantizationLayerKerne...
ITensorInfo & set_data_type(DataType data_type) override
Set the data type to the specified value.
Definition: TensorInfo.cpp:319
void configure(const ITensor *input, ITensor *output, const PermutationVector &perm)
Set the input and output of the kernel.
void configure(const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, const BoundingBoxTransformInfo &info)
Set the input and output tensors.
void run() override
Run the kernels contained in the function.
Store the tensor's metadata.
Definition: ITensorInfo.h:40
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Quantization info when assuming per layer quantization.
quantized, asymmetric fixed-point 16-bit number
static Status validate(const ITensorInfo *anchors, const ITensorInfo *all_anchors, const ComputeAnchorsInfo &info)
Static function to check if given info will lead to a valid configuration of NEComputeAllAnchorsKerne...
Status class.
Definition: Error.h:52
void configure(const ITensor *anchors, ITensor *all_anchors, const ComputeAnchorsInfo &info)
Set the input and output tensors.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
Interface for NEON tensor.
Definition: ITensor.h:36
static Status validate(const ITensorInfo *scores, const ITensorInfo *deltas, const ITensorInfo *anchors, const ITensorInfo *proposals, const ITensorInfo *scores_out, const ITensorInfo *num_valid_proposals, const GenerateProposalsInfo &info)
Static function to check if given info will lead to a valid configuration of NEGenerateProposalsLayer...
Copyright (c) 2017-2020 Arm Limited.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:207
1 channel, 1 F16 per channel
TensorAllocator * allocator()
Return a pointer to the tensor's allocator.
Definition: Tensor.cpp:48
ITensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: Tensor.cpp:33
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
Definition: MemoryGroup.h:79
Quantization information.
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEDequantizationLayerKer...
1 channel, 1 U32 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:443
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
void configure(const ITensor *scores, const ITensor *deltas, const ITensor *anchors, ITensor *proposals, ITensor *scores_out, ITensor *num_valid_proposals, const GenerateProposalsInfo &info)
Set the input and output tensors.
quantized, asymmetric fixed-point 8-bit number unsigned
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
Basic implementation of the tensor interface.
Definition: Tensor.h:37
virtual ITensorInfo & set_quantization_info(const QuantizationInfo &quantization_info)=0
Set the quantization settings (scale and offset) of the tensor.
Bounding Box Transform information class.
Definition: Types.h:1450
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, const PixelValue constant_value=PixelValue(), const PaddingMode mode=PaddingMode::CONSTANT)
Static function to check if given info will lead to a valid configuration of NEPadLayer.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
Num samples, channels, height, width.
static Status validate(const ITensorInfo *boxes, const ITensorInfo *pred_boxes, const ITensorInfo *deltas, const BoundingBoxTransformInfo &info)
Static function to check if given info will lead to a valid configuration of CLBoundingBoxTransform.
NEGenerateProposalsLayer(std::shared_ptr< IMemoryManager > memory_manager=nullptr)
Default constructor.
Strides of an item in bytes.
Definition: Strides.h:37
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Memory group resources scope handling class.
Definition: IMemoryGroup.h:82
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PermutationVector &perm)
Static function to check if given info will lead to a valid configuration of CPPPermuteKernel.
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
void configure(ITensor *input, ITensor *output, const PaddingList &padding, const PixelValue constant_value=PixelValue(), const PaddingMode mode=PaddingMode::CONSTANT)
Initialize the function.
ComputeAnchors information class.
Definition: Types.h:1400
Num samples, height, width, channels.
void configure(const ITensor *input, ITensor *output)
Initialise the kernel's inputs and outputs.
Store the tensor's metadata.
Definition: TensorInfo.h:45
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:332
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(t,...)
Definition: Validate.h:746
DataType
Available data types.
Definition: Types.h:77
void run() override
Run the kernels contained in the function.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:95
void configure(const ITensor *scores_in, const ITensor *boxes_in, const ITensor *batch_splits_in, ITensor *scores_out, ITensor *boxes_out, ITensor *classes, ITensor *batch_splits_out=nullptr, ITensor *keeps=nullptr, ITensor *keeps_size=nullptr, const BoxNMSLimitInfo info=BoxNMSLimitInfo())
Configure the BoxWithNonMaximaSuppressionLimit CPP kernel.