21.02
|
Function to run the deconvolution layer. More...
#include <CLDirectDeconvolutionLayer.h>
Public Member Functions | |
CLDirectDeconvolutionLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Constructor. More... | |
CLDirectDeconvolutionLayer (const CLDirectDeconvolutionLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLDirectDeconvolutionLayer (CLDirectDeconvolutionLayer &&)=default | |
Default move constructor. More... | |
CLDirectDeconvolutionLayer & | operator= (const CLDirectDeconvolutionLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
CLDirectDeconvolutionLayer & | operator= (CLDirectDeconvolutionLayer &&)=default |
Default move assignment operator. More... | |
void | configure (ICLTensor *input, ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &info, const WeightsInfo &weights_info=WeightsInfo()) |
Set the input, weights, biases and output tensors. More... | |
void | configure (const CLCompileContext &compile_context, ICLTensor *input, ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &info, const WeightsInfo &weights_info=WeightsInfo()) |
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, ITensorInfo *output, const PadStrideInfo &info, const WeightsInfo &weights_info=WeightsInfo()) |
Static function to check if given info will lead to a valid configuration of CLDirectDeconvolutionLayer. More... | |
Function to run the deconvolution layer.
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 and pad is the amount of padding.
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. Therefore, it will be necessary to use the weights in the reverse order to perform an actual convolution. This is achieved by using CLReverse.
This function calls the following OpenCL kernels/functions:
And the following CPP kernels:
Definition at line 75 of file CLDirectDeconvolutionLayer.h.
CLDirectDeconvolutionLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
Constructor.
Definition at line 45 of file CLDirectDeconvolutionLayer.cpp.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
default |
Default move constructor.
void configure | ( | ICLTensor * | input, |
ICLTensor * | weights, | ||
const ICLTensor * | bias, | ||
ICLTensor * | output, | ||
const PadStrideInfo & | info, | ||
const WeightsInfo & | weights_info = WeightsInfo() |
||
) |
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_SIGNED/QASYMM8/F16/F32. |
[in] | weights | The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . |
[in] | bias | (Optional) The biases have one dimension. 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] | output | Output tensor. The output has the same number of dimensions as the input . |
[in] | info | Contains padding and policies to be used in the deconvolution, this is decribed in PadStrideInfo. |
[in] | weights_info | (Optional) Weights information needed for CLConvolutionLayer, specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. |
Definition at line 110 of file CLDirectDeconvolutionLayer.cpp.
References CLKernelLibrary::get().
void configure | ( | const CLCompileContext & | compile_context, |
ICLTensor * | input, | ||
ICLTensor * | weights, | ||
const ICLTensor * | bias, | ||
ICLTensor * | output, | ||
const PadStrideInfo & | info, | ||
const WeightsInfo & | weights_info = WeightsInfo() |
||
) |
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_SIGNED/QASYMM8/F16/F32. |
[in] | weights | The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . |
[in] | bias | (Optional) The biases have one dimension. 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] | output | Output tensor. The output has the same number of dimensions as the input . |
[in] | info | Contains padding and policies to be used in the deconvolution, this is decribed in PadStrideInfo. |
[in] | weights_info | (Optional) Weights information needed for CLConvolutionLayer, specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. |
Definition at line 116 of file CLDirectDeconvolutionLayer.cpp.
References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), ICLTensor::buffer(), arm_compute::CEIL, ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_deconvolution_output_shape(), arm_compute::misc::shape_calculator::compute_deconvolution_upsampled_shape(), CLReverse::configure(), CLDeconvolutionLayerUpsample::configure(), CLConvolutionLayer::configure(), arm_compute::test::validation::conv_info, arm_compute::test::validation::data_layout, ITensorInfo::data_layout(), ITensorInfo::data_type(), arm_compute::deconvolution_output_dimensions(), ITensorInfo::dimension(), arm_compute::FLOOR, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, ITensor::info(), arm_compute::test::validation::info, ITensorAllocator::init(), MemoryGroup::manage(), CLTensor::map(), arm_compute::NHWC, arm_compute::test::validation::output_shape, PadStrideInfo::pad_bottom(), PadStrideInfo::pad_left(), PadStrideInfo::pad_right(), PadStrideInfo::pad_top(), ITensorInfo::quantization_info(), WeightsInfo::retain_internal_weights(), TensorInfo::set_data_layout(), PadStrideInfo::stride(), arm_compute::U, arm_compute::U32, CLTensor::unmap(), CLDirectDeconvolutionLayer::validate(), and arm_compute::WIDTH.
|
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 211 of file CLDirectDeconvolutionLayer.cpp.
References CLTensorAllocator::allocate(), CLTensor::allocator(), ARM_COMPUTE_ERROR_ON, CLTensorAllocator::free(), ITensor::is_used(), ITensor::mark_as_unused(), CLConvolutionLayer::prepare(), and ICLSimpleFunction::run().
Referenced by CLDirectDeconvolutionLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 201 of file CLDirectDeconvolutionLayer.cpp.
References CLDirectDeconvolutionLayer::prepare(), CLDeconvolutionLayerUpsample::run(), and CLConvolutionLayer::run().
|
static |
Static function to check if given info will lead to a valid configuration of CLDirectDeconvolutionLayer.
[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_SIGNED/QASYMM8/F16/F32. |
[in] | weights | The 4d weights info with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . |
[in] | bias | (Optional) The biases have one dimension. 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] | output | Output tensor info. The output has the same number of dimensions as the input . |
[in] | info | Contains padding and policies to be used in the deconvolution, this is decribed in PadStrideInfo. |
[in] | weights_info | (Optional) Weights information needed for CLConvolutionLayer, specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel. |
Definition at line 58 of file CLDirectDeconvolutionLayer.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_MSG, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::CEIL, arm_compute::CHANNEL, ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_deconvolution_output_shape(), arm_compute::misc::shape_calculator::compute_deconvolution_upsampled_shape(), arm_compute::test::validation::conv_info, 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::test::validation::info, arm_compute::is_data_type_quantized_asymmetric(), arm_compute::test::validation::output_shape, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::S32, PadStrideInfo::stride(), CLDeconvolutionLayerUpsample::validate(), CLConvolutionLayer::validate(), and arm_compute::WIDTH.
Referenced by CLDirectDeconvolutionLayer::configure(), and CLDeconvolutionLayer::validate().