Compute Library
 22.08
CpuDepthwiseConv2dAssemblyDispatch Class Reference

Depthwise convolution assembly kernel glue. More...

#include <CpuDepthwiseConv2dAssemblyDispatch.h>

Collaboration diagram for CpuDepthwiseConv2dAssemblyDispatch:
[legend]

Public Member Functions

 CpuDepthwiseConv2dAssemblyDispatch ()
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuDepthwiseConv2dAssemblyDispatch)
 
 ~CpuDepthwiseConv2dAssemblyDispatch ()
 
void configure (const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *bias, ITensorInfo *dst, const ConvolutionInfo &info)
 Initialize the function's source, destination, kernels and border_size. 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...
 
experimental::MemoryRequirements workspace () const override
 Return the memory requirements required by the workspace. 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...
 
- 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 *bias, const ITensorInfo *dst, const ConvolutionInfo &info)
 Static function to check if given info will lead to a valid configuration. More...
 
static bool is_activation_supported (const ActivationLayerInfo &activation)
 Checks if activation is supported by the assembly kernels. More...
 

Detailed Description

Depthwise convolution assembly kernel glue.

Definition at line 35 of file CpuDepthwiseConv2dAssemblyDispatch.h.

Constructor & Destructor Documentation

◆ CpuDepthwiseConv2dAssemblyDispatch()

◆ ~CpuDepthwiseConv2dAssemblyDispatch()

Member Function Documentation

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( CpuDepthwiseConv2dAssemblyDispatch  )

◆ configure()

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

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

Note
Supports only NHWC format
Parameters
[in]srcSource tensor info. Data type supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]weightsWeights tensor info. These are 3D tensors with shape [W, H, IFM]. Data type supported: same as src or QASYMM8/QASYMM8_SIGNED/QSYMM8_PER_CHANNEL when src is QASYMM8/QASYMM8_SIGNED.
[in]bias(Optional) Biases tensor info. A 1D tensor with shape [IFM]. Must be nullptr if not needed. Data type supported: same as src or S32 if src is quantized.
[out]dstDestination tensor info. Data type supported: same as src.
[in]infoDepthwise convolution meta-data.

Definition at line 55 of file CpuDepthwiseConv2dAssemblyDispatch.cpp.

References arm_compute::ACL_INT_0, arm_compute::ACL_INT_1, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_LOG_PARAMS, ci, IScheduler::cpu_info(), ITensorInfo::dimension(), Scheduler::get(), IScheduler::num_threads(), and CpuDepthwiseConv2dAssemblyDispatch::validate().

60 {
61  ARM_COMPUTE_LOG_PARAMS(src, weights, bias, dst, info);
62  const CPUInfo &ci = NEScheduler::get().cpu_info();
63  const unsigned int num_threads = NEScheduler::get().num_threads();
64  _pImpl->is_prepared = false;
65 
66  // If we don't support a combination of data types, silently return: it is the caller's responsibility to check if configure() was successful via is_configured()
68  {
69  return;
70  }
71 
72  auto dwc_wrapper = std::make_unique<kernels::CpuDepthwiseConv2dAssemblyWrapperKernel>();
73  ARM_COMPUTE_ERROR_ON(dwc_wrapper == nullptr);
74  dwc_wrapper->configure(src, weights, bias, dst, info, ci);
75 
76  // Compute memory requirements for assembly kernels
77  constexpr size_t alignment = 4096;
78  _pImpl->mem_req.push_back({ TensorType::ACL_INT_0, dwc_wrapper->get_working_size(num_threads, src->dimension(0)), alignment });
79  _pImpl->mem_req.push_back({ TensorType::ACL_INT_1, dwc_wrapper->get_storage_size(), alignment });
80  _pImpl->asm_kernel = std::move(dwc_wrapper);
81 }
#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
CPUInfo & cpu_info()
Get CPU info.
Definition: IScheduler.cpp:41
SimpleTensor< float > src
Definition: DFT.cpp:155
const CPUInfo & ci
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_LOG_PARAMS(...)
virtual unsigned int num_threads() const =0
Returns the number of threads that the SingleThreadScheduler has in its pool.
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *bias, const ITensorInfo *dst, const ConvolutionInfo &info)
Static function to check if given info will lead to a valid configuration.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94
const int32_t * bias

◆ is_activation_supported()

