Compute Library
 22.08
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 44 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 424 of file CpuDepthwiseConv2d.cpp.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_LOG_PARAMS, arm_compute::GENERIC, CpuDepthwiseConv2d::get_depthwiseconvolution_function(), and arm_compute::OPTIMIZED.

425 {
426  ARM_COMPUTE_LOG_PARAMS(src, weights, biases, dst, info);
427 
428  _depth_conv_func = get_depthwiseconvolution_function(src, weights, (biases != nullptr) ? biases : nullptr, dst, info);
429  switch(_depth_conv_func)
430  {
432  _func_optimized.configure(src, weights, biases, dst, info);
433  break;
435  _func_generic.configure(src, weights, biases, dst, info);
436  break;
437  default:
438  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
439  }
440 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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.
SimpleTensor< float > src
Definition: DFT.cpp:155
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_PARAMS(...)

◆ 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 458 of file CpuDepthwiseConv2d.cpp.

References arm_compute::GENERIC, arm_compute::OPTIMIZED, and arm_compute::experimental::dynamic_fusion::validate().

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

460 {
461  if(bool(CpuDepthwiseConv2dOptimizedInternal::validate(src, weights, biases, dst, info)))
462  {
464  }
465  else
466  {
468  }
469 }
Status validate(const OperatorGraph &op_graph)
Return the validity of op_graph, usually after performing an operation (e.g.
SimpleTensor< float > src
Definition: DFT.cpp:155
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

◆ 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 486 of file CpuDepthwiseConv2d.cpp.

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

Referenced by CpuDepthwiseConv2dAssemblyDispatch::run().

487 {
488  switch(_depth_conv_func)
489  {
491  _func_optimized.prepare(tensors);
492  break;
494  _func_generic.prepare(tensors);
495  break;
496  default:
497  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
498  }
499 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ 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 471 of file CpuDepthwiseConv2d.cpp.

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

472 {
473  switch(_depth_conv_func)
474  {
476  _func_optimized.run(tensors);
477  break;
479  _func_generic.run(tensors);
480  break;
481  default:
482  ARM_COMPUTE_ERROR("DepthwiseConvolutionFunction not properly configured");
483  }
484 }
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352

◆ 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 442 of file CpuDepthwiseConv2d.cpp.

References ARM_COMPUTE_ERROR, arm_compute::GENERIC, CpuDepthwiseConv2d::get_depthwiseconvolution_function(), arm_compute::OPTIMIZED, and arm_compute::experimental::dynamic_fusion::validate().

Referenced by NEDepthwiseConvolutionLayer::validate().

443 {
444  DepthwiseConvolutionFunction depth_conv_func = get_depthwiseconvolution_function(src, weights, biases, dst, info);
445  switch(depth_conv_func)
446  {
448  return CpuDepthwiseConv2dOptimizedInternal::validate(src, weights, biases, dst, info);
449  break;
451  return CpuDepthwiseConv2dGeneric::validate(src, weights, biases, dst, info);
452  break;
453  default:
454  ARM_COMPUTE_ERROR("Unsupported DepthwiseConvolutionFunction");
455  }
456 }
Status validate(const OperatorGraph &op_graph)
Return the validity of op_graph, usually after performing an operation (e.g.
DepthwiseConvolutionFunction
Available DepthwiseConvolutionFunction.
Definition: Types.h:144
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
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.
SimpleTensor< float > src
Definition: DFT.cpp:155
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)

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