Compute Library
 23.11
CpuDepthwiseConv2d Class Reference

Function to execute a depthwise convolution. More...

#include <CpuDepthwiseConv2d.h>

Collaboration diagram for CpuDepthwiseConv2d:
[legend]

Public Member Functions

 CpuDepthwiseConv2d ()=default
 Default constructor. More...
 
void configure (ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, ITensorInfo *dst, const ConvolutionInfo &info)
 Initialize the function's source, destination, weights and convolution information. More...
 
void run (ITensorPack &tensors) override
 Run the kernels contained in the function. More...
 
void prepare (ITensorPack &tensors) override
 Prepare the function for executing. More...
 
- Public Member Functions inherited from INEOperator
 INEOperator (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 INEOperator (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEOperator (INEOperator &&)=default
 Default move constructor. More...
 
INEOperatoroperator= (const INEOperator &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEOperatoroperator= (INEOperator &&)=default
 Default move assignment operator. More...
 
 ~INEOperator ()
 Default destructor. More...
 
MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. More...
 
- Public Member Functions inherited from IOperator
virtual ~IOperator ()=default
 Destructor. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const ConvolutionInfo &info)
 Static function to check if given info will lead to a valid configuration. More...
 
static DepthwiseConvolutionFunction get_depthwiseconvolution_function (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const ConvolutionInfo &info)
 Static function to choose the best depthwise convolution function for CpuDepthwiseConv2d. More...
 

Detailed Description

Function to execute a depthwise convolution.

Definition at line 45 of file CpuDepthwiseConv2d.h.

Constructor & Destructor Documentation

◆ CpuDepthwiseConv2d()

CpuDepthwiseConv2d ( )
default

Default constructor.

Member Function Documentation

◆ configure()

void configure ( ITensorInfo src,
const ITensorInfo weights,
const ITensorInfo biases,
ITensorInfo dst,
const ConvolutionInfo info 
)

Initialize the function's source, destination, weights and convolution information.

Parameters
[in,out]srcSource tensor info. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32
[out]dstDestination tensor info. Data type supported: same as src.
[in]weightsWeights tensor info. These are 3D tensor infos with shape [kernel_x, kernel_y, IFM]. Data type supported: Same as src or QASYMM8/QASYMM8_SIGNED/QSYMM8_PER_CHANNEL when src is QASYMM8/QASYMM8_SIGNED.
[in]biasesBiases tensor info. A 1D tensor with shape [IFM]. Must be nullptr if not needed. Data type supported: Same as src, S32 when src is QASYMM8/QASYMM8_SIGNED.
[in]infoDepthwise convolution meta-data.

Definition at line 479 of file CpuDepthwiseConv2d.cpp.

484 {
485  ARM_COMPUTE_LOG_PARAMS(src, weights, biases, dst, info);
486 
487  _depth_conv_func =
488  get_depthwiseconvolution_function(src, weights, (biases != nullptr) ? biases : nullptr, dst, info);
489  switch (_depth_conv_func)
490  {
492  _func_optimized.configure(src, weights, biases, dst, info);
493  break;
495  _func_generic.configure(src, weights, biases, dst, info);
496  break;
497  default:
498  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
499  }
500 }

References ARM_COMPUTE_ERROR, ARM_COMPUTE_LOG_PARAMS, arm_compute::test::validation::dst, arm_compute::GENERIC, CpuDepthwiseConv2d::get_depthwiseconvolution_function(), arm_compute::test::validation::info, arm_compute::OPTIMIZED, and arm_compute::test::validation::src.

◆ get_depthwiseconvolution_function()

DepthwiseConvolutionFunction get_depthwiseconvolution_function ( const ITensorInfo src,
const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo dst,
const ConvolutionInfo info 
)
static

Static function to choose the best depthwise convolution function for CpuDepthwiseConv2d.

Parameters
[in]srcSource tensor info. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32
[in]weightsWeights tensor info. These are 3D tensors with shape [kernel_x, kernel_y, IFM]. Data type supported: Same as src or QASYMM8/QASYMM8_SIGNED/QSYMM8_PER_CHANNEL when src is QASYMM8/QASYMM8_SIGNED.
[in]biasesBiases tensor info. A 1D tensor with shape [IFM]. Must be nullptr if not needed. Data type supported: Same as src, S32 when src is QASYMM8/QASYMM8_SIGNED.
[in]dstDestination tensor. Data type supported: same as src.
[in]infoDepthwise convolution meta-data.
Returns
a Depthwise Convolution Function

Definition at line 522 of file CpuDepthwiseConv2d.cpp.

527 {
528  if (bool(CpuDepthwiseConv2dOptimizedInternal::validate(src, weights, biases, dst, info)))
529  {
531  }
532  else
533  {
535  }
536 }

References arm_compute::test::validation::dst, arm_compute::GENERIC, arm_compute::test::validation::info, arm_compute::OPTIMIZED, arm_compute::test::validation::src, and arm_compute::validate().

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

◆ prepare()

void prepare ( ITensorPack constants)
overridevirtual

Prepare the function for executing.

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

Parameters
[in]constantsVector that contains the constants tensors.
Note
Prepare stage might not need all the function's buffers' backing memory to be available in order to execute

Reimplemented from INEOperator.

Definition at line 553 of file CpuDepthwiseConv2d.cpp.

554 {
555  switch (_depth_conv_func)
556  {
558  _func_optimized.prepare(tensors);
559  break;
561  _func_generic.prepare(tensors);
562  break;
563  default:
564  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
565  }
566 }

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

◆ run()

void run ( ITensorPack tensors)
overridevirtual

Run the kernels contained in the function.

Parameters
[in]tensorsVector that contains the tensors to operate on.

Reimplemented from INEOperator.

Definition at line 538 of file CpuDepthwiseConv2d.cpp.

539 {
540  switch (_depth_conv_func)
541  {
543  _func_optimized.run(tensors);
544  break;
546  _func_generic.run(tensors);
547  break;
548  default:
549  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
550  }
551 }

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

◆ validate()

Status validate ( const ITensorInfo src,
const ITensorInfo weights,
const ITensorInfo biases,
const ITensorInfo dst,
const ConvolutionInfo info 
)
static

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

Similar to CpuDepthwiseConv2d::configure()

Returns
a status

Definition at line 502 of file CpuDepthwiseConv2d.cpp.

507 {
508  DepthwiseConvolutionFunction depth_conv_func = get_depthwiseconvolution_function(src, weights, biases, dst, info);
509  switch (depth_conv_func)
510  {
512  return CpuDepthwiseConv2dOptimizedInternal::validate(src, weights, biases, dst, info);
513  break;
515  return CpuDepthwiseConv2dGeneric::validate(src, weights, biases, dst, info);
516  break;
517  default:
518  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
519  }
520 }

References ARM_COMPUTE_ERROR, arm_compute::test::validation::dst, arm_compute::GENERIC, CpuDepthwiseConv2d::get_depthwiseconvolution_function(), arm_compute::test::validation::info, arm_compute::OPTIMIZED, arm_compute::test::validation::src, and arm_compute::validate().

Referenced by NEDepthwiseConvolutionLayer::validate().


The documentation for this class was generated from the following files:
arm_compute::test::validation::src
SimpleTensor< float > src
Definition: DFT.cpp:155
arm_compute::test::validation::dst
auto dst
Definition: DFT.cpp:170
ARM_COMPUTE_ERROR
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:354
arm_compute::DepthwiseConvolutionFunction
DepthwiseConvolutionFunction
Available DepthwiseConvolutionFunction.
Definition: Types.h:102
arm_compute::DepthwiseConvolutionFunction::OPTIMIZED
@ OPTIMIZED
Optimized Depthwise Convolution.
arm_compute::DepthwiseConvolutionFunction::GENERIC
@ GENERIC
Generic Depthwise Convolution.
arm_compute::validate
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)
Definition: CPPBoxWithNonMaximaSuppressionLimit.cpp:243
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
ARM_COMPUTE_LOG_PARAMS
#define ARM_COMPUTE_LOG_PARAMS(...)
Definition: Log.h:35
arm_compute::cpu::CpuDepthwiseConv2d::get_depthwiseconvolution_function
static DepthwiseConvolutionFunction get_depthwiseconvolution_function(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const ConvolutionInfo &info)
Static function to choose the best depthwise convolution function for CpuDepthwiseConv2d.
Definition: CpuDepthwiseConv2d.cpp:522