Compute Library
 21.02
NEROIAlignLayerKernel.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 
28 #include "arm_compute/core/Utils.h"
33 #include "src/core/CPP/Validate.h"
36 
37 #include <arm_neon.h>
38 
40 
41 namespace arm_compute
42 {
43 namespace
44 {
45 Status validate_arguments(const ITensorInfo *input, const ITensorInfo *rois, ITensorInfo *output, const ROIPoolingLayerInfo &pool_info)
46 {
47  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, rois, output);
48  ARM_COMPUTE_RETURN_ERROR_ON(rois->dimension(0) != 5);
49  ARM_COMPUTE_RETURN_ERROR_ON(rois->num_dimensions() > 2);
52  ARM_COMPUTE_RETURN_ERROR_ON((pool_info.pooled_width() == 0) || (pool_info.pooled_height() == 0));
54 
55  if(output->total_size() != 0)
56  {
59  ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(compute_roi_align_shape(*input, *rois, pool_info), output->tensor_shape());
60  }
61 
62  if(input->data_type() == DataType::QASYMM8 || input->data_type() == DataType::QASYMM8_SIGNED)
63  {
65 
66  const UniformQuantizationInfo rois_qinfo = rois->quantization_info().uniform();
67  ARM_COMPUTE_RETURN_ERROR_ON(rois_qinfo.scale != 0.125f);
68  ARM_COMPUTE_RETURN_ERROR_ON(rois_qinfo.offset != 0);
69  }
70  else
71  {
73  }
74 
75  return Status{};
76 }
77 } // namespace
78 
80  : _input(nullptr), _output(nullptr), _rois(nullptr), _pool_info(0, 0, 0.f)
81 {
82 }
83 
84 void NEROIAlignLayerKernel::configure(const ITensor *input, const ITensor *rois, ITensor *output, const ROIPoolingLayerInfo &pool_info)
85 {
86  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, rois);
87  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), rois->info(), output->info(), pool_info));
88  // Output auto inizialitation if not yet initialized
89  const TensorShape output_shape = compute_roi_align_shape(*input->info(), *rois->info(), pool_info);
90  auto_init_if_empty((*output->info()), output_shape, 1, input->info()->data_type(), input->info()->quantization_info());
91  output->info()->set_data_layout(input->info()->data_layout());
92 
93  // Configure kernel window
94  const unsigned int num_rois = rois->info()->dimension(1);
95  Window window;
96  window.set(Window::DimX, Window::Dimension(0, num_rois));
97  window.set(Window::DimY, Window::Dimension(0, 1));
98 
99  Coordinates coord;
100  coord.set_num_dimensions(output->info()->num_dimensions());
101  output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
102 
103  // Set instance variables
104  _input = input;
105  _rois = rois;
106  _output = output;
107  _pool_info = pool_info;
108 
109  INEKernel::configure(window);
110 }
111 
113 {
114  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, rois, output, pool_info));
115  return Status{};
116 }
117 
118 /** Average pooling over an aligned window */
119 template <typename input_data_type>
120 inline input_data_type roi_align_1x1(const ITensor *input,
121  unsigned int roi_batch,
122  float region_start_x,
123  float bin_size_x,
124  int grid_size_x,
125  float region_end_x,
126  float region_start_y,
127  float bin_size_y,
128  int grid_size_y,
129  float region_end_y,
130  int pz)
131 {
132  if((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
133  {
134  return input_data_type(0);
135  }
136  else
137  {
138  const DataLayout data_layout = input->info()->data_layout();
139  float avg = 0;
140  // Iterate through the aligned pooling region
141  for(int iy = 0; iy < grid_size_y; ++iy)
142  {
143  for(int ix = 0; ix < grid_size_x; ++ix)
144  {
145  // Align the window in the middle of every bin
146  float y = region_start_y + (iy + 0.5) * bin_size_y / float(grid_size_y);
147  float x = region_start_x + (ix + 0.5) * bin_size_x / float(grid_size_x);
148 
149  // Interpolation in the [0,0] [0,1] [1,0] [1,1] square
150  const int y_low = y;
151  const int x_low = x;
152  const int y_high = y_low + 1;
153  const int x_high = x_low + 1;
154 
155  const float ly = y - y_low;
156  const float lx = x - x_low;
157  const float hy = 1. - ly;
158  const float hx = 1. - lx;
159 
160  const float w1 = hy * hx;
161  const float w2 = hy * lx;
162  const float w3 = ly * hx;
163  const float w4 = ly * lx;
164  if(data_layout == DataLayout::NCHW)
165  {
166  const auto data1 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_low, pz, roi_batch)));
167  const auto data2 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_low, pz, roi_batch)));
168  const auto data3 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_high, pz, roi_batch)));
169  const auto data4 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_high, pz, roi_batch)));
170  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
171  }
172  else
173  {
174  const auto data1 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_low, roi_batch)));
175  const auto data2 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_low, roi_batch)));
176  const auto data3 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_high, roi_batch)));
177  const auto data4 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_high, roi_batch)));
178  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
179  }
180  }
181  }
182 
183  avg /= grid_size_x * grid_size_y;
184  return input_data_type(avg);
185  }
186 }
187 
188 /** Average pooling over an aligned window */
189 template <typename input_data_type>
190 inline input_data_type roi_align_1x1_qasymm8(const ITensor *input,
191  unsigned int roi_batch,
192  float region_start_x,
193  float bin_size_x,
194  int grid_size_x,
195  float region_end_x,
196  float region_start_y,
197  float bin_size_y,
198  int grid_size_y,
199  float region_end_y,
200  int pz,
201  const QuantizationInfo &out_qinfo)
202 {
203  if((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
204  {
205  return input_data_type(out_qinfo.uniform().offset);
206  }
207  else
208  {
209  float avg = 0;
210  const UniformQuantizationInfo input_qinfo = input->info()->quantization_info().uniform();
211  const bool is_qasymm_signed = is_data_type_quantized_asymmetric_signed(input->info()->data_type());
212  const DataLayout data_layout = input->info()->data_layout();
213 
214  // Iterate through the aligned pooling region
215  for(int iy = 0; iy < grid_size_y; ++iy)
216  {
217  for(int ix = 0; ix < grid_size_x; ++ix)
218  {
219  // Align the window in the middle of every bin
220  float y = region_start_y + (iy + 0.5) * bin_size_y / float(grid_size_y);
221  float x = region_start_x + (ix + 0.5) * bin_size_x / float(grid_size_x);
222 
223  // Interpolation in the [0,0] [0,1] [1,0] [1,1] square
224  const int y_low = y;
225  const int x_low = x;
226  const int y_high = y_low + 1;
227  const int x_high = x_low + 1;
228 
229  const float ly = y - y_low;
230  const float lx = x - x_low;
231  const float hy = 1. - ly;
232  const float hx = 1. - lx;
233 
234  const float w1 = hy * hx;
235  const float w2 = hy * lx;
236  const float w3 = ly * hx;
237  const float w4 = ly * lx;
238 
239  if(data_layout == DataLayout::NCHW)
240  {
241  if(is_qasymm_signed)
242  {
243  float data1 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_low, pz, roi_batch))), input_qinfo);
244  float data2 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_low, pz, roi_batch))), input_qinfo);
245  float data3 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_high, pz, roi_batch))), input_qinfo);
246  float data4 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_high, pz, roi_batch))), input_qinfo);
247  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
248  }
249  else
250  {
251  float data1 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_low, pz, roi_batch))), input_qinfo);
252  float data2 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_low, pz, roi_batch))), input_qinfo);
253  float data3 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_high, pz, roi_batch))), input_qinfo);
254  float data4 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_high, pz, roi_batch))), input_qinfo);
255  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
256  }
257  }
258  else
259  {
260  if(is_qasymm_signed)
261  {
262  const auto data1 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_low, roi_batch))), input_qinfo);
263  const auto data2 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_low, roi_batch))), input_qinfo);
264  const auto data3 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_high, roi_batch))), input_qinfo);
265  const auto data4 = dequantize_qasymm8_signed(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_high, roi_batch))), input_qinfo);
266  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
267  }
268  else
269  {
270  const auto data1 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_low, roi_batch))), input_qinfo);
271  const auto data2 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_low, roi_batch))), input_qinfo);
272  const auto data3 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_high, roi_batch))), input_qinfo);
273  const auto data4 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_high, roi_batch))), input_qinfo);
274  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
275  }
276  }
277  }
278  }
279 
280  avg /= grid_size_x * grid_size_y;
281 
282  input_data_type res = 0;
283  if(is_qasymm_signed)
284  {
285  res = quantize_qasymm8_signed(avg, out_qinfo);
286  }
287  else
288  {
289  res = quantize_qasymm8(avg, out_qinfo);
290  }
291  return res;
292  }
293 }
294 
295 inline float compute_region_coordinate(int p, float bin_size, float roi_anchor, float max_value)
296 {
297  const float region_start = p * bin_size + roi_anchor;
298  return utility::clamp(region_start, 0.0f, max_value);
299 }
300 
302 {
303  const DataLayout data_layout = _input->info()->data_layout();
304  if(data_layout == DataLayout::NCHW || data_layout == DataLayout::NHWC)
305  {
306  switch(_input->info()->data_type())
307  {
308  case DataType::QASYMM8:
309  {
310  NEROIAlignLayerKernel::internal_run<uint8_t, uint16_t>(window, info);
311  break;
312  }
314  {
315  NEROIAlignLayerKernel::internal_run<int8_t, uint16_t>(window, info);
316  break;
317  }
318  case DataType::F32:
319  {
320  NEROIAlignLayerKernel::internal_run<float>(window, info);
321  break;
322  }
323 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
324  case DataType::F16:
325  {
326  NEROIAlignLayerKernel::internal_run<float16_t>(window, info);
327  break;
328  }
329 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
330  default:
331  {
332  ARM_COMPUTE_ERROR("DataType not supported");
333  break;
334  }
335  }
336  }
337  else
338  {
339  ARM_COMPUTE_ERROR("Invalid layout");
340  }
341 }
342 
343 template <typename input_data_type, typename roi_data_type>
344 void NEROIAlignLayerKernel::internal_run(const Window &window, const ThreadInfo &info)
345 {
346  ARM_COMPUTE_UNUSED(info);
349 
350  const DataLayout data_layout = _input->info()->data_layout();
351  const size_t values_per_roi = _rois->info()->dimension(0);
352 
353  const int roi_list_start = window.x().start();
354  const int roi_list_end = window.x().end();
355 
356  const unsigned int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
358  const unsigned int idx_depth = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
359 
360  const int input_width = _input->info()->dimension(idx_width);
361  const int input_height = _input->info()->dimension(idx_height);
362  const int input_chanels = _input->info()->dimension(idx_depth);
363  const int pooled_w = _pool_info.pooled_width();
364  const int pooled_h = _pool_info.pooled_height();
365 
366  const DataType data_type = _input->info()->data_type();
367  const bool is_qasymm = is_data_type_quantized_asymmetric(data_type);
368 
369  const auto *rois_ptr = reinterpret_cast<const roi_data_type *>(_rois->buffer());
370  const QuantizationInfo &rois_qinfo = _rois->info()->quantization_info();
371  for(int roi_indx = roi_list_start; roi_indx < roi_list_end; ++roi_indx)
372  {
373  const unsigned int roi_batch = rois_ptr[values_per_roi * roi_indx];
374 
375  roi_data_type qx1 = rois_ptr[values_per_roi * roi_indx + 1];
376  roi_data_type qy1 = rois_ptr[values_per_roi * roi_indx + 2];
377  roi_data_type qx2 = rois_ptr[values_per_roi * roi_indx + 3];
378  roi_data_type qy2 = rois_ptr[values_per_roi * roi_indx + 4];
379  float x1(qx1);
380  float x2(qx2);
381  float y1(qy1);
382  float y2(qy2);
383  if(is_qasymm)
384  {
385  x1 = dequantize_qasymm16(qx1, rois_qinfo);
386  x2 = dequantize_qasymm16(qx2, rois_qinfo);
387  y1 = dequantize_qasymm16(qy1, rois_qinfo);
388  y2 = dequantize_qasymm16(qy2, rois_qinfo);
389  }
390  const float roi_anchor_x = x1 * _pool_info.spatial_scale();
391  const float roi_anchor_y = y1 * _pool_info.spatial_scale();
392  const float roi_dims_x = std::max((x2 - x1) * _pool_info.spatial_scale(), 1.0f);
393  const float roi_dims_y = std::max((y2 - y1) * _pool_info.spatial_scale(), 1.0f);
394  float bin_size_x = roi_dims_x / _pool_info.pooled_width();
395  float bin_size_y = roi_dims_y / _pool_info.pooled_height();
396 
397  // Iterate through all feature maps
398  for(int ch = 0; ch < input_chanels; ++ch)
399  {
400  // Iterate through all output pixels
401  for(int py = 0; py < pooled_h; ++py)
402  {
403  for(int px = 0; px < pooled_w; ++px)
404  {
405  const float region_start_x = compute_region_coordinate(px, bin_size_x, roi_anchor_x, input_width);
406  const float region_start_y = compute_region_coordinate(py, bin_size_y, roi_anchor_y, input_height);
407  const float region_end_x = compute_region_coordinate(px + 1, bin_size_x, roi_anchor_x, input_width);
408  const float region_end_y = compute_region_coordinate(py + 1, bin_size_y, roi_anchor_y, input_height);
409  const int roi_bin_grid_x = (_pool_info.sampling_ratio() > 0) ? _pool_info.sampling_ratio() : int(ceil(bin_size_x));
410  const int roi_bin_grid_y = (_pool_info.sampling_ratio() > 0) ? _pool_info.sampling_ratio() : int(ceil(bin_size_y));
411  input_data_type out_val(0);
412  if(is_qasymm)
413  {
414  out_val = roi_align_1x1_qasymm8<input_data_type>(
415  _input, roi_batch, region_start_x, bin_size_x,
416  roi_bin_grid_x, region_end_x, region_start_y, bin_size_y,
417  roi_bin_grid_y, region_end_y, ch, _output->info()->quantization_info());
418  }
419  else
420  {
421  out_val = roi_align_1x1<input_data_type>(
422  _input, roi_batch, region_start_x, bin_size_x,
423  roi_bin_grid_x, region_end_x, region_start_y, bin_size_y,
424  roi_bin_grid_y, region_end_y, ch);
425  }
426 
427  if(data_layout == DataLayout::NCHW)
428  {
429  auto out_ptr = reinterpret_cast<input_data_type *>(_output->ptr_to_element(Coordinates(px, py, ch, roi_indx)));
430  *out_ptr = out_val;
431  }
432  else
433  {
434  auto out_ptr = reinterpret_cast<input_data_type *>(_output->ptr_to_element(Coordinates(ch, px, py, roi_indx)));
435  *out_ptr = out_val;
436  }
437  }
438  }
439  }
440  }
441 }
442 } // namespace arm_compute
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
input_data_type roi_align_1x1(const ITensor *input, unsigned int roi_batch, float region_start_x, float bin_size_x, int grid_size_x, float region_end_x, float region_start_y, float bin_size_y, int grid_size_y, float region_end_y, int pz)
Average pooling over an aligned window.
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
Definition: ITensor.h:63
Shape of a tensor.
Definition: TensorShape.h:39
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_LAYOUT_NOT_IN(t,...)
Definition: Validate.h:746
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
Definition: Validate.h:494
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
Definition: Validate.h:108
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
TensorShape compute_roi_align_shape(const ITensorInfo &input, const ITensorInfo &rois, ROIPoolingLayerInfo pool_info)
Calculate the output roi align shape of a tensor.
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#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.
1 channel, 1 F32 per channel
const DataLayout data_layout
Definition: Im2Col.cpp:151
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Quantization info when assuming per layer quantization.
Describe one of the image&#39;s dimensions with a start, end and step.
Definition: Window.h:77
quantized, asymmetric fixed-point 16-bit number
unsigned int pooled_width() const
Get the pooled width of the layer.
Definition: Types.h:1324
Status class.
Definition: Error.h:52
float compute_region_coordinate(int p, float bin_size, float roi_anchor, float max_value)
#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
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
Definition: Validate.h:288
Copyright (c) 2017-2021 Arm Limited.
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
DataType clamp(const DataType &n, const DataType &lower=std::numeric_limits< RangeType >::lowest(), const DataType &upper=std::numeric_limits< RangeType >::max())
Performs clamping among a lower and upper value.
Definition: Utility.h:99
float dequantize_qasymm16(uint16_t value, const UniformQuantizationInfo &qinfo)
Dequantize a value given a 16-bit asymmetric quantization scheme.
const DataType data_type
Definition: Im2Col.cpp:150
Quantization information.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
virtual ITensorInfo & set_data_layout(const DataLayout &data_layout)=0
Set the data layout of the tensor.
int8_t quantize_qasymm8_signed(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a signed 8-bit asymmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number unsigned
Coordinates of an item.
Definition: Coordinates.h:37
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory. ...
UniformQuantizationInfo uniform() const
Return per layer quantization info.
bool is_data_type_quantized_asymmetric_signed(DataType dt)
Check if a given data type is of asymmetric quantized signed type.
Definition: Utils.h:1209
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...
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
unsigned int sampling_ratio() const
Get sampling ratio.
Definition: Types.h:1339
Num samples, channels, height, width.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1190
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Information about executing thread and CPU.
Definition: CPPTypes.h:235
input_data_type roi_align_1x1_qasymm8(const ITensor *input, unsigned int roi_batch, float region_start_x, float bin_size_x, int grid_size_x, float region_end_x, float region_start_y, float bin_size_y, int grid_size_y, float region_end_y, int pz, const QuantizationInfo &out_qinfo)
Average pooling over an aligned window.
unsigned int pooled_height() const
Get the pooled height of the layer.
Definition: Types.h:1329
ROI Pooling Layer Information class.
Definition: Types.h:1309
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
Num samples, height, width, channels.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
float spatial_scale() const
Get the spatial scale.
Definition: Types.h:1334
float dequantize_qasymm8_signed(int8_t value, const INFO_TYPE &qinfo)
Dequantize a value given a signed 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
void set_num_dimensions(size_t num_dimensions)
Set number of dimensions.
Definition: Dimensions.h:149
quantized, asymmetric fixed-point 8-bit number signed
Container for valid region of a window.
Definition: Types.h:188
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:193
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
DataType
Available data types.
Definition: Types.h:77
DataLayout
[DataLayout enum definition]
Definition: Types.h:120
void configure(const ITensor *input, const ITensor *rois, ITensor *output, const ROIPoolingLayerInfo &pool_info)
Set the input and output tensors.
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:94
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
static Status validate(const ITensorInfo *input, const ITensorInfo *rois, ITensorInfo *output, const ROIPoolingLayerInfo &pool_info)
Static function to check if given info will lead to a valid configuration of NEROIAlignLayerKernel.
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145