Compute Library
 21.11
NEROIAlignLayerKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019-2021 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"
32 #include "src/core/CPP/Validate.h"
35 
36 #include <arm_neon.h>
37 
39 
40 namespace arm_compute
41 {
42 namespace
43 {
44 Status validate_arguments(const ITensorInfo *input, const ITensorInfo *rois, ITensorInfo *output, const ROIPoolingLayerInfo &pool_info)
45 {
46  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, rois, output);
47  ARM_COMPUTE_RETURN_ERROR_ON(rois->dimension(0) != 5);
48  ARM_COMPUTE_RETURN_ERROR_ON(rois->num_dimensions() > 2);
51  ARM_COMPUTE_RETURN_ERROR_ON((pool_info.pooled_width() == 0) || (pool_info.pooled_height() == 0));
53 
54  if(output->total_size() != 0)
55  {
58  ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(compute_roi_align_shape(*input, *rois, pool_info), output->tensor_shape());
59  }
60 
61  if(input->data_type() == DataType::QASYMM8 || input->data_type() == DataType::QASYMM8_SIGNED)
62  {
64 
65  const UniformQuantizationInfo rois_qinfo = rois->quantization_info().uniform();
66  ARM_COMPUTE_RETURN_ERROR_ON(rois_qinfo.scale != 0.125f);
67  ARM_COMPUTE_RETURN_ERROR_ON(rois_qinfo.offset != 0);
68  }
69  else
70  {
72  }
73 
74  return Status{};
75 }
76 } // namespace
77 
79  : _input(nullptr), _output(nullptr), _rois(nullptr), _pool_info(0, 0, 0.f)
80 {
81 }
82 
83 void NEROIAlignLayerKernel::configure(const ITensor *input, const ITensor *rois, ITensor *output, const ROIPoolingLayerInfo &pool_info)
84 {
85  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, rois);
86  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), rois->info(), output->info(), pool_info));
87  // Output auto inizialitation if not yet initialized
88  const TensorShape output_shape = compute_roi_align_shape(*input->info(), *rois->info(), pool_info);
89  auto_init_if_empty((*output->info()), output_shape, 1, input->info()->data_type(), input->info()->quantization_info());
90  output->info()->set_data_layout(input->info()->data_layout());
91 
92  // Configure kernel window
93  const unsigned int num_rois = rois->info()->dimension(1);
94  Window window;
95  window.set(Window::DimX, Window::Dimension(0, num_rois));
96  window.set(Window::DimY, Window::Dimension(0, 1));
97 
98  // Set instance variables
99  _input = input;
100  _rois = rois;
101  _output = output;
102  _pool_info = pool_info;
103 
104  INEKernel::configure(window);
105 }
106 
108 {
109  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, rois, output, pool_info));
110  return Status{};
111 }
112 
113 /** Average pooling over an aligned window */
114 template <typename input_data_type>
115 inline input_data_type roi_align_1x1(const ITensor *input,
116  unsigned int roi_batch,
117  float region_start_x,
118  float bin_size_x,
119  int grid_size_x,
120  float region_end_x,
121  float region_start_y,
122  float bin_size_y,
123  int grid_size_y,
124  float region_end_y,
125  int pz)
126 {
127  if((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
128  {
129  return input_data_type(0);
130  }
131  else
132  {
133  const DataLayout data_layout = input->info()->data_layout();
134  float avg = 0;
135  // Iterate through the aligned pooling region
136  for(int iy = 0; iy < grid_size_y; ++iy)
137  {
138  for(int ix = 0; ix < grid_size_x; ++ix)
139  {
140  // Align the window in the middle of every bin
141  float y = region_start_y + (iy + 0.5) * bin_size_y / float(grid_size_y);
142  float x = region_start_x + (ix + 0.5) * bin_size_x / float(grid_size_x);
143 
144  // Interpolation in the [0,0] [0,1] [1,0] [1,1] square
145  const int y_low = y;
146  const int x_low = x;
147  const int y_high = y_low + 1;
148  const int x_high = x_low + 1;
149 
150  const float ly = y - y_low;
151  const float lx = x - x_low;
152  const float hy = 1. - ly;
153  const float hx = 1. - lx;
154 
155  const float w1 = hy * hx;
156  const float w2 = hy * lx;
157  const float w3 = ly * hx;
158  const float w4 = ly * lx;
159  if(data_layout == DataLayout::NCHW)
160  {
161  const auto data1 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_low, pz, roi_batch)));
162  const auto data2 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_low, pz, roi_batch)));
163  const auto data3 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_high, pz, roi_batch)));
164  const auto data4 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_high, pz, roi_batch)));
165  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
166  }
167  else
168  {
169  const auto data1 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_low, roi_batch)));
170  const auto data2 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_low, roi_batch)));
171  const auto data3 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_low, y_high, roi_batch)));
172  const auto data4 = *reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(pz, x_high, y_high, roi_batch)));
173  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
174  }
175  }
176  }
177 
178  avg /= grid_size_x * grid_size_y;
179  return input_data_type(avg);
180  }
181 }
182 
183 /** Average pooling over an aligned window */
184 template <typename input_data_type>
185 inline input_data_type roi_align_1x1_qasymm8(const ITensor *input,
186  unsigned int roi_batch,
187  float region_start_x,
188  float bin_size_x,
189  int grid_size_x,
190  float region_end_x,
191  float region_start_y,
192  float bin_size_y,
193  int grid_size_y,
194  float region_end_y,
195  int pz,
196  const QuantizationInfo &out_qinfo)
197 {
198  if((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
199  {
200  return input_data_type(out_qinfo.uniform().offset);
201  }
202  else
203  {
204  float avg = 0;
205  const UniformQuantizationInfo input_qinfo = input->info()->quantization_info().uniform();
206  const bool is_qasymm_signed = is_data_type_quantized_asymmetric_signed(input->info()->data_type());
207  const DataLayout data_layout = input->info()->data_layout();
208 
209  // Iterate through the aligned pooling region
210  for(int iy = 0; iy < grid_size_y; ++iy)
211  {
212  for(int ix = 0; ix < grid_size_x; ++ix)
213  {
214  // Align the window in the middle of every bin
215  float y = region_start_y + (iy + 0.5) * bin_size_y / float(grid_size_y);
216  float x = region_start_x + (ix + 0.5) * bin_size_x / float(grid_size_x);
217 
218  // Interpolation in the [0,0] [0,1] [1,0] [1,1] square
219  const int y_low = y;
220  const int x_low = x;
221  const int y_high = y_low + 1;
222  const int x_high = x_low + 1;
223 
224  const float ly = y - y_low;
225  const float lx = x - x_low;
226  const float hy = 1. - ly;
227  const float hx = 1. - lx;
228 
229  const float w1 = hy * hx;
230  const float w2 = hy * lx;
231  const float w3 = ly * hx;
232  const float w4 = ly * lx;
233 
234  if(data_layout == DataLayout::NCHW)
235  {
236  if(is_qasymm_signed)
237  {
238  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);
239  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);
240  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);
241  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);
242  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
243  }
244  else
245  {
246  float data1 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_low, pz, roi_batch))), input_qinfo);
247  float data2 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_low, pz, roi_batch))), input_qinfo);
248  float data3 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_low, y_high, pz, roi_batch))), input_qinfo);
249  float data4 = dequantize_qasymm8(*reinterpret_cast<const input_data_type *>(input->ptr_to_element(Coordinates(x_high, y_high, pz, roi_batch))), input_qinfo);
250  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
251  }
252  }
253  else
254  {
255  if(is_qasymm_signed)
256  {
257  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);
258  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);
259  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);
260  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);
261  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
262  }
263  else
264  {
265  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);
266  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);
267  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);
268  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);
269  avg += w1 * data1 + w2 * data2 + w3 * data3 + w4 * data4;
270  }
271  }
272  }
273  }
274 
275  avg /= grid_size_x * grid_size_y;
276 
277  input_data_type res = 0;
278  if(is_qasymm_signed)
279  {
280  res = quantize_qasymm8_signed(avg, out_qinfo);
281  }
282  else
283  {
284  res = quantize_qasymm8(avg, out_qinfo);
285  }
286  return res;
287  }
288 }
289 
290 inline float compute_region_coordinate(int p, float bin_size, float roi_anchor, float max_value)
291 {
292  const float region_start = p * bin_size + roi_anchor;
293  return utility::clamp(region_start, 0.0f, max_value);
294 }
295 
297 {
298  const DataLayout data_layout = _input->info()->data_layout();
299  if(data_layout == DataLayout::NCHW || data_layout == DataLayout::NHWC)
300  {
301  switch(_input->info()->data_type())
302  {
303  case DataType::QASYMM8:
304  {
305  NEROIAlignLayerKernel::internal_run<uint8_t, uint16_t>(window, info);
306  break;
307  }
309  {
310  NEROIAlignLayerKernel::internal_run<int8_t, uint16_t>(window, info);
311  break;
312  }
313  case DataType::F32:
314  {
315  NEROIAlignLayerKernel::internal_run<float>(window, info);
316  break;
317  }
318 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
319  case DataType::F16:
320  {
321  NEROIAlignLayerKernel::internal_run<float16_t>(window, info);
322  break;
323  }
324 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
325  default:
326  {
327  ARM_COMPUTE_ERROR("DataType not supported");
328  break;
329  }
330  }
331  }
332  else
333  {
334  ARM_COMPUTE_ERROR("Invalid layout");
335  }
336 }
337 
338 template <typename input_data_type, typename roi_data_type>
339 void NEROIAlignLayerKernel::internal_run(const Window &window, const ThreadInfo &info)
340 {
341  ARM_COMPUTE_UNUSED(info);
344 
345  const DataLayout data_layout = _input->info()->data_layout();
346  const size_t values_per_roi = _rois->info()->dimension(0);
347 
348  const int roi_list_start = window.x().start();
349  const int roi_list_end = window.x().end();
350 
351  const unsigned int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
353  const unsigned int idx_depth = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
354 
355  const int input_width = _input->info()->dimension(idx_width);
356  const int input_height = _input->info()->dimension(idx_height);
357  const int input_chanels = _input->info()->dimension(idx_depth);
358  const int pooled_w = _pool_info.pooled_width();
359  const int pooled_h = _pool_info.pooled_height();
360 
361  const DataType data_type = _input->info()->data_type();
362  const bool is_qasymm = is_data_type_quantized_asymmetric(data_type);
363 
364  const auto *rois_ptr = reinterpret_cast<const roi_data_type *>(_rois->buffer());
365  const QuantizationInfo &rois_qinfo = _rois->info()->quantization_info();
366  for(int roi_indx = roi_list_start; roi_indx < roi_list_end; ++roi_indx)
367  {
368  const unsigned int roi_batch = rois_ptr[values_per_roi * roi_indx];
369 
370  roi_data_type qx1 = rois_ptr[values_per_roi * roi_indx + 1];
371  roi_data_type qy1 = rois_ptr[values_per_roi * roi_indx + 2];
372  roi_data_type qx2 = rois_ptr[values_per_roi * roi_indx + 3];
373  roi_data_type qy2 = rois_ptr[values_per_roi * roi_indx + 4];
374  float x1(qx1);
375  float x2(qx2);
376  float y1(qy1);
377  float y2(qy2);
378  if(is_qasymm)
379  {
380  x1 = dequantize_qasymm16(qx1, rois_qinfo);
381  x2 = dequantize_qasymm16(qx2, rois_qinfo);
382  y1 = dequantize_qasymm16(qy1, rois_qinfo);
383  y2 = dequantize_qasymm16(qy2, rois_qinfo);
384  }
385  const float roi_anchor_x = x1 * _pool_info.spatial_scale();
386  const float roi_anchor_y = y1 * _pool_info.spatial_scale();
387  const float roi_dims_x = std::max((x2 - x1) * _pool_info.spatial_scale(), 1.0f);
388  const float roi_dims_y = std::max((y2 - y1) * _pool_info.spatial_scale(), 1.0f);
389  float bin_size_x = roi_dims_x / _pool_info.pooled_width();
390  float bin_size_y = roi_dims_y / _pool_info.pooled_height();
391 
392  // Iterate through all feature maps
393  for(int ch = 0; ch < input_chanels; ++ch)
394  {
395  // Iterate through all output pixels
396  for(int py = 0; py < pooled_h; ++py)
397  {
398  for(int px = 0; px < pooled_w; ++px)
399  {
400  const float region_start_x = compute_region_coordinate(px, bin_size_x, roi_anchor_x, input_width);
401  const float region_start_y = compute_region_coordinate(py, bin_size_y, roi_anchor_y, input_height);
402  const float region_end_x = compute_region_coordinate(px + 1, bin_size_x, roi_anchor_x, input_width);
403  const float region_end_y = compute_region_coordinate(py + 1, bin_size_y, roi_anchor_y, input_height);
404  const int roi_bin_grid_x = (_pool_info.sampling_ratio() > 0) ? _pool_info.sampling_ratio() : int(ceil(bin_size_x));
405  const int roi_bin_grid_y = (_pool_info.sampling_ratio() > 0) ? _pool_info.sampling_ratio() : int(ceil(bin_size_y));
406  input_data_type out_val(0);
407  if(is_qasymm)
408  {
409  out_val = roi_align_1x1_qasymm8<input_data_type>(
410  _input, roi_batch, region_start_x, bin_size_x,
411  roi_bin_grid_x, region_end_x, region_start_y, bin_size_y,
412  roi_bin_grid_y, region_end_y, ch, _output->info()->quantization_info());
413  }
414  else
415  {
416  out_val = roi_align_1x1<input_data_type>(
417  _input, roi_batch, region_start_x, bin_size_x,
418  roi_bin_grid_x, region_end_x, region_start_y, bin_size_y,
419  roi_bin_grid_y, region_end_y, ch);
420  }
421 
422  if(data_layout == DataLayout::NCHW)
423  {
424  auto out_ptr = reinterpret_cast<input_data_type *>(_output->ptr_to_element(Coordinates(px, py, ch, roi_indx)));
425  *out_ptr = out_val;
426  }
427  else
428  {
429  auto out_ptr = reinterpret_cast<input_data_type *>(_output->ptr_to_element(Coordinates(ch, px, py, roi_indx)));
430  *out_ptr = out_val;
431  }
432  }
433  }
434  }
435  }
436 }
437 } // namespace arm_compute
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:742
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
Definition: Validate.h:490
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
Definition: Validate.h:115
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
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:1283
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 CPU tensor.
Definition: ITensor.h:36
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
Definition: Validate.h:284
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
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:101
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.
const size_t input_width
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 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:1022
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:915
unsigned int sampling_ratio() const
Get sampling ratio.
Definition: Types.h:1298
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:1003
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:158
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:1288
ROI Pooling Layer Information class.
Definition: Types.h:1268
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
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:541
Num samples, height, width, channels.
const size_t input_height
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:788
float spatial_scale() const
Get the spatial scale.
Definition: Types.h:1293
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:157
quantized, asymmetric fixed-point 8-bit number signed
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
DataType
Available data types.
Definition: Types.h:79
DataLayout
[DataLayout enum definition]
Definition: Types.h:113
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:201
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