Compute Library
 19.08
CLDeconvolutionLayer Class Reference

Basic function to compute the deconvolution layer. More...

#include <CLDeconvolutionLayer.h>

Collaboration diagram for CLDeconvolutionLayer:
[legend]

Public Member Functions

 CLDeconvolutionLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default constructor. More...
 
void configure (ICLTensor *input, ICLTensor *weights, const ICLTensor *bias, ICLTensor *output, const PadStrideInfo &deconv_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 &deconv_info, const WeightsInfo &weights_info=WeightsInfo())
 Static function to check if given info will lead to a valid configuration of CLDeconvolutionLayer. More...
 
static DeconvolutionMethod get_deconvolution_method (const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, ITensorInfo *output, const PadStrideInfo &deconv_info, const WeightsInfo &weights_info)
 

Detailed Description

Basic function to compute the deconvolution layer.

This function calls the following OpenCL kernels/functions:

  1. CLGEMMDeconvolutionLayer
  2. CLDirectDeconvolutionLayer

Definition at line 41 of file CLDeconvolutionLayer.h.

Constructor & Destructor Documentation

◆ CLDeconvolutionLayer()

CLDeconvolutionLayer ( std::shared_ptr< IMemoryManager memory_manager = nullptr)

Default constructor.

Definition at line 39 of file CLDeconvolutionLayer.cpp.

40  : _memory_manager(std::move(memory_manager)), _function()
41 {
42 }

Member Function Documentation

◆ configure()

void configure ( ICLTensor input,
ICLTensor weights,
const ICLTensor bias,
ICLTensor output,
const PadStrideInfo deconv_info,
const WeightsInfo weights_info = WeightsInfo() 
)

Set the input, weights, biases and output tensors.

Parameters
[in,out]inputInput tensor. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: QASYMM8/F16/F32.
[in]weightsThe 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: Same as input.
[out]outputOutput tensor. The output has the same number of dimensions as the input.
[in]deconv_infoContains padding and policies to be used in the deconvolution, this is described in PadStrideInfo.
[in]weights_info(Optional) Weights information needed for CLConvolutionLayer, specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel.

Definition at line 44 of file CLDeconvolutionLayer.cpp.

46 {
47  ARM_COMPUTE_ERROR_ON_NULLPTR(input, weights, output);
48 
49  switch(CLDeconvolutionLayer::get_deconvolution_method(input->info(), weights->info(), nullptr, output->info(), deconv_info, weights_info))
50  {
52  {
53  auto f = arm_compute::support::cpp14::make_unique<CLDirectDeconvolutionLayer>();
54  f->configure(input, weights, bias, output, deconv_info, weights_info);
55  _function = std::move(f);
56  break;
57  }
59  {
60  auto f = arm_compute::support::cpp14::make_unique<CLGEMMDeconvolutionLayer>(_memory_manager);
61  f->configure(input, weights, bias, output, deconv_info);
62  _function = std::move(f);
63  break;
64  }
65  default:
66  ARM_COMPUTE_ERROR("Not supported.");
67  break;
68  }
69 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: CLTensor.cpp:35
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
static DeconvolutionMethod get_deconvolution_method(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, ITensorInfo *output, const PadStrideInfo &deconv_info, const WeightsInfo &weights_info)

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, arm_compute::test::validation::bias, arm_compute::DIRECT, arm_compute::GEMM, CLDeconvolutionLayer::get_deconvolution_method(), ITensor::info(), CLTensor::info(), arm_compute::test::validation::weights, and arm_compute::test::validation::weights_info.

◆ get_deconvolution_method()

DeconvolutionMethod get_deconvolution_method ( const ITensorInfo input,
const ITensorInfo weights,
const ITensorInfo bias,
ITensorInfo output,
const PadStrideInfo deconv_info,
const WeightsInfo weights_info 
)
static

Definition at line 97 of file CLDeconvolutionLayer.cpp.

99 {
101 
102  const DataLayout data_layout = input->data_layout();
103 
106 
107  if(weights->dimension(idx_w) != deconv_info.stride().first || weights->dimension(idx_h) != deconv_info.stride().second)
108  {
110  }
111 
113 }
const DataLayout data_layout
Definition: Im2Col.cpp:146
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:724
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:326
DataLayout
[DataLayout enum definition]
Definition: Types.h:114
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

References ARM_COMPUTE_UNUSED, arm_compute::test::validation::bias, arm_compute::test::validation::data_layout, ITensorInfo::data_layout(), arm_compute::DIRECT, arm_compute::GEMM, arm_compute::get_data_layout_dimension_index(), arm_compute::HEIGHT, PadStrideInfo::stride(), arm_compute::test::validation::weights, arm_compute::test::validation::weights_info, and arm_compute::WIDTH.

Referenced by CLDeconvolutionLayer::configure(), and CLDeconvolutionLayer::validate().

◆ prepare()

void prepare ( )
overridevirtual

Prepare the function for executing.

Any one off pre-processing step required by the function is handled here

Note
Prepare stage might not need all the function's buffers' backing memory to be available in order to execute

Reimplemented from IFunction.

Definition at line 121 of file CLDeconvolutionLayer.cpp.

122 {
123  _function->prepare();
124 }

Referenced by CLDeconvolutionLayer::run().

◆ run()

void run ( )
overridevirtual

Run the kernels contained in the function.

For NEON 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 115 of file CLDeconvolutionLayer.cpp.

116 {
117  prepare();
118  _function->run();
119 }
void prepare() override
Prepare the function for executing.

References CLDeconvolutionLayer::prepare().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo weights,
const ITensorInfo bias,
ITensorInfo output,
const PadStrideInfo deconv_info,
const WeightsInfo weights_info = WeightsInfo() 
)
static

Static function to check if given info will lead to a valid configuration of CLDeconvolutionLayer.

Parameters
[in]inputInput tensor info. 3 lower dimensions represent a single input, and an optional 4th dimension for batch of inputs. Data types supported: QASYMM8/F16/F32.
[in]weightsThe 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: Same as input.
[in]outputOutput tensor info. The output has the same number of dimensions as the input.
[in]deconv_infoContains padding and policies to be used in the deconvolution, this is described in PadStrideInfo.
[in]weights_info(Optional) Weights information needed for CLConvolutionLayer, specifies if the weights tensor has been reshaped with CLWeightsReshapeKernel.
Returns
a status

Definition at line 71 of file CLDeconvolutionLayer.cpp.

73 {
75  switch(CLDeconvolutionLayer::get_deconvolution_method(input, weights, bias, output, deconv_info, weights_info))
76  {
78  {
79  // Validate direct convolution layer
81  break;
82  }
84  {
85  // Validate gemm-based convolution layer
87  break;
88  }
89  default:
90  ARM_COMPUTE_ERROR("Not supported.");
91  break;
92  }
93 
94  return Status{};
95 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
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 CLDirectDeconvolutionLay...
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.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
Status class.
Definition: Error.h:52
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
static DeconvolutionMethod get_deconvolution_method(const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *bias, ITensorInfo *output, const PadStrideInfo &deconv_info, const WeightsInfo &weights_info)

References ARM_COMPUTE_ERROR, ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::test::validation::bias, arm_compute::DIRECT, arm_compute::GEMM, CLDeconvolutionLayer::get_deconvolution_method(), CLGEMMDeconvolutionLayer::validate(), CLDirectDeconvolutionLayer::validate(), arm_compute::test::validation::weights, and arm_compute::test::validation::weights_info.


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