Compute Library
 21.02
NEDepthwiseConvolutionLayer Class Reference

Function to execute a depthwise convolution. More...

#include <NEDepthwiseConvolutionLayer.h>

Collaboration diagram for NEDepthwiseConvolutionLayer:
[legend]

Public Member Functions

 NEDepthwiseConvolutionLayer (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 Default constructor. More...
 
 NEDepthwiseConvolutionLayer (const NEDepthwiseConvolutionLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEDepthwiseConvolutionLayer (NEDepthwiseConvolutionLayer &&)=default
 Default move constructor. More...
 
NEDepthwiseConvolutionLayeroperator= (const NEDepthwiseConvolutionLayer &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEDepthwiseConvolutionLayeroperator= (NEDepthwiseConvolutionLayer &&)=default
 Default move assignment operator. More...
 
 ~NEDepthwiseConvolutionLayer ()
 Default destructor. More...
 
void configure (ITensor *input, const ITensor *weights, const ITensor *biases, ITensor *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, weights and convolution information. 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 *biases, const ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier=1, const ActivationLayerInfo &act_info=ActivationLayerInfo(), const Size2D &dilation=Size2D(1U, 1U))
 Static function to check if given info will lead to a valid configuration of NEDepthwiseConvolutionLayer. More...
 

Detailed Description

Function to execute a depthwise convolution.

Definition at line 40 of file NEDepthwiseConvolutionLayer.h.

Constructor & Destructor Documentation

◆ NEDepthwiseConvolutionLayer() [1/3]

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

Default constructor.

Definition at line 340 of file NEDepthwiseConvolutionLayer.cpp.

341  : _depth_conv_func(DepthwiseConvolutionFunction::GENERIC), _func_optimized(std::move(memory_manager)), _func_generic()
342 {
343 }

◆ NEDepthwiseConvolutionLayer() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ NEDepthwiseConvolutionLayer() [3/3]

Default move constructor.

◆ ~NEDepthwiseConvolutionLayer()

Default destructor.

Member Function Documentation

◆ configure()

void configure ( ITensor input,
const ITensor weights,
const ITensor biases,
ITensor 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, weights and convolution information.

Parameters
[in,out]inputSource tensor. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32
[out]outputDestination tensor. Data type supported: same as input.
[in]weightsWeights tensor. These are 3D tensors with shape [kernel_x, kernel_y, IFM]. Data type supported: Same as input or QASYMM8/QASYMM8_SIGNED/QSYMM8_PER_CHANNEL when input is QASYMM8/QASYMM8_SIGNED.
[in]biasesBiases tensor. A 1D tensor with shape [IFM]. Must be nullptr if not needed. Data type supported: Same as input, S32 when input is QASYMM8/QASYMM8_SIGNED.
[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).

Definition at line 345 of file NEDepthwiseConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR, arm_compute::test::validation::conv_info, arm_compute::GENERIC, ITensor::info(), and arm_compute::OPTIMIZED.

347 {
348  _depth_conv_func = get_depthwiseconvolution_function(input->info(), weights->info(), (biases != nullptr) ? biases->info() : nullptr, output->info(), conv_info, depth_multiplier, act_info, dilation);
349  switch(_depth_conv_func)
350  {
352  _func_optimized.configure(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
353  break;
355  _func_generic.configure(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
356  break;
357  default:
358  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
359  }
360 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ operator=() [1/2]

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

Default move assignment operator.

◆ 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 408 of file NEDepthwiseConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR, arm_compute::GENERIC, and arm_compute::OPTIMIZED.

409 {
410  switch(_depth_conv_func)
411  {
413  _func_optimized.prepare();
414  break;
416  _func_generic.prepare();
417  break;
418  default:
419  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
420  }
421 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ 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 393 of file NEDepthwiseConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR, arm_compute::GENERIC, and arm_compute::OPTIMIZED.

394 {
395  switch(_depth_conv_func)
396  {
398  _func_optimized.run();
399  break;
401  _func_generic.run();
402  break;
403  default:
404  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
405  }
406 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo output,
const PadStrideInfo conv_info,
unsigned int  depth_multiplier = 1,
const ActivationLayerInfo act_info = ActivationLayerInfo(),
const Size2D dilation = Size2D(1U, 1U) 
)
static

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

Parameters
[in]inputSource tensor. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32
[in]outputDestination tensor. Data type supported: same as input.
[in]weightsWeights tensor. These are 3D tensors with shape [kernel_x, kernel_y, IFM]. Data type supported: Same as input or QASYMM8/QASYMM8_SIGNED/QSYMM8_PER_CHANNEL when input is QASYMM8/QASYMM8_SIGNED.
[in]biasesBiases tensor. A 1D tensor with shape [IFM]. Must be nullptr if not needed. Data type supported: Same as input, S32 when input is QASYMM8/QASYMM8_SIGNED.
[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).
Returns
a status

Definition at line 362 of file NEDepthwiseConvolutionLayer.cpp.

References ARM_COMPUTE_ERROR, arm_compute::GENERIC, arm_compute::OPTIMIZED, and arm_compute::validate().

Referenced by arm_compute::test::validation::DATA_TEST_CASE().

364 {
365  DepthwiseConvolutionFunction depth_conv_func = get_depthwiseconvolution_function(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
366  switch(depth_conv_func)
367  {
369  return NEDepthwiseConvolutionLayerOptimizedInternal::validate(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
370  break;
372  return NEDepthwiseConvolutionLayerGeneric::validate(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
373  break;
374  default:
375  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
376  }
377 }
DepthwiseConvolutionFunction
Available DepthwiseConvolutionFunction.
Definition: Types.h:148
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
Status validate(const ITensorInfo *scores_in, const ITensorInfo *boxes_in, const ITensorInfo *batch_splits_in, const ITensorInfo *scores_out, const ITensorInfo *boxes_out, const ITensorInfo *classes, const ITensorInfo *batch_splits_out, const ITensorInfo *keeps, const ITensorInfo *keeps_size, const BoxNMSLimitInfo info)

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