Compute Library
 21.02
NEComputeAllAnchorsKernel Class Reference

Interface for Compute All Anchors kernel. More...

#include <NEGenerateProposalsLayerKernel.h>

Collaboration diagram for NEComputeAllAnchorsKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEComputeAllAnchorsKernel ()
 Default constructor. More...
 
 NEComputeAllAnchorsKernel (const NEComputeAllAnchorsKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEComputeAllAnchorsKerneloperator= (const NEComputeAllAnchorsKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEComputeAllAnchorsKernel (NEComputeAllAnchorsKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEComputeAllAnchorsKerneloperator= (NEComputeAllAnchorsKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEComputeAllAnchorsKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *anchors, ITensor *all_anchors, const ComputeAnchorsInfo &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...
 

Static Public Member Functions

static Status validate (const ITensorInfo *anchors, const ITensorInfo *all_anchors, const ComputeAnchorsInfo &info)
 Static function to check if given info will lead to a valid configuration of NEComputeAllAnchorsKernel. More...
 

Detailed Description

Interface for Compute All Anchors kernel.

Definition at line 33 of file NEGenerateProposalsLayerKernel.h.

Constructor & Destructor Documentation

◆ NEComputeAllAnchorsKernel() [1/3]

Default constructor.

Definition at line 68 of file NEGenerateProposalsLayerKernel.cpp.

Referenced by NEComputeAllAnchorsKernel::name().

69  : _anchors(nullptr), _all_anchors(nullptr), _anchors_info(0.f, 0.f, 0.f)
70 {
71 }

◆ NEComputeAllAnchorsKernel() [2/3]

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

◆ NEComputeAllAnchorsKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEComputeAllAnchorsKernel()

Default destructor.

Referenced by NEComputeAllAnchorsKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor anchors,
ITensor all_anchors,
const ComputeAnchorsInfo info 
)

Set the input and output tensors.

Parameters
[in]anchorsSource tensor. Original set of anchors of size (4, A), where A is the number of anchors. Data types supported: QSYMM16/F16/F32
[out]all_anchorsDestination tensor. Destination anchors of size (4, H*W*A) where H and W are the height and width of the feature map and A is the number of anchors. Data types supported: Same as input
[in]infoContains Compute Anchors operation information described in ComputeAnchorsInfo

Definition at line 73 of file NEGenerateProposalsLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), arm_compute::test::validation::data_type, ITensorInfo::data_type(), ITensorInfo::dimension(), ComputeAnchorsInfo::feat_height(), ComputeAnchorsInfo::feat_width(), ITensor::info(), arm_compute::test::validation::info, arm_compute::test::validation::output_shape, ITensorInfo::quantization_info(), arm_compute::validate_arguments(), and ComputeAnchorsInfo::values_per_roi().

Referenced by NEComputeAllAnchorsKernel::name().

74 {
75  ARM_COMPUTE_ERROR_ON_NULLPTR(anchors, all_anchors);
76  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(anchors->info(), all_anchors->info(), info));
77 
78  // Metadata
79  const size_t num_anchors = anchors->info()->dimension(1);
80  const DataType data_type = anchors->info()->data_type();
81  const float width = info.feat_width();
82  const float height = info.feat_height();
83 
84  // Initialize the output if empty
85  const TensorShape output_shape(info.values_per_roi(), width * height * num_anchors);
86  auto_init_if_empty(*all_anchors->info(), TensorInfo(output_shape, 1, data_type, anchors->info()->quantization_info()));
87 
88  // Set instance variables
89  _anchors = anchors;
90  _all_anchors = all_anchors;
91  _anchors_info = info;
92 
93  Window win = calculate_max_window(*all_anchors->info(), Steps(info.values_per_roi()));
94 
95  INEKernel::configure(win);
96 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
const DataType data_type
Definition: Im2Col.cpp:150
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...
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
DataType
Available data types.
Definition: Types.h:77

◆ name()

◆ operator=() [1/2]

NEComputeAllAnchorsKernel& operator= ( const NEComputeAllAnchorsKernel )
delete

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

Referenced by NEComputeAllAnchorsKernel::name().

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ 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 169 of file NEGenerateProposalsLayerKernel.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_type(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::QSYMM16, and IKernel::window().

Referenced by NEComputeAllAnchorsKernel::name().

170 {
174 
175  switch(_anchors->info()->data_type())
176  {
177  case DataType::QSYMM16:
178  {
179  internal_run<int16_t>(window);
180  break;
181  }
182 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
183  case DataType::F16:
184  {
185  internal_run<float16_t>(window);
186  break;
187  }
188 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
189  case DataType::F32:
190  {
191  internal_run<float>(window);
192  break;
193  }
194  default:
195  {
196  ARM_COMPUTE_ERROR("Data type not supported");
197  }
198  }
199 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
quantized, symmetric fixed-point 16-bit number
#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
1 channel, 1 F16 per channel
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205

◆ validate()

Status validate ( const ITensorInfo anchors,
const ITensorInfo all_anchors,
const ComputeAnchorsInfo info 
)
static

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

Parameters
[in]anchorsSource tensor info. Original set of anchors of size (4, A), where A is the number of anchors. Data types supported: QSYMM16/F16/F32
[in]all_anchorsDestination tensor info. Destination anchors of size (4, H*W*A) where H and W are the height and width of the feature map and A is the number of anchors. Data types supported: Same as input
[in]infoContains Compute Anchors operation information described in ComputeAnchorsInfo
Returns
a Status

Definition at line 98 of file NEGenerateProposalsLayerKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::dequantize_qsymm16(), ITensorInfo::dimension(), arm_compute::execute_window_loop(), ComputeAnchorsInfo::feat_width(), ITensor::info(), Iterator::ptr(), ITensor::ptr_to_element(), arm_compute::test::validation::qinfo, ITensorInfo::quantization_info(), arm_compute::quantize_qsymm16(), UniformQuantizationInfo::scale, ComputeAnchorsInfo::spatial_scale(), QuantizationInfo::uniform(), arm_compute::validate_arguments(), IKernel::window(), and Window::y().

Referenced by NEComputeAllAnchorsKernel::name(), and NEGenerateProposalsLayer::validate().

99 {
100  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(anchors, all_anchors, info));
101  return Status{};
102 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)

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