Compute Library
 21.08
NEROIAlignLayerKernel Class Reference

Interface for the RoIAlign kernel. More...

#include <NEROIAlignLayerKernel.h>

Collaboration diagram for NEROIAlignLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEROIAlignLayerKernel ()
 Constructor. More...
 
 NEROIAlignLayerKernel (const NEROIAlignLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEROIAlignLayerKerneloperator= (const NEROIAlignLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEROIAlignLayerKernel (NEROIAlignLayerKernel &&)=default
 Default Move Constructor. More...
 
NEROIAlignLayerKerneloperator= (NEROIAlignLayerKernel &&)=default
 Default move assignment operator. More...
 
 ~NEROIAlignLayerKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, const ITensor *rois, ITensor *output, const ROIPoolingLayerInfo &pool_info)
 Set the input and output tensors. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Static Public Member Functions

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. More...
 

Detailed Description

Interface for the RoIAlign kernel.

Definition at line 35 of file NEROIAlignLayerKernel.h.

Constructor & Destructor Documentation

◆ NEROIAlignLayerKernel() [1/3]

Constructor.

Definition at line 78 of file NEROIAlignLayerKernel.cpp.

Referenced by NEROIAlignLayerKernel::name().

79  : _input(nullptr), _output(nullptr), _rois(nullptr), _pool_info(0, 0, 0.f)
80 {
81 }

◆ NEROIAlignLayerKernel() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEROIAlignLayerKernel() [3/3]

Default Move Constructor.

◆ ~NEROIAlignLayerKernel()

~NEROIAlignLayerKernel ( )
default

Default destructor.

Referenced by NEROIAlignLayerKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
const ITensor rois,
ITensor output,
const ROIPoolingLayerInfo pool_info 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]roisROIs tensor, it is a 2D tensor of size [5, N] (where N is the number of ROIs) containing top left and bottom right corner as coordinate of an image and batch_id of ROI [ batch_id, x1, y1, x2, y2 ]. Data types supported: QASYMM16 with scale of 0.125 and 0 offset if input is QASYMM8/QASYMM8_SIGNED, otherwise same as input
[out]outputDestination tensor. Data types supported: Same as input.
[in]pool_infoContains pooling operation information described in ROIPoolingLayerInfo.
Note
The x and y dimensions of output tensor must be the same as pool_info 's pooled width and pooled height.
The z dimensions of output tensor and input tensor must be the same.
The fourth dimension of output tensor must be the same as the number of elements in rois array.

Definition at line 83 of file NEROIAlignLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::misc::shape_calculator::compute_roi_align_shape(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, Window::DimY, ITensor::info(), arm_compute::test::validation::input, arm_compute::test::validation::output_shape, ITensorInfo::quantization_info(), Window::set(), ITensorInfo::set_data_layout(), and IKernel::window().

Referenced by NEROIAlignLayerKernel::name().

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 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
TensorShape compute_roi_align_shape(const ITensorInfo &input, const ITensorInfo &rois, ROIPoolingLayerInfo pool_info)
Calculate the output roi align shape of a tensor.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
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...
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
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:157

◆ name()

◆ operator=() [1/2]

NEROIAlignLayerKernel& operator= ( const NEROIAlignLayerKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers)

Referenced by NEROIAlignLayerKernel::name().

◆ operator=() [2/2]

NEROIAlignLayerKernel& operator= ( NEROIAlignLayerKernel &&  )
default

Default move assignment operator.

◆ run()

void run ( const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Reimplemented from ICPPKernel.

Definition at line 296 of file NEROIAlignLayerKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensor::buffer(), arm_compute::CHANNEL, arm_compute::compute_region_coordinate(), arm_compute::test::validation::data_layout, ITensorInfo::data_layout(), arm_compute::test::validation::data_type, ITensorInfo::data_type(), arm_compute::dequantize_qasymm16(), ITensorInfo::dimension(), Window::Dimension::end(), arm_compute::F16, arm_compute::F32, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::test::validation::idx_height, arm_compute::test::validation::idx_width, ITensor::info(), arm_compute::test::validation::info, input_height, input_width, arm_compute::is_data_type_quantized_asymmetric(), arm_compute::NCHW, arm_compute::NHWC, ROIPoolingLayerInfo::pooled_height(), ROIPoolingLayerInfo::pooled_width(), ITensor::ptr_to_element(), arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, ITensorInfo::quantization_info(), ROIPoolingLayerInfo::sampling_ratio(), ROIPoolingLayerInfo::spatial_scale(), Window::Dimension::start(), arm_compute::WIDTH, IKernel::window(), and Window::x().

Referenced by NEROIAlignLayerKernel::name().

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 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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
1 channel, 1 F16 per channel
quantized, asymmetric fixed-point 8-bit number unsigned
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
Num samples, channels, height, width.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Num samples, height, width, channels.
quantized, asymmetric fixed-point 8-bit number signed
DataLayout
[DataLayout enum definition]
Definition: Types.h:111
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo rois,
ITensorInfo output,
const ROIPoolingLayerInfo pool_info 
)
static

Static function to check if given info will lead to a valid configuration of NEROIAlignLayerKernel.

Parameters
[in]inputSource tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]roisROIs tensor info. Data types supported: QASYMM16 with scale of 0.125 and 0 offset if input is QASYMM8/QASYMM8_SIGNED, otherwise same as input
[in]outputDestination tensor info. Data types supported: Same as input.
[in]pool_infoContains pooling operation information described in ROIPoolingLayerInfo.
Note
The x and y dimensions of output tensor must be the same as pool_info 's pooled width and pooled height.
The z dimensions of output tensor and input tensor must be the same.
The fourth dimension of output tensor must be the same as the number of elements in rois array.
Returns
a Status

Definition at line 107 of file NEROIAlignLayerKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NEROIAlignLayerKernel::name(), and NEROIAlignLayer::validate().

108 {
109  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, rois, output, pool_info));
110  return Status{};
111 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

The documentation for this class was generated from the following files: