Compute Library
 19.08
CLDirectConvolutionLayer Class Reference

Basic function to execute direct convolution function: More...

#include <CLDirectConvolutionLayer.h>

Collaboration diagram for CLDirectConvolutionLayer:
[legend]

Public Member Functions

 CLDirectConvolutionLayer ()
 Default constructor. More...
 
void configure (ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Set the input and output tensors. More...
 
void run () override
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Static function to check if given info will lead to a valid configuration of CLDirectConvolutionLayer. More...
 

Detailed Description

Basic function to execute direct convolution function:

Definition at line 41 of file CLDirectConvolutionLayer.h.

Constructor & Destructor Documentation

◆ CLDirectConvolutionLayer()

Default constructor.

Definition at line 35 of file CLDirectConvolutionLayer.cpp.

36  : _direct_conv_kernel(), _input_border_handler(), _activationlayer_function(), _is_activationlayer_enabled(false)
37 {
38 }

Member Function Documentation

◆ configure()

void configure ( ICLTensor input,
const ICLTensor weights,
const ICLTensor biases,
ICLTensor output,
const PadStrideInfo conv_info,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. 3 lower dimensions represent a single input [width, height, IFM], while every optional dimension from 4 and above represent a batch of inputs. Data types supported: QASYMM8/F16/F32.
[in]weightsWeights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported:Same as input.
[in]biasesBiases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Should match input data type, except for input of QASYMM8 type where biases should be of S32 type.
[out]outputDestination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. Data types supported: Same as input.
[in]conv_infoContains padding and stride information described in PadStrideInfo.
[in]act_info(Optional) Activation layer information in case of a fused activation.

Definition at line 40 of file CLDirectConvolutionLayer.cpp.

41 {
42  // Set GPU target
43  _direct_conv_kernel.set_target(CLScheduler::get().target());
44 
45  // Configure direct convolution
46  _direct_conv_kernel.configure(input, weights, biases, output, conv_info);
47 
48  // Configure border handler
49  PixelValue &&zero_value(0.f);
51  {
52  zero_value = PixelValue(static_cast<uint8_t>(input->info()->quantization_info().uniform().offset));
53  }
54  _input_border_handler.configure(input, _direct_conv_kernel.border_size(), BorderMode::CONSTANT, zero_value);
55 
56  // Tune kernels
57  CLScheduler::get().tune_kernel_static(_direct_conv_kernel);
58 
59  _is_activationlayer_enabled = act_info.enabled();
60 
61  //Configure Activation Layer
62  if(_is_activationlayer_enabled)
63  {
64  _activationlayer_function.configure(output, nullptr, act_info);
65  }
66 }
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
virtual DataType data_type() const =0
Data type used for each element of the tensor.
void configure(ICLTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel's input, output and border mode.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1030
BorderSize border_size() const override
The size of the border for that kernel.
void configure(ICLTensor *input, ICLTensor *output, ActivationLayerInfo act_info)
Set the input and output tensor.
void set_target(GPUTarget target)
Set the targeted GPU architecture.
Definition: ICLKernel.h:271
void tune_kernel_static(ICLKernel &kernel)
Tunes OpenCL kernel.
Definition: CLScheduler.h:172
void configure(const ICLTensor *input, const ICLTensor *weights, const ICLTensor *biases, ICLTensor *output, const PadStrideInfo &conv_info)
Set the input, weights, biases and output tensors.

References arm_compute::test::validation::act_info, CLDirectConvolutionLayerKernel::border_size(), CLActivationLayer::configure(), CLFillBorderKernel::configure(), CLDirectConvolutionLayerKernel::configure(), arm_compute::CONSTANT, arm_compute::test::validation::conv_info, ITensorInfo::data_type(), CLScheduler::get(), ITensor::info(), arm_compute::is_data_type_quantized_asymmetric(), UniformQuantizationInfo::offset, ITensorInfo::quantization_info(), ICLKernel::set_target(), CLScheduler::tune_kernel_static(), QuantizationInfo::uniform(), and arm_compute::test::validation::weights.

Referenced by CLDepthwiseSeparableConvolutionLayer::configure().

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For NEON kernels:

  • Multi-threading is used for the kernels which are parallelisable.
  • By default std::thread::hardware_concurrency() threads are used.
Note
CPPScheduler::set_num_threads() can be used to manually set the number of threads

For OpenCL kernels:

  • All the kernels are enqueued on the queue associated with CLScheduler.
  • The queue is then flushed.
Note
The function will not block until the kernels are executed. It is the user's responsibility to wait.
Will call prepare() on first run if hasn't been done

Implements IFunction.

Definition at line 79 of file CLDirectConvolutionLayer.cpp.

80 {
81  // Run border handler
82  CLScheduler::get().enqueue(_input_border_handler, false);
83 
84  // Run direct convolution
85  CLScheduler::get().enqueue(_direct_conv_kernel);
86 
87  //Run Activation Layer
88  if(_is_activationlayer_enabled)
89  {
90  _activationlayer_function.run();
91  }
92 }
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
void run() override final
Run the kernels contained in the function.
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: CLScheduler.cpp:95

References CLScheduler::enqueue(), CLScheduler::get(), and ICLSimpleFunction::run().

Referenced by CLDepthwiseSeparableConvolutionLayer::run().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo output,
const PadStrideInfo conv_info,
const ActivationLayerInfo act_info = ActivationLayerInfo() 
)
static

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

Parameters
[in]inputSource tensor. 3 lower dimensions represent a single input [width, height, IFM], while every optional dimension from 4 and above represent a batch of inputs. Data types supported: QASYMM8/F16/F32.
[in]weightsWeights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported:Same as input.
[in]biasesBiases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported:Same as input.
[in]outputDestination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. Data types supported: Same as input.
[in]conv_infoContains padding and stride information described in PadStrideInfo.
[in]act_info(Optional) Activation layer information in case of a fused activation.
Returns
a status

Definition at line 68 of file CLDirectConvolutionLayer.cpp.

70 {
72  if(act_info.enabled())
73  {
75  }
76  return Status{};
77 }
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ActivationLayerInfo &act_info)
Static function to check if given info will lead to a valid configuration of CLActivationLayer.
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
#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
static Status validate(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, const GPUTarget target)
Static function to check if given info will lead to a valid configuration of CLDirectConvolutionLayer...

References arm_compute::test::validation::act_info, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::test::validation::conv_info, CLScheduler::get(), CLActivationLayer::validate(), CLDirectConvolutionLayerKernel::validate(), and arm_compute::test::validation::weights.

Referenced by CLConvolutionLayer::get_convolution_method(), and CLConvolutionLayer::validate().


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