Compute Library
GCDepthwiseConvolutionLayer3x3 Class Reference

Basic function to execute a depthwise convolution for kernel size 3x3xC. More...

#include <GCDepthwiseConvolutionLayer.h>

Collaboration diagram for GCDepthwiseConvolutionLayer3x3:

Public Member Functions

 GCDepthwiseConvolutionLayer3x3 ()
 Default constructor. More...
void configure (IGCTensor *input, const IGCTensor *weights, const IGCTensor *biases, IGCTensor *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier=1, const ActivationLayerInfo &act_info=ActivationLayerInfo(), const Size2D &dilation=Size2D(1U, 1U))
 Initialize the function's source, destination, conv and border_size. 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 a depthwise convolution for kernel size 3x3xC.

This function calls the following OpenGLES kernels:

  1. GCDepthwiseConvolutionLayer3x3Kernel
  2. GCFillBorderKernel (if pad_x or pad_y > 0)
This function is deprecated and is intended to be removed in 21.05 release

Definition at line 46 of file GCDepthwiseConvolutionLayer.h.

Constructor & Destructor Documentation

◆ GCDepthwiseConvolutionLayer3x3()

Default constructor.

Definition at line 32 of file GCDepthwiseConvolutionLayer.cpp.

33  : _kernel(nullptr), _border_handler(), _shift_handler(), _activationlayer_function(), _is_activationlayer_enabled(false)
34 {
35 }

Member Function Documentation

◆ configure()

void configure ( IGCTensor input,
const IGCTensor weights,
const IGCTensor biases,
IGCTensor output,
const PadStrideInfo conv_info,
unsigned int  depth_multiplier = 1,
const ActivationLayerInfo act_info = ActivationLayerInfo(),
const Size2D dilation = Size2D(1U, 1U) 

Initialize the function's source, destination, conv and border_size.

[in,out]inputSource tensor. Data type supported: F16. (Written to only for border filling).
[in]weightsWeights tensor. A 3D tensor with shape [3, 3, IFM]. Data type supported: Same as input.
[in]biasesBiases tensor. A 1D tensor with shape [IFM]. Must be nullptr if not needed. Data type supported: Same as input.
[out]outputDestination tensor. Data type supported: same as input.
[in]conv_infoPadding and stride information to use for the convolution.
[in]depth_multiplier(Optional) Multiplier to apply to the input's depth in order to retrieve the output's depth. Defaults to 1.
[in]act_info(Optional) Activation layer information in case of a fused activation.
[in]dilation(Optional) Dilation, in elements, across x and y. Defaults to (1, 1). Currently supports (1,1) only.

Definition at line 37 of file GCDepthwiseConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_UNUSED, GCFillBorderKernel::configure(), GCActivationLayer::configure(), GCTensorShiftKernel::configure(), arm_compute::CONSTANT, ActivationLayerInfo::enabled(), Size2D::x(), and Size2D::y().

39 {
40  ARM_COMPUTE_ERROR_ON(dilation.x() != 1 || dilation.y() != 1);
41  ARM_COMPUTE_UNUSED(dilation);
42  auto k = std::make_unique<GCDepthwiseConvolutionLayer3x3Kernel>();
43  k->configure(input, weights, biases, output, conv_info, depth_multiplier);
44  _kernel = std::move(k);
46  // Configure border handler
47  _border_handler.configure(input, _kernel->border_size(), BorderMode::CONSTANT, PixelValue());
49  _shift_handler.configure(input);
51  //Configure Activation Layer
52  _is_activationlayer_enabled = act_info.enabled();
54  if(_is_activationlayer_enabled)
55  {
56  _activationlayer_function.configure(output, nullptr, act_info);
57  }
58 }
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
bool enabled() const
Check if initialised.
Definition: Types.h:1600
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
size_t x() const
Semantic accessor for width as x.
Definition: Size2D.h:74
To avoid unused variables warnings.
Definition: Error.h:152
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.
size_t y() const
Semantic accessor for height as y.
Definition: Size2D.h:83
void configure(IGCTensor *input, IGCTensor *output, ActivationLayerInfo act_info)
Set the input and output tensor.
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 60 of file GCDepthwiseConvolutionLayer.cpp.

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

61 {
62  GCScheduler::get().dispatch(_shift_handler, false);
64  GCScheduler::get().dispatch(_border_handler, false);
66  GCScheduler::get().dispatch(*_kernel);
68  // Run Activation Layer
69  if(_is_activationlayer_enabled)
70  {
72  }
73 }
void dispatch(IGCKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Definition: GCScheduler.cpp:77
void run() override final
Run the kernels contained in the function.
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: