Compute Library
 21.08
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...
 
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 *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 67 of file NEGenerateProposalsLayerKernel.cpp.

Referenced by NEComputeAllAnchorsKernel::name().

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

◆ 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 72 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(), and ComputeAnchorsInfo::values_per_roi().

Referenced by NEComputeAllAnchorsKernel::name().

73 {
74  ARM_COMPUTE_ERROR_ON_NULLPTR(anchors, all_anchors);
75  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(anchors->info(), all_anchors->info(), info));
76 
77  // Metadata
78  const size_t num_anchors = anchors->info()->dimension(1);
79  const DataType data_type = anchors->info()->data_type();
80  const float width = info.feat_width();
81  const float height = info.feat_height();
82 
83  // Initialize the output if empty
84  const TensorShape output_shape(info.values_per_roi(), width * height * num_anchors);
85  auto_init_if_empty(*all_anchors->info(), TensorInfo(output_shape, 1, data_type, anchors->info()->quantization_info()));
86 
87  // Set instance variables
88  _anchors = anchors;
89  _all_anchors = all_anchors;
90  _anchors_info = info;
91 
92  Window win = calculate_max_window(*all_anchors->info(), Steps(info.values_per_roi()));
93 
94  INEKernel::configure(win);
95 }
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)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
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 168 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().

169 {
173 
174  switch(_anchors->info()->data_type())
175  {
176  case DataType::QSYMM16:
177  {
178  internal_run<int16_t>(window);
179  break;
180  }
181 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
182  case DataType::F16:
183  {
184  internal_run<float16_t>(window);
185  break;
186  }
187 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
188  case DataType::F32:
189  {
190  internal_run<float>(window);
191  break;
192  }
193  default:
194  {
195  ARM_COMPUTE_ERROR("Data type not supported");
196  }
197  }
198 }
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:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

◆ 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 97 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(), IKernel::window(), and Window::y().

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

98 {
99  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(anchors, all_anchors, info));
100  return Status{};
101 }
#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)

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