39 : _input(nullptr), _rois(nullptr), _output(nullptr), _pool_info(0, 0, 0.f)
75 _pool_info = pool_info;
86 INEKernel::configure(window);
97 const int roi_list_start = window.
x().
start();
98 const int roi_list_end = window.
x().
end();
106 const auto *rois_ptr =
reinterpret_cast<const uint16_t *
>(_rois->
buffer());
108 for(
int roi_indx = roi_list_start; roi_indx < roi_list_end; ++roi_indx)
110 const unsigned int roi_batch = rois_ptr[values_per_roi * roi_indx];
111 const auto x1 = rois_ptr[values_per_roi * roi_indx + 1];
112 const auto y1 = rois_ptr[values_per_roi * roi_indx + 2];
113 const auto x2 = rois_ptr[values_per_roi * roi_indx + 3];
114 const auto y2 = rois_ptr[values_per_roi * roi_indx + 4];
123 for(
int fm = 0; fm < fms; ++fm)
126 for(
int py = 0; py < pooled_h; ++py)
128 for(
int px = 0; px < pooled_w; ++px)
130 auto region_start_x =
static_cast<int>(std::floor((static_cast<float>(px) / pooled_w) * roi_width));
131 auto region_end_x =
static_cast<int>(std::floor((static_cast<float>(px + 1) / pooled_w) * roi_width));
132 auto region_start_y =
static_cast<int>(std::floor((static_cast<float>(py) / pooled_h) * roi_height));
133 auto region_end_y =
static_cast<int>(std::floor((static_cast<float>(py + 1) / pooled_h) * roi_height));
135 region_start_x = std::min(std::max(region_start_x + roi_anchor_x, 0), width);
136 region_end_x = std::min(std::max(region_end_x + roi_anchor_x, 0), width);
137 region_start_y = std::min(std::max(region_start_y + roi_anchor_y, 0), height);
138 region_end_y = std::min(std::max(region_end_y + roi_anchor_y, 0), height);
141 if((region_end_x <= region_start_x) || (region_end_y <= region_start_y))
147 float curr_max = -FLT_MAX;
148 for(
int j = region_start_y; j < region_end_y; ++j)
150 for(
int i = region_start_x; i < region_end_x; ++i)
153 curr_max = std::max(val, curr_max);
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
const Window & window() const
The maximum window the kernel can be executed on.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Describe one of the image's dimensions with a start, end and step.
1 channel, 1 U16 per channel
unsigned int pooled_width() const
Get the pooled width of the layer.
Interface for Neon tensor.
Copyright (c) 2017-2021 Arm Limited.
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
#define ARM_COMPUTE_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory. ...
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's metadata.
void configure(const ITensor *input, const ITensor *rois, ITensor *output, const ROIPoolingLayerInfo &pool_info)
Set the input and output tensors.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
unsigned int pooled_height() const
Get the pooled height of the layer.
ROI Pooling Layer Information class.
T round(T value)
Round floating-point value with half value rounding away from zero.
float spatial_scale() const
Get the spatial scale.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
NEROIPoolingLayerKernel()
Default constructor.
void set_num_dimensions(size_t num_dimensions)
Set number of dimensions.
Container for valid region of a window.
constexpr int end() const
Return the end of the dimension.
constexpr int start() const
Return the start of the dimension.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.