24.02.1
|
Basic function to compute the convolution layer. More...
#include <ClConv2d.h>
Public Member Functions | |
ClConv2d () | |
Default constructor. More... | |
~ClConv2d () | |
Default Destructor. More... | |
ClConv2d (const ClConv2d &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
ClConv2d (ClConv2d &&)=default | |
Default move constructor. More... | |
ClConv2d & | operator= (const ClConv2d &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
ClConv2d & | operator= (ClConv2d &&)=default |
Default move assignment operator. More... | |
void | configure (const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *dst, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info=WeightsInfo()) |
Set the src and dst tensors. More... | |
void | run (ITensorPack &tensors) override |
Run the kernels contained in the function. More... | |
void | prepare (ITensorPack &tensors) override |
Prepare the function for executing. More... | |
experimental::MemoryRequirements | workspace () const override |
Return the memory requirements required by the workspace. More... | |
Public Member Functions inherited from ICLOperator | |
ICLOperator (IRuntimeContext *ctx=nullptr) | |
Constructor. More... | |
ICLOperator (const ICLOperator &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
ICLOperator (ICLOperator &&)=default | |
Default move constructor. More... | |
ICLOperator & | operator= (const ICLOperator &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
ICLOperator & | operator= (ICLOperator &&)=default |
Default move assignment operator. More... | |
Public Member Functions inherited from IOperator | |
virtual | ~IOperator ()=default |
Destructor. More... | |
Static Public Member Functions | |
static Status | validate (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info=WeightsInfo()) |
Static function to check if given info will lead to a valid configuration of ClConv2d. More... | |
static ConvolutionMethod | get_convolution_method (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const Conv2dInfo &conv2d_info, const WeightsInfo &weights_info, const GPUTarget gpu_target) |
Static function to check if given info will return the convolution called by ClConv2d. More... | |
Basic function to compute the convolution layer.
This function calls the following OpenCL kernels/functions:
The function selects one of the algorithms mentioned above based on:
Generally GEMM-based convolution is executed when neither Winograd nor FFT nor Direct convolution can be performed.
FP32 Algorithm | Filter Size | Input/Output feature maps |
---|---|---|
Winograd | 3x3 1x3 3x1 5x1 1x5 5x5(fast maths) 7x1 1x7 | Input channels is greater than 3 |
FFT | Squared kernels and greater than 9x9 | Input feature maps > Output feature maps |
DirectConv | 9x9 | |
GEMM | Any size |
Winograd 5x5 requires fast maths enabled.
FP16 Algorithm | Filter Size | Input/Output feature maps |
---|---|---|
Winograd | 3x3 1x3 3x1 5x1 1x5 5x5 | Input channels is greater than 3 |
FFT | Not supported | |
DirectConv | 9x9 | |
GEMM | Any size |
Winograd FP16 requires fast maths enabled.
Definition at line 72 of file ClConv2d.h.
ClConv2d | ( | ) |
|
default |
Default Destructor.
Prevent instances of this class from being copied (As this class contains pointers)
void configure | ( | const CLCompileContext & | compile_context, |
ITensorInfo * | src, | ||
ITensorInfo * | weights, | ||
ITensorInfo * | biases, | ||
ITensorInfo * | dst, | ||
const Conv2dInfo & | conv2d_info, | ||
const WeightsInfo & | weights_info = WeightsInfo() |
||
) |
Set the src and dst tensors.
Valid data layouts:
Valid data type configurations:
src0 | src1 | src2 | dst |
---|---|---|---|
F16 | F16 | F16 | F16 |
F32 | F32 | F32 | F32 |
QASYMM8 | QASYMM8 | S32 | QASYMM8 |
QASYMM8 | QSYMM8_PER_CHANNEL | S32 | QASYMM8 |
QASYMM8_SIGNED | QASYMM8_SIGNED | S32 | QASYMM8_SIGNED |
QASYMM8_SIGNED | QSYMM8_PER_CHANNEL | S32 | QASYMM8_SIGNED |
[in] | compile_context | The compile context to be used. |
[in] | src | Source tensor info. 3 lower dimensions represent a single src [width, height, IFM], while every optional dimension from 4 and above represent a batch of srcs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. |
[in] | weights | Weights tensor info. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: Same as src , also could be QSYMM8_PER_CHANNEL if src is QASYMM8/QASYMM8_SIGNED. |
[in] | biases | Biases tensor info. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as src , except for src of QASYMM8/QASYMM8_SIGNED type where biases should be of S32 type. |
[out] | dst | Destination tensor info. 3 lower dimensions represent a single dst [width, height, OFM], while the rest represent batch of dsts. Data types supported: Same as src . |
[in] | conv2d_info | Contains convolution 2d info described in Conv2dInfo. |
[in] | weights_info | Specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. Data type supported: Same as src . |
Definition at line 80 of file ClConv2d.cpp.
References Conv2dInfo::act_info, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_LOG_PARAMS, Conv2dInfo::conv_info, arm_compute::DIRECT, arm_compute::test::validation::dst, Conv2dInfo::enable_fast_math, arm_compute::GEMM, CLScheduler::get(), ClConv2d::get_convolution_method(), arm_compute::INDIRECT, Conv2dInfo::num_groups, arm_compute::test::validation::src, ClConv2d::validate(), arm_compute::test::validation::weights_info, and arm_compute::WINOGRAD.
|
static |
Static function to check if given info will return the convolution called by ClConv2d.
[in] | src | Source tensor. 3 lower dimensions represent a single src [width, height, IFM], while every optional dimension from 4 and above represent a batch of srcs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. |
[in] | weights | Weights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported: Same as src , also could be QSYMM8_PER_CHANNEL if src is QASYMM8/QASYMM8_SIGNED. |
[in] | dst | Destination tensor. 3 lower dimensions represent a single dst [width, height, OFM], while the rest represent batch of dsts. Data types supported: Same as src . |
[in] | conv2d_info | Contains convolution 2d info described in Conv2dInfo. |
[in] | weights_info | Specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. |
[in] | gpu_target | Specifies the GPUTarget . |
Definition at line 190 of file ClConv2d.cpp.
References Conv2dInfo::act_info, arm_compute::test::validation::act_info, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_UNUSED, arm_compute::CHANNEL, arm_compute::misc::shape_calculator::compute_deep_convolution_shape(), Conv2dInfo::conv_info, arm_compute::test::validation::conv_info, arm_compute::cpu::data_layout, Conv2dInfo::dilation, ITensorInfo::dimension(), arm_compute::DIRECT, arm_compute::test::validation::dst, Conv2dInfo::enable_fast_math, arm_compute::FFT, arm_compute::FLOOR, arm_compute::G71, arm_compute::G72, arm_compute::G76, arm_compute::G77, arm_compute::GEMM, arm_compute::get_arch_from_target(), arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::INDIRECT, arm_compute::test::validation::info, arm_compute::is_data_type_float(), arm_compute::MIDGARD, arm_compute::NCHW, arm_compute::NHWC, arm_compute::test::validation::output_shape, arm_compute::test::validation::src, PadStrideInfo::stride(), arm_compute::utils::cast::U, ClDirectConv2d::validate(), ClIndirectConv2d::validate(), ClWinogradConv2d::validate(), CLFFTConvolutionLayer::validate(), arm_compute::test::validation::weights_info, arm_compute::WIDTH, and arm_compute::WINOGRAD.
Referenced by ClConv2d::configure(), CLConvolutionLayer::configure(), CLConvolutionLayer::get_convolution_method(), ClConv2d::validate(), and CLConvolutionLayer::validate().
Prevent instances of this class from being copied (As this class contains pointers)
|
overridevirtual |
Prepare the function for executing.
Any one off pre-processing step required by the function is handled here
[in] | constants | Vector that contains the constants tensors. |
Reimplemented from ICLOperator.
Definition at line 422 of file ClConv2d.cpp.
Referenced by ClConv2d::run().
|
overridevirtual |
Run the kernels contained in the function.
[in] | tensors | Vector that contains the tensors to operate on. |
Reimplemented from ICLOperator.
Definition at line 416 of file ClConv2d.cpp.
References ClConv2d::prepare().
|
static |
Static function to check if given info will lead to a valid configuration of ClConv2d.
Similar to ClConv2d::configure()
Definition at line 134 of file ClConv2d.cpp.
References Conv2dInfo::act_info, ARM_COMPUTE_ERROR, ARM_COMPUTE_RETURN_ERROR_ON_MSG, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, Conv2dInfo::conv_info, arm_compute::DIRECT, arm_compute::test::validation::dst, Conv2dInfo::enable_fast_math, arm_compute::GEMM, CLScheduler::get(), ClConv2d::get_convolution_method(), arm_compute::INDIRECT, arm_compute::NCHW, Conv2dInfo::num_groups, arm_compute::test::validation::src, CLScheduler::target(), ClDirectConv2d::validate(), ClIndirectConv2d::validate(), ClWinogradConv2d::validate(), ClGemmConv2d::validate(), arm_compute::test::validation::weights_info, and arm_compute::WINOGRAD.
Referenced by ClConv2d::configure(), and CLConvolutionLayer::validate().
|
overridevirtual |
Return the memory requirements required by the workspace.
Reimplemented from ICLOperator.
Definition at line 427 of file ClConv2d.cpp.