Compute Library
 22.11
CLDirectConvolutionLayer Class Reference

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

#include <CLDirectConvolutionLayer.h>

Collaboration diagram for CLDirectConvolutionLayer:
[legend]

Public Member Functions

 CLDirectConvolutionLayer ()
 Constructor. More...
 
 ~CLDirectConvolutionLayer ()
 Destructor. More...
 
 CLDirectConvolutionLayer (const CLDirectConvolutionLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLDirectConvolutionLayer (CLDirectConvolutionLayer &&)
 Default move constructor. More...
 
CLDirectConvolutionLayeroperator= (const CLDirectConvolutionLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLDirectConvolutionLayeroperator= (CLDirectConvolutionLayer &&)
 Default move assignment operator. 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 configure (const CLCompileContext &compile_context, 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() [1/3]

Constructor.

Definition at line 47 of file CLDirectConvolutionLayer.cpp.

References CLDirectConvolutionLayer::operator=(), and CLDirectConvolutionLayer::~CLDirectConvolutionLayer().

48  : _impl(std::make_unique<Impl>())
49 {
50 }

◆ ~CLDirectConvolutionLayer()

◆ CLDirectConvolutionLayer() [2/3]

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

◆ CLDirectConvolutionLayer() [3/3]

Default move constructor.

Member Function Documentation

◆ configure() [1/2]

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.

Valid data layouts:

  • NHWC
  • NCHW

Valid data type configurations:

src0 src1 src2 dst
F16 F16 F16 F16
F32 F32 F32 F32
QASYMM8 QASYMM8 S32 QASYMM8
QASYMM8_SIGNED QASYMM8_SIGNED S32 QASYMM8_SIGNED
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_SIGNED/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 and QASYMM8_SIGNED 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 55 of file CLDirectConvolutionLayer.cpp.

References CLKernelLibrary::get().

Referenced by arm_compute::test::validation::TEST_CASE().

56 {
57  configure(CLKernelLibrary::get().get_compile_context(), input, weights, biases, output, conv_info, act_info);
58 }
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.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.

◆ configure() [2/2]

void configure ( const CLCompileContext compile_context,
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]compile_contextThe compile context to be used.
[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_SIGNED/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 and QASYMM8_SIGNED 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 60 of file CLDirectConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_LOG_PARAMS, arm_compute::test::validation::conv_info, ITensor::info(), and arm_compute::test::validation::input.

62 {
63  ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output);
64  ARM_COMPUTE_LOG_PARAMS(input, weights, biases, output, conv_info, act_info);
65 
66  _impl->src = input;
67  _impl->weights = weights;
68  _impl->biases = biases;
69  _impl->dst = output;
70 
71  _impl->op = std::make_unique<opencl::ClDirectConv2d>();
72  _impl->op->configure(compile_context, input->info(), weights->info(), (biases != nullptr) ? biases->info() : nullptr, output->info(), conv_info, act_info);
73 }
#define ARM_COMPUTE_LOG_PARAMS(...)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ operator=() [1/2]

CLDirectConvolutionLayer& operator= ( const CLDirectConvolutionLayer )
delete

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

Referenced by CLDirectConvolutionLayer::CLDirectConvolutionLayer().

◆ operator=() [2/2]

CLDirectConvolutionLayer & operator= ( CLDirectConvolutionLayer &&  )
default

Default move assignment operator.

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For CPU 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 81 of file CLDirectConvolutionLayer.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, arm_compute::ACL_SRC_1, arm_compute::ACL_SRC_2, ITensorPack::add_tensor(), and arm_compute::test::validation::pack.

82 {
83  ITensorPack pack;
84  pack.add_tensor(TensorType::ACL_SRC, _impl->src);
85  pack.add_tensor(TensorType::ACL_SRC_1, _impl->weights);
86  pack.add_tensor(TensorType::ACL_SRC_2, _impl->biases);
87  pack.add_tensor(TensorType::ACL_DST, _impl->dst);
88  _impl->op->run(pack);
89 }
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
Definition: ITensorPack.cpp:39

◆ 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_SIGNED/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 and QASYMM8_SIGNED type where biases should be of S32 type.
[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 75 of file CLDirectConvolutionLayer.cpp.

References ClDirectConv2d::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE().

77 {
78  return opencl::ClDirectConv2d::validate(input, weights, biases, output, conv_info, act_info);
79 }
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
Static function to check if given info will lead to a valid configuration.

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