bool is_activation_supported ( const ActivationLayerInfo activation)
static

Checks if activation is supported by the assembly kernels.

Parameters
[in]activationActivation to check
Returns
True if activation is supported else false

Definition at line 93 of file CpuDepthwiseConv2dAssemblyDispatch.cpp.

References arm_compute::assembly_utils::map_to_arm_gemm_activation(), Activation::None, and Activation::type.

94 {
97 }
arm_gemm::Activation map_to_arm_gemm_activation(const ActivationLayerInfo &act)
Performs a mapping between Compute Library ActivationLayerInfo and the assembly Activation structure...

◆ 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 108 of file CpuDepthwiseConv2dAssemblyDispatch.cpp.

References arm_compute::ACL_INT_1, arm_compute::ACL_SRC_1, arm_compute::ACL_SRC_2, bias, ITensor::buffer(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), ITensor::info(), ITensor::mark_as_unused(), ITensorInfo::offset_first_element_in_bytes(), ITensorInfo::padding(), ITensorInfo::tensor_shape(), and arm_compute::test::validation::weights_shape.

109 {
110  if(!_pImpl->is_prepared)
111  {
112  // Pack weights and bias
113  const ITensor *weights = tensors.get_const_tensor(TensorType::ACL_SRC_1);
114  const ITensor *bias = tensors.get_const_tensor(TensorType::ACL_SRC_2);
115  ITensor *storage = tensors.get_tensor(TensorType::ACL_INT_1);
116 
117  const auto weights_ptr = weights->buffer() + weights->info()->offset_first_element_in_bytes();
118  const auto bias_ptr = (bias) ? bias->buffer() + bias->info()->offset_first_element_in_bytes() : nullptr;
119  auto parameters_ptr = storage->buffer() + storage->info()->offset_first_element_in_bytes();
120 
121  const auto weights_shape = weights->info()->tensor_shape();
122  const auto weights_padding = weights->info()->padding();
123 
124  const size_t ld_weights_col = weights_shape[0] + weights_padding.left + weights_padding.right;
125  const size_t ld_weights_row = ld_weights_col * (weights_shape[1] + weights_padding.top + weights_padding.bottom);
126  _pImpl->asm_kernel->pack_parameters(parameters_ptr, bias_ptr, weights_ptr, ld_weights_col, ld_weights_row);
127 
128  weights->mark_as_unused();
129  if(bias != nullptr)
130  {
131  bias->mark_as_unused();
132  }
133  _pImpl->is_prepared = true;
134  }
135 }
const int32_t * bias

◆ 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 99 of file CpuDepthwiseConv2dAssemblyDispatch.cpp.

References ARM_COMPUTE_ERROR_ON_MSG, Window::DimY, ITensorPack::empty(), Scheduler::get(), CpuDepthwiseConv2d::prepare(), and IScheduler::schedule_op().

100 {
101  ARM_COMPUTE_ERROR_ON_MSG(tensors.empty(), "No inputs provided");
102 
103  prepare(tensors);
104 
105  NEScheduler::get().schedule_op(_pImpl->asm_kernel.get(), Window::DimY, _pImpl->asm_kernel->window(), tensors);
106 }
virtual void schedule_op(ICPPKernel *kernel, const Hints &hints, const Window &window, ITensorPack &tensors)=0
Runs the kernel in the same thread as the caller synchronously.
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
void prepare(ITensorPack &tensors) override
Prepare the function for executing.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94

◆ validate()

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

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

Similar to CpuDepthwiseConv2dAssemblyDispatch::configure()

Returns
a status

Definition at line 83 of file CpuDepthwiseConv2dAssemblyDispatch.cpp.

References CpuDepthwiseConv2dAssemblyWrapperKernel::validate().

Referenced by CpuDepthwiseConv2dAssemblyDispatch::configure().

84 {
86 }
static Status validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *bias, const ITensorInfo *dst, const ConvolutionInfo &info)
Indicates whether or not this function can be used to process the given parameters.
SimpleTensor< float > src
Definition: DFT.cpp:155
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
const int32_t * bias

◆ workspace()

experimental::MemoryRequirements workspace ( ) const
overridevirtual

Return the memory requirements required by the workspace.

Reimplemented from INEOperator.

Definition at line 88 of file CpuDepthwiseConv2dAssemblyDispatch.cpp.

89 {
90  return _pImpl->mem_req;
91 }

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