Compute Library
GCDirectConvolutionLayer Class Reference

Basic function to execute direct convolution function. More...

#include <GCDirectConvolutionLayer.h>

Collaboration diagram for GCDirectConvolutionLayer:

Public Member Functions

 GCDirectConvolutionLayer ()
 Default constructor. More...
void configure (IGCTensor *input, const IGCTensor *weights, const IGCTensor *biases, IGCTensor *output, const PadStrideInfo &conv_info, const ActivationLayerInfo &act_info=ActivationLayerInfo())
 Set the input and output tensors. More...
void run () override final
 Run the kernels contained in the function. More...
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
virtual void prepare ()
 Prepare the function for executing. More...

Detailed Description

Basic function to execute direct convolution function.

This function calls the following kernels:

  1. GCDirectConvolutionLayerKernel
  2. GCFillBorderKernel
  3. GCTensorShiftKernel
Supported kernel size: 1x1, 3x3, and 5x5
This OpenGL ES implementation works with stride_x = 1 and 2
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 53 of file GCDirectConvolutionLayer.h.

Constructor & Destructor Documentation

◆ GCDirectConvolutionLayer()

Default constructor.

Definition at line 36 of file GCDirectConvolutionLayer.cpp.

37  : _kernel(nullptr), _border_handler(), _shift_handler()
38 {
39 }

Member Function Documentation

◆ configure()

void configure ( IGCTensor input,
const IGCTensor weights,
const IGCTensor biases,
IGCTensor output,
const PadStrideInfo conv_info,
const ActivationLayerInfo act_info = ActivationLayerInfo() 

Set the input and output tensors.

[in,out]inputSource tensor. 3 lower dimensions represent a single input [width, height, IFM], while every optional dimension from 4 and above represent a batch of inputs. Data types supported: F16/F32. input will be written to only if it is currently left aligned.
[in]weightsWeights tensor. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM]. Data type supported:Same as input.
[in]biasesBiases tensor. Shared biases supported. Biases are 1D tensor with dimensions [OFM]. Data type supported:Same as input.
[out]outputDestination tensor. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. Data types supported: Same as input.
[in]conv_infoContains padding and stride information described in PadStrideInfo.
[in]act_info(Optional) Activation layer information in case of a fused activation.

Definition at line 41 of file GCDirectConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR, GCFillBorderKernel::configure(), GCTensorShiftKernel::configure(), arm_compute::CONSTANT, ITensorInfo::dimension(), and ITensor::info().

43 {
44  int kernel_size = weights->info()->dimension(0);
46  if(kernel_size == 1)
47  {
48  auto k = std::make_unique<GCDirectConvolutionLayer1x1Kernel>();
49  k->configure(input, weights, biases, output, conv_info, act_info);
50  _kernel = std::move(k);
51  }
52  else if(kernel_size == 3)
53  {
54  auto k = std::make_unique<GCDirectConvolutionLayer3x3Kernel>();
55  k->configure(input, weights, biases, output, conv_info, act_info);
56  _kernel = std::move(k);
57  }
58  else if(kernel_size == 5)
59  {
60  auto k = std::make_unique<GCDirectConvolutionLayer5x5Kernel>();
61  k->configure(input, weights, biases, output, conv_info, act_info);
62  _kernel = std::move(k);
63  }
64  else
65  {
66  ARM_COMPUTE_ERROR("kernel size unsupported!");
67  return;
68  }
70  _border_handler.configure(input, _kernel->border_size(), BorderMode::CONSTANT, PixelValue());
72  _shift_handler.configure(input);
73 }
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
void configure(const IGCTensor *tensor, BorderSize border_size, BorderMode border_mode, const PixelValue &constant_border_value=PixelValue())
Initialise the kernel&#39;s input, output and border mode.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
void configure(IGCTensor *input)
Set the input of the kernel.

◆ run()

void run ( )

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.
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.
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 75 of file GCDirectConvolutionLayer.cpp.

References GCScheduler::dispatch(), GCScheduler::get(), and GCScheduler::memory_barrier().

76 {
77  GCScheduler::get().dispatch(_shift_handler, false);
79  GCScheduler::get().dispatch(_border_handler, false);
81  GCScheduler::get().dispatch(*_kernel);
83  GCScheduler::get().dispatch(_shift_handler);
84 }
void dispatch(IGCKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: GCScheduler.cpp:77
void memory_barrier()
Defines a barrier ordering memory transactions.
Definition: GCScheduler.cpp:86
static GCScheduler & get()
Access the scheduler singleton.
Definition: GCScheduler.cpp:70

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