Compute Library
 19.11
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...
 
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 42 of file NEDepthwiseConvolutionLayer.h.

Constructor & Destructor Documentation

◆ NEDepthwiseConvolutionLayer() [1/3]

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

Default constructor.

Definition at line 538 of file NEDepthwiseConvolutionLayer.cpp.

539  : _depth_conv_func(DepthwiseConvolutionFunction::GENERIC), _func_optimized(std::move(memory_manager)), _func_generic()
540 {
541 }

References arm_compute::GENERIC.

◆ NEDepthwiseConvolutionLayer() [2/3]

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

◆ NEDepthwiseConvolutionLayer() [3/3]

Default move constructor.

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/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/QSYMM8_PER_CHANNEL when input is QASYMM8.
[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.
[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 543 of file NEDepthwiseConvolutionLayer.cpp.

545 {
546  _depth_conv_func = get_depthwiseconvolution_function(input->info(), weights->info(), (biases != nullptr) ? biases->info() : nullptr, output->info(), conv_info, depth_multiplier, act_info, dilation);
547  switch(_depth_conv_func)
548  {
550  _func_optimized.configure(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
551  break;
553  _func_generic.configure(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
554  break;
555  default:
556  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
557  }
558 }
TensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: CLTensor.cpp:41
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

References arm_compute::test::validation::act_info, ARM_COMPUTE_ERROR, arm_compute::test::validation::conv_info, arm_compute::test::validation::dilation, arm_compute::GENERIC, ITensor::info(), CLTensor::info(), arm_compute::test::validation::input, arm_compute::OPTIMIZED, and arm_compute::test::validation::weights.

Referenced by NEDepthwiseConvolutionLayerOptimized::configure().

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

607 {
608  switch(_depth_conv_func)
609  {
611  _func_optimized.prepare();
612  break;
614  _func_generic.prepare();
615  break;
616  default:
617  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
618  }
619 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

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

Referenced by NEDepthwiseConvolutionLayerOptimized::prepare().

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

592 {
593  switch(_depth_conv_func)
594  {
596  _func_optimized.run();
597  break;
599  _func_generic.run();
600  break;
601  default:
602  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
603  }
604 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

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

Referenced by NEDepthwiseConvolutionLayerOptimized::run().

◆ 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/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/QSYMM8_PER_CHANNEL when input is QASYMM8.
[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.
[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 560 of file NEDepthwiseConvolutionLayer.cpp.

562 {
563  DepthwiseConvolutionFunction depth_conv_func = get_depthwiseconvolution_function(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
564  switch(depth_conv_func)
565  {
567  return NEDepthwiseConvolutionLayerOptimized::validate(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
568  break;
570  return NEDepthwiseConvolutionLayerGeneric::validate(input, weights, biases, output, conv_info, depth_multiplier, act_info, dilation);
571  break;
572  default:
573  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
574  }
575 }
DepthwiseConvolutionFunction
Available DepthwiseConvolutionFunction.
Definition: Types.h:143
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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 NEDepthwiseConvolutionLa...
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)

References arm_compute::test::validation::act_info, ARM_COMPUTE_ERROR, arm_compute::test::validation::conv_info, arm_compute::test::validation::dilation, arm_compute::GENERIC, arm_compute::test::validation::input, arm_compute::OPTIMIZED, arm_compute::validate(), NEDepthwiseConvolutionLayerOptimized::validate(), and arm_compute::test::validation::weights.


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