24.02.1
|
Go to the documentation of this file.
42 const ITensorInfo *rois,
43 const ITensorInfo *output,
44 const ROIPoolingLayerInfo &pool_info)
55 if (output->total_size() != 0)
59 (output->dimension(1) != pool_info.pooled_height()));
82 void template_eval(
const ITensor *
input,
83 const ITensor *output,
94 if ((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
96 *
reinterpret_cast<T *
>(output->ptr_to_element(Coordinates(px, py, fm, roi_indx))) = 0;
101 for (
int j = region_start_y; j < region_end_y; ++j)
103 for (
int i = region_start_x; i < region_end_x; ++i)
105 const auto val = *
reinterpret_cast<const T *
>(
input->ptr_to_element(Coordinates(i, j, fm, roi_batch)));
106 curr_max = std::max(val, curr_max);
115 input->info()->quantization_info().uniform(), output->info()->quantization_info().uniform());
116 *
reinterpret_cast<T *
>(output->ptr_to_element(Coordinates(px, py, fm, roi_indx))) =
121 *
reinterpret_cast<T *
>(output->ptr_to_element(Coordinates(px, py, fm, roi_indx))) = curr_max;
128 : _input(nullptr), _rois(nullptr), _output(nullptr), _pool_info(0, 0, 0.f)
166 _pool_info = pool_info;
173 INEKernel::configure(
window);
193 const auto *rois_ptr =
reinterpret_cast<const uint16_t *
>(_rois->
buffer());
196 for (
int roi_indx = roi_list_start; roi_indx < roi_list_end; ++roi_indx)
198 const unsigned int roi_batch = rois_ptr[values_per_roi * roi_indx];
199 const auto x1 = rois_ptr[values_per_roi * roi_indx + 1];
200 const auto y1 = rois_ptr[values_per_roi * roi_indx + 2];
201 const auto x2 = rois_ptr[values_per_roi * roi_indx + 3];
202 const auto y2 = rois_ptr[values_per_roi * roi_indx + 4];
211 for (
int fm = 0; fm < fms; ++fm)
214 for (
int py = 0; py < pooled_h; ++py)
216 for (
int px = 0; px < pooled_w; ++px)
218 auto region_start_x =
static_cast<int>(std::floor((
static_cast<float>(px) / pooled_w) * roi_width));
220 static_cast<int>(std::floor((
static_cast<float>(px + 1) / pooled_w) * roi_width));
221 auto region_start_y =
222 static_cast<int>(std::floor((
static_cast<float>(py) / pooled_h) * roi_height));
224 static_cast<int>(std::floor((
static_cast<float>(py + 1) / pooled_h) * roi_height));
226 region_start_x = std::min(std::max(region_start_x + roi_anchor_x, 0), width);
227 region_end_x = std::min(std::max(region_end_x + roi_anchor_x, 0), width);
228 region_start_y = std::min(std::max(region_start_y + roi_anchor_y, 0), height);
229 region_end_y = std::min(std::max(region_end_y + roi_anchor_y, 0), height);
234 template_eval<float>(_input, _output, region_start_x, region_start_y, region_end_x,
235 region_end_y, fm, px, py, roi_batch, roi_indx);
238 template_eval<qasymm8_t>(_input, _output, region_start_x, region_start_y, region_end_x,
239 region_end_y, fm, px, py, roi_batch, roi_indx);
constexpr int start() const
Return the start of the dimension.
unsigned int pooled_width() const
Get the pooled width of the layer.
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
@ U16
unsigned 16-bit number
T round(T value)
Round floating-point value with half value rounding away from zero.
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
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.
Interface for CPU tensor.
unsigned int pooled_height() const
Get the pooled height of the layer.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void configure(const ITensor *input, const ITensor *rois, const ITensor *output, const ROIPoolingLayerInfo &pool_info)
Set the input and output tensors.
UniformQuantizationInfo compute_requantization_scale_offset(const UniformQuantizationInfo &uqinfo_in, const UniformQuantizationInfo &uqinfo_out)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(t,...)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
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...
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Describe one of the image's dimensions with a start, end and step.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
const Window & window() const
The maximum window the kernel can be executed on.
Information about executing thread and CPU.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Describe a multidimensional execution window.
Copyright (c) 2017-2024 Arm Limited.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
float spatial_scale() const
Get the spatial scale.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
NEROIPoolingLayerKernel()
Default constructor.
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Store the tensor's metadata.
@ F32
32-bit floating-point number
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
constexpr int end() const
Return the end of the dimension.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
ROI Pooling Layer Information class.
static Status validate(const ITensorInfo *input, const ITensorInfo *rois, const ITensorInfo *output, const ROIPoolingLayerInfo &pool_info)
Static function to check if given info will lead to a valid configuration of NEROIPoolingLayerKernel.
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory.