Compute Library
 21.08
NEBoundingBoxTransformKernel Class Reference

Interface for the bounding box kernel. More...

#include <NEBoundingBoxTransformKernel.h>

Collaboration diagram for NEBoundingBoxTransformKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEBoundingBoxTransformKernel ()
 Default constructor. More...
 
 NEBoundingBoxTransformKernel (const NEBoundingBoxTransformKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEBoundingBoxTransformKerneloperator= (const NEBoundingBoxTransformKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEBoundingBoxTransformKernel (NEBoundingBoxTransformKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEBoundingBoxTransformKerneloperator= (NEBoundingBoxTransformKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEBoundingBoxTransformKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *boxes, ITensor *pred_boxes, const ITensor *deltas, const BoundingBoxTransformInfo &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 *boxes, const ITensorInfo *pred_boxes, const ITensorInfo *deltas, const BoundingBoxTransformInfo &info)
 Static function to check if given info will lead to a valid configuration of CLBoundingBoxTransform. More...
 

Detailed Description

Interface for the bounding box kernel.

Definition at line 34 of file NEBoundingBoxTransformKernel.h.

Constructor & Destructor Documentation

◆ NEBoundingBoxTransformKernel() [1/3]

Default constructor.

Definition at line 82 of file NEBoundingBoxTransformKernel.cpp.

Referenced by NEBoundingBoxTransformKernel::name().

83  : _boxes(nullptr), _pred_boxes(nullptr), _deltas(nullptr), _bbinfo(0, 0, 0)
84 {
85 }

◆ NEBoundingBoxTransformKernel() [2/3]

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

◆ NEBoundingBoxTransformKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEBoundingBoxTransformKernel()

Default destructor.

Referenced by NEBoundingBoxTransformKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor boxes,
ITensor pred_boxes,
const ITensor deltas,
const BoundingBoxTransformInfo info 
)

Set the input and output tensors.

Parameters
[in]boxesSource tensor. Bounding box proposals in pixel coordinates. Size(M, 4), format [x1, y1, x2, y2]. Data types supported: QASYMM16/F16/F32.
[out]pred_boxesDestination tensor. Pixel coordinates of the transformed bounding boxes. Size (M, 4*K), format [x1, y1, x2, y2]. Data types supported: Same as input
[in]deltasBounding box translations and scales. Size (M, 4*K), format [dx, dy, dw, dh], K is the number of classes. Data types supported: QASYMM8 if input is QASYMM16, otherwise same as input.
[in]infoContains BoundingBox operation information described in BoundingBoxTransformInfo.
Note
Only single image prediction is supported. Height and Width (and scale) of the image will be contained in the BoundingBoxTransformInfo struct.

Definition at line 87 of file NEBoundingBoxTransformKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), ITensorInfo::data_type(), ITensorInfo::dimension(), Window::DimX, Window::DimY, ITensor::info(), arm_compute::test::validation::info, ITensorInfo::quantization_info(), and Window::set().

Referenced by NEBoundingBoxTransformKernel::name().

88 {
89  ARM_COMPUTE_ERROR_ON_NULLPTR(boxes, pred_boxes, deltas);
90  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(boxes->info(), pred_boxes->info(), deltas->info(), info));
91 
92  // Configure kernel window
93  auto_init_if_empty(*pred_boxes->info(), deltas->info()->clone()->set_data_type(boxes->info()->data_type()).set_quantization_info(boxes->info()->quantization_info()));
94 
95  // Set instance variables
96  _boxes = boxes;
97  _pred_boxes = pred_boxes;
98  _deltas = deltas;
99  _bbinfo = info;
100 
101  const unsigned int num_boxes = boxes->info()->dimension(1);
102  Window win = calculate_max_window(*pred_boxes->info(), Steps());
103  win.set(Window::DimX, Window::Dimension(0, 1u));
104  win.set(Window::DimY, Window::Dimension(0, num_boxes));
105 
106  INEKernel::configure(win);
107 }
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
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
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ name()

◆ operator=() [1/2]

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

Referenced by NEBoundingBoxTransformKernel::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 226 of file NEBoundingBoxTransformKernel.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::QASYMM16, and IKernel::window().

Referenced by NEBoundingBoxTransformKernel::name().

227 {
231  switch(_boxes->info()->data_type())
232  {
233  case DataType::F32:
234  {
235  internal_run<float>(window);
236  break;
237  }
238  case DataType::QASYMM16:
239  {
240  internal_run<uint16_t>(window);
241  break;
242  }
243 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
244  case DataType::F16:
245  {
246  internal_run<float16_t>(window);
247  break;
248  }
249 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
250  default:
251  {
252  ARM_COMPUTE_ERROR("Data type not supported");
253  }
254  }
255 }
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
quantized, asymmetric fixed-point 16-bit number
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 boxes,
const ITensorInfo pred_boxes,
const ITensorInfo deltas,
const BoundingBoxTransformInfo info 
)
static

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

Parameters
[in]boxesSource tensor info. Bounding box proposals in pixel coordinates. Size(M, 4), format [x1, y1, x2, y2]. Data types supported: QASYMM16/F16/F32.
[in]pred_boxesDestination tensor info. Pixel coordinates of the transformed bounding boxes. Size (M, 4*K), format [x1, y1, x2, y2]. Data types supported: Same as input
[in]deltasBounding box translations and scales. Size (M, 4*K), format [dx, dy, dw, dh], K is the number of classes. Data types supported: QASYMM8 if input is QASYMM16, otherwise same as input.
[in]infoContains BoundingBox operation information described in BoundingBoxTransformInfo.
Note
Only single image prediction is supported. Height and Width (and scale) of the image will be contained in the BoundingBoxTransformInfo struct.
Returns
a Status

Definition at line 109 of file NEBoundingBoxTransformKernel.cpp.

References BoundingBoxTransformInfo::apply_scale(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_RETURN_ON_ERROR, BoundingBoxTransformInfo::bbox_xform_clip(), ITensor::buffer(), BoundingBoxTransformInfo::correct_transform_coords(), arm_compute::dequantize_qasymm16(), arm_compute::dequantize_qasymm8(), arm_compute::execute_window_loop(), BoundingBoxTransformInfo::img_height(), BoundingBoxTransformInfo::img_width(), ITensor::info(), offset(), ITensorInfo::offset_first_element_in_bytes(), Iterator::ptr(), ITensorInfo::quantization_info(), arm_compute::quantize_qasymm16(), BoundingBoxTransformInfo::scale(), ITensorInfo::tensor_shape(), QuantizationInfo::uniform(), BoundingBoxTransformInfo::weights(), and IKernel::window().

Referenced by NEBoundingBoxTransformKernel::name(), and NEBoundingBoxTransform::validate().

110 {
111  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(boxes, pred_boxes, deltas, info));
112  return Status{};
113 }
#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: