Compute Library
 19.08
NEYOLOLayerKernel Class Reference

Interface for the YOLO layer kernel. More...

#include <NEYOLOLayerKernel.h>

Collaboration diagram for NEYOLOLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEYOLOLayerKernel ()
 Constructor. More...
 
 NEYOLOLayerKernel (const NEYOLOLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEYOLOLayerKernel (NEYOLOLayerKernel &&)=default
 Default move constructor. More...
 
NEYOLOLayerKerneloperator= (const NEYOLOLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEYOLOLayerKerneloperator= (NEYOLOLayerKernel &&)=default
 Default move assignment operator. More...
 
 ~NEYOLOLayerKernel ()=default
 Default destructor. More...
 
void configure (ITensor *input, ITensor *output, const ActivationLayerInfo &act_info, int32_t num_classes)
 Set the input and output tensor. 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...
 
- 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 *input, const ITensorInfo *output, const ActivationLayerInfo &act_info, int32_t num_classes)
 Static function to check if given info will lead to a valid configuration of NEYOLOLayerKernel. More...
 

Detailed Description

Interface for the YOLO layer kernel.

Definition at line 34 of file NEYOLOLayerKernel.h.

Constructor & Destructor Documentation

◆ NEYOLOLayerKernel() [1/3]

Constructor.

Definition at line 98 of file NEYOLOLayerKernel.cpp.

99  : _func(nullptr), _input(nullptr), _output(nullptr), _act_info(), _num_classes()
100 {
101 }

◆ NEYOLOLayerKernel() [2/3]

NEYOLOLayerKernel ( const NEYOLOLayerKernel )
delete

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

◆ NEYOLOLayerKernel() [3/3]

Default move constructor.

◆ ~NEYOLOLayerKernel()

~NEYOLOLayerKernel ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( ITensor input,
ITensor output,
const ActivationLayerInfo act_info,
int32_t  num_classes 
)

Set the input and output tensor.

Note
If the output tensor is a nullptr or is equal to the input, the activation function will be performed in-place
Parameters
[in,out]inputSource tensor. In case of output tensor = nullptr, this tensor will store the result of the activation function. Data types supported: F16/F32.
[out]outputDestination tensor. Data type supported: same as input
[in]act_infoActivation layer parameters.
[in]num_classesNumber of classes to activate (must be submultiple of input channels)

Definition at line 203 of file NEYOLOLayerKernel.cpp.

204 {
206  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, act_info, num_classes));
207 
208  _input = input;
209  _output = output;
210  _act_info = act_info;
211  _num_classes = num_classes;
212 
213  switch(_input->info()->data_type())
214  {
215 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
216  case DataType::F16:
217  _func = (_input->info()->data_layout() == DataLayout::NHWC) ? &NEYOLOLayerKernel::yolo_layer_fp16_nhwc : &NEYOLOLayerKernel::yolo_layer_fp16_nchw;
218  break;
219 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
220  case DataType::F32:
221  _func = (_input->info()->data_layout() == DataLayout::NHWC) ? &NEYOLOLayerKernel::yolo_layer_fp32_nhwc : &NEYOLOLayerKernel::yolo_layer_fp32_nchw;
222  break;
223  default:
224  ARM_COMPUTE_ERROR("Element size not supported");
225  break;
226  }
227 
228  // Configure kernel window
229  auto win_config = validate_and_configure_window(input->info(), (output == nullptr) ? nullptr : output->info());
230  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
231  ICPPKernel::configure(win_config.second);
232 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
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_THROW_ON(status)
Definition: Error.h:327
1 channel, 1 F16 per channel
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Num samples, height, width, channels.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

References arm_compute::test::validation::act_info, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ITensorInfo::data_layout(), ITensorInfo::data_type(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::NHWC, and arm_compute::validate_and_configure_window().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 37 of file NEYOLOLayerKernel.h.

38  {
39  return "NEYOLOLayerKernel";
40  }

◆ operator=() [1/2]

NEYOLOLayerKernel& operator= ( const NEYOLOLayerKernel )
delete

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

◆ operator=() [2/2]

NEYOLOLayerKernel& operator= ( NEYOLOLayerKernel &&  )
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.

Implements ICPPKernel.

Definition at line 242 of file NEYOLOLayerKernel.cpp.

243 {
247  ARM_COMPUTE_ERROR_ON(_func == nullptr);
248 
249  (this->*_func)(window);
250 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::info, and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const ActivationLayerInfo act_info,
int32_t  num_classes 
)
static

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

Parameters
[in]inputSource tensor info. In case of output tensor info = nullptr, this tensor will store the result of the activation function. Data types supported: F16/F32.
[in]outputDestination tensor info. Data type supported: same as input
[in]act_infoActivation layer information.
[in]num_classesNumber of classes to activate (must be submultiple of input channels)
Returns
a status

Definition at line 234 of file NEYOLOLayerKernel.cpp.

235 {
236  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, act_info, num_classes));
237  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), (output == nullptr) ? nullptr : output->clone().get()).first);
238 
239  return Status{};
240 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
Status class.
Definition: Error.h:52
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.

References arm_compute::test::validation::act_info, ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::validate_and_configure_window().

Referenced by NEYOLOLayer::validate().


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