21.02
|
Function to run the deconvolution layer. More...
#include <NEDeconvolutionLayer.h>
Public Member Functions | |
NEDeconvolutionLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr) | |
Constructor. More... | |
NEDeconvolutionLayer (const NEDeconvolutionLayer &)=delete | |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEDeconvolutionLayer & | operator= (const NEDeconvolutionLayer &)=delete |
Prevent instances of this class from being copied (As this class contains pointers) More... | |
NEDeconvolutionLayer (NEDeconvolutionLayer &&)=delete | |
Prevent instances of this class from being moved (As this class contains pointers) More... | |
NEDeconvolutionLayer & | operator= (NEDeconvolutionLayer &&)=delete |
Prevent instances of this class from being moved (As this class contains pointers) More... | |
virtual | ~NEDeconvolutionLayer ()=default |
Default destructor. More... | |
void | configure (ITensor *input, const ITensor *weights, const ITensor *bias, ITensor *output, const PadStrideInfo &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 &info) |
Static function to check if given info will lead to a valid configuration of NEDeconvolutionLayer. 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 perfrom 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 finaly 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 is the size of the first input dimension. height 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 NEReverse.
This function calls the following Neon kernels/functions:
Definition at line 75 of file NEDeconvolutionLayer.h.
NEDeconvolutionLayer | ( | std::shared_ptr< IMemoryManager > | memory_manager = nullptr | ) |
Constructor.
Definition at line 69 of file NEDeconvolutionLayer.cpp.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
delete |
Prevent instances of this class from being moved (As this class contains pointers)
|
virtualdefault |
Default destructor.
void configure | ( | ITensor * | input, |
const ITensor * | weights, | ||
const ITensor * | bias, | ||
ITensor * | output, | ||
const PadStrideInfo & | 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: F32/F16/QASYMM8/QASYMM8_SIGNED. |
[in] | weights | The 4d weights with dimensions [width, height, IFM, OFM]. Data type supported: Same as input . |
[in] | bias | Optional, ignored if NULL. The biases have one dimension. Data type supported: Data types supported: S32 for QASYMM8 and QASYMM8_SIGNED input, F32 for F32 input, F16 for F16 input. |
[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. |
Definition at line 150 of file NEDeconvolutionLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), Tensor::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(), CPPUpsample::configure(), NEReverse::configure(), NEConvolutionLayer::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::get_data_layout_dimension_index(), arm_compute::HEIGHT, ITensor::info(), arm_compute::test::validation::info, TensorAllocator::init(), arm_compute::test::validation::input, MemoryGroup::manage(), arm_compute::test::validation::output_shape, ITensorInfo::quantization_info(), TensorInfo::set_data_layout(), PadStrideInfo::stride(), arm_compute::U, arm_compute::U32, NEDeconvolutionLayer::validate(), and arm_compute::WIDTH.
|
delete |
Prevent instances of this class from being copied (As this class contains pointers)
|
delete |
Prevent instances of this class from being moved (As this class contains pointers)
|
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 219 of file NEDeconvolutionLayer.cpp.
References TensorAllocator::allocate(), Tensor::allocator(), ARM_COMPUTE_ERROR_ON, ITensor::is_used(), ITensor::mark_as_unused(), NEConvolutionLayer::prepare(), and INESimpleFunctionNoBorder::run().
Referenced by NEDeconvolutionLayer::run().
|
overridevirtual |
Run the kernels contained in the function.
For Neon kernels:
For OpenCL kernels:
Implements IFunction.
Definition at line 209 of file NEDeconvolutionLayer.cpp.
References NEDeconvolutionLayer::prepare(), ICPPSimpleFunction::run(), and NEConvolutionLayer::run().
|
static |
Static function to check if given info will lead to a valid configuration of NEDeconvolutionLayer.
[in] | input | Input tensor info. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: F32/F16/QASYMM8/QASYMM8_SIGNED. |
[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: Data types supported: S32 for QASYMM8 and QASYMM8_SIGNED input, F32 for F32 input, F16 for F16 input. |
[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. |
Definition at line 84 of file NEDeconvolutionLayer.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::BATCHES, 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(), Window::DimX, Window::DimY, Window::DimZ, 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(), ITensorInfo::tensor_shape(), TensorShape::total_size(), NEConvolutionLayer::validate(), arm_compute::WIDTH, Dimensions< T >::x(), Dimensions< T >::y(), and Dimensions< T >::z().
Referenced by NEDeconvolutionLayer::configure().