21.02
|
Function to run the deconvolution layer through a call to GEMM. More...
#include <CLGEMMDeconvolutionLayer.h>
Public Member Functions | |
CLGEMMDeconvolutionLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Constructor. More... | |
CLGEMMDeconvolutionLayer (const CLGEMMDeconvolutionLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLGEMMDeconvolutionLayer (CLGEMMDeconvolutionLayer &&)=default | |
Default move constructor. More... | |
CLGEMMDeconvolutionLayer & | operator= (const CLGEMMDeconvolutionLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLGEMMDeconvolutionLayer & | operator= (CLGEMMDeconvolutionLayer &&)=default |
Default move assignment operator. More... | |
~CLGEMMDeconvolutionLayer () | |
Default desctructor. More... | |
void | configure (const ICLTensor *input, const ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &deconv_info) |
Set the input, weights, biases and output tensors. More... | |
void | configure (const CLCompileContext &compile_context, const ICLTensor *input, const ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &deconv_info) |
Set the input, weights, biases and output tensors. More... | |
void | run () override |
Run the kernels contained in the function. More... | |
void | prepare () override |
Prepare the function for executing. More... | |
Public Member Functions inherited from IFunction | |
virtual | ~IFunction ()=default |
Destructor. More... | |
Static Public Member Functions | |
static Status | validate (const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, const ITensorInfo *output, const PadStrideInfo &deconv_info) |
Static function to check if given info will lead to a valid configuration of CLDeconvolutionLayer. More... | |
Function to run the deconvolution layer through a call to GEMM.
Deconvolution Layer is the backward pass of Convolution Layer. First we transform the input depending on the stride and pad info and then perform a 1x1 convolution pass. Input stride defines how many zeroes we should put between each element of the input, pad is the amount of padding and finally a is a user specified value where a < stride - 1, that increases the padding top and right of the input image.
The relation between input to output is as follows:
\[ width\_output = (width\_input - 1) \cdot stride\_x - 2 \cdot padding\_x + kernel\_x \]
\[ height\_output = (height\_input - 1) \cdot stride\_y - 2 \cdot padding\_y + kernel\_y \]
where: width_input is the size of the first input dimension. height_input is the size of the second input dimension. width_output is the size of the first output dimension. height_output is the size of the second output dimension. kernel_x and kernel_y are the convolution sizes in x and y. stride_x and stride_y is the input stride of the first and second dimension.
The weights used by Deconvolution are supposed to be the same as the ones used for Convolution.
This function calls the following OpenCL kernels/functions:
Definition at line 79 of file CLGEMMDeconvolutionLayer.h.
CLGEMMDeconvolutionLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Default move constructor.
|
default |
Default desctructor.
void configure | ( | const ICLTensor * | input, |
const ICLTensor * | weights, | ||
const ICLTensor * | bias, | ||
ICLTensor * | output, | ||
const PadStrideInfo & | deconv_info | ||
) |
Set the input, weights, biases and output tensors.
[in,out] | input | Input tensor. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. Data layout supported: NHWC |
[in] | weights | The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . Data layout supported: same as input . |
[in] | bias | (Optional) The biases have one dimension. Data type supported: Same as input . Data layout supported: same as input . |
[out] | output | Output tensor. The output has the same number of dimensions as the input . Data layout supported: same as input . |
[in] | deconv_info | Contains padding and policies to be used in the deconvolution, this is described in PadStrideInfo. This function supports only stride_x = weights.width && stride_y = weights.height. Moreover, padding is not supported. |
Definition at line 230 of file CLGEMMDeconvolutionLayer.cpp.
References CLKernelLibrary::get().
void configure | ( | const CLCompileContext & | compile_context, |
const ICLTensor * | input, | ||
const ICLTensor * | weights, | ||
const ICLTensor * | bias, | ||
ICLTensor * | output, | ||
const PadStrideInfo & | deconv_info | ||
) |
Set the input, weights, biases and output tensors.
[in] | compile_context | The compile context to be used. |
[in,out] | input | Input tensor. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. Data layout supported: NHWC |
[in] | weights | The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . Data layout supported: same as input . |
[in] | bias | (Optional) The biases have one dimension. Data type supported: Same as input . Data layout supported: same as input . |
[out] | output | Output tensor. The output has the same number of dimensions as the input . Data layout supported: same as input . |
[in] | deconv_info | Contains padding and policies to be used in the deconvolution, this is described in PadStrideInfo. This function supports only stride_x = weights.width && stride_y = weights.height. Moreover, padding is not supported. |
Definition at line 235 of file CLGEMMDeconvolutionLayer.cpp.
References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, CLTranspose::configure(), CLReshapeLayer::configure(), CLPermute::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), CLSlice::configure(), CLGEMM::configure(), CLGEMMLowpOutputStage::configure(), ITensorInfo::data_layout(), ITensorInfo::data_type(), ITensorInfo::dimension(), arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, ITensor::info(), CLTensor::info(), ITensorAllocator::init(), arm_compute::test::validation::input, arm_compute::is_data_type_quantized_asymmetric(), MemoryGroup::manage(), arm_compute::NCHW, UniformQuantizationInfo::offset, PadStrideInfo::pad_bottom(), PadStrideInfo::pad_left(), PadStrideInfo::pad_right(), PadStrideInfo::pad_top(), ITensorInfo::quantization_info(), UniformQuantizationInfo::scale, TensorInfo::set_quantization_info(), arm_compute::U, QuantizationInfo::uniform(), and CLGEMMDeconvolutionLayer::validate().
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Default move assignment operator.
|
overridevirtual |
Prepare the function for executing.
Any one off pre-processing step required by the function is handled here
Reimplemented from IFunction.
Definition at line 389 of file CLGEMMDeconvolutionLayer.cpp.
References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON, CLTensorAllocator::free(), ITensor::is_used(), ITensor::mark_as_unused(), CLGEMMLowpMatrixMultiplyCore::prepare(), CLGEMM::prepare(), ICLSimpleFunction::run(), CLReshapeLayer::run(), and CLPermute::run().
Referenced by CLGEMMDeconvolutionLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 356 of file CLGEMMDeconvolutionLayer.cpp.
References CLScheduler::enqueue(), CLScheduler::get(), CLGEMMDeconvolutionLayer::prepare(), ICLSimpleFunction::run(), CLPermute::run(), CLGEMMLowpMatrixMultiplyCore::run(), CLSlice::run(), and CLGEMM::run().
|
static |
Static function to check if given info will lead to a valid configuration of CLDeconvolutionLayer.
[in] | input | Input tensor info. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32. Data layout supported: NHWC |
[in] | weights | The 4d weights info with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . Data layout supported: same as input . |
[in] | bias | (Optional) The biases have one dimension. Data type supported: Same as input . Data layout supported: same as input . |
[in] | output | Output tensor info. The output has the same number of dimensions as the input . Data layout supported: same as input . |
[in] | deconv_info | Contains padding and policies to be used in the deconvolution, this is described in PadStrideInfo. |
Definition at line 135 of file CLGEMMDeconvolutionLayer.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT, ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::BATCHES, ICloneable< T >::clone(), TensorInfo::clone(), arm_compute::misc::shape_calculator::compute_deconvolution_output_shape(), arm_compute::test::validation::data_layout, ITensorInfo::data_layout(), ITensorInfo::data_type(), arm_compute::deconvolution_output_dimensions(), ITensorInfo::dimension(), arm_compute::F16, arm_compute::F32, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, arm_compute::is_data_type_quantized_asymmetric(), arm_compute::NCHW, PadStrideInfo::pad_bottom(), PadStrideInfo::pad_left(), PadStrideInfo::pad_right(), PadStrideInfo::pad_top(), arm_compute::permute(), arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::S32, TensorInfo::set_data_type(), PadStrideInfo::stride(), ITensorInfo::tensor_shape(), CLTranspose::validate(), CLReshapeLayer::validate(), CLPermute::validate(), CLDeconvolutionReshapeOutputKernel::validate(), CLGEMMLowpMatrixMultiplyCore::validate(), CLSlice::validate(), CLGEMM::validate(), CLGEMMLowpOutputStage::validate(), and arm_compute::WIDTH.
Referenced by CLGEMMDeconvolutionLayer::configure(), and CLDeconvolutionLayer::validate().