Compute Library
 21.08
CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols > Class Template Referencefinal

Kernel to perform Winograd weights transform. More...

#include <CpuWinogradConv2dKernel.h>

Collaboration diagram for CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols >:
[legend]

Public Member Functions

 CpuWinogradConv2dTransformWeightsKernel (const CpuWinogradConv2dTransformWeightsKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CpuWinogradConv2dTransformWeightsKerneloperator= (const CpuWinogradConv2dTransformWeightsKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CpuWinogradConv2dTransformWeightsKernel (CpuWinogradConv2dTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
CpuWinogradConv2dTransformWeightsKerneloperator= (CpuWinogradConv2dTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~CpuWinogradConv2dTransformWeightsKernel ()=default
 Default destructor. More...
 
 CpuWinogradConv2dTransformWeightsKernel ()
 Default constructor. More...
 
const char * name () const override
 Name of the kernel. More...
 
unsigned int get_weight_storage_size (int num_output_channels, int num_input_channels) const override
 Determine how much memory (in units of T) to allocate for the transformed weights. More...
 
int get_matrix_stride (int num_output_channels, int num_input_channels) const override
 Gets the stride between matrices in the input worspace. More...
 
void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
bool is_parallelisable () const override
 Indicates whether or not the kernel is parallelisable. More...
 
- Public Member Functions inherited from ICpuWinogradConv2dTransformWeightsKernel
 ICpuWinogradConv2dTransformWeightsKernel (const ICpuWinogradConv2dTransformWeightsKernel &)=default
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICpuWinogradConv2dTransformWeightsKerneloperator= (const ICpuWinogradConv2dTransformWeightsKernel &)=default
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICpuWinogradConv2dTransformWeightsKernel (ICpuWinogradConv2dTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
ICpuWinogradConv2dTransformWeightsKerneloperator= (ICpuWinogradConv2dTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ICpuWinogradConv2dTransformWeightsKernel ()
 
virtual ~ICpuWinogradConv2dTransformWeightsKernel ()
 
virtual void configure (const ITensorInfo *weights_hwio, ITensorInfo *output, const int matrix_stride, const int num_output_channels, const int num_input_channels)=0
 Configure the weights transform kernel. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run (const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
 Static function to check if given info will lead to a valid configuration of CpuWinogradConv2dTransformWeightsKernel. More...
 
- Static Public Member Functions inherited from ICpuWinogradConv2dTransformWeightsKernel
static Status validate (const ITensorInfo *input, const ITensorInfo *weights)
 Static function to check if given info will lead to a valid configuration of CpuWinogradConv2dTransformWeightsKernel. More...
 

Detailed Description

template<typename T, int OutputTileRows, int OutputTileCols, int KernelRows, int KernelCols>
class arm_compute::cpu::CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols >

Kernel to perform Winograd weights transform.

Definition at line 480 of file CpuWinogradConv2dKernel.h.

Constructor & Destructor Documentation

◆ CpuWinogradConv2dTransformWeightsKernel() [1/3]

CpuWinogradConv2dTransformWeightsKernel ( const CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols > &  )
delete

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

◆ CpuWinogradConv2dTransformWeightsKernel() [2/3]

CpuWinogradConv2dTransformWeightsKernel ( CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols > &&  )
default

Allow instances of this class to be moved.

◆ ~CpuWinogradConv2dTransformWeightsKernel()

Default destructor.

◆ CpuWinogradConv2dTransformWeightsKernel() [3/3]

Default constructor.

Definition at line 202 of file CpuWinogradConv2dKernel.cpp.

203  : _transform(nullptr), _num_output_channels(0), _matrix_stride(0)
204 {
205 }

Member Function Documentation

◆ get_matrix_stride()

int get_matrix_stride ( int  num_output_channels,
int  num_input_channels 
) const
overridevirtual

Gets the stride between matrices in the input worspace.

Parameters
[in]num_output_channelsNumber of output feature maps.
[in]num_input_channelsNumber of input feature maps.
Returns
Stride expressed in bytes.

Implements ICpuWinogradConv2dTransformWeightsKernel.

Definition at line 208 of file CpuWinogradConv2dKernel.cpp.

References ARM_COMPUTE_UNUSED, ICpuWinogradConv2dTransformWeightsKernel::configure(), Window::DimX, and Window::set().

209 {
210  return WinogradConv::get_kernel_matrix_stride(num_input_channels, num_output_channels);
211 }

◆ get_weight_storage_size()

unsigned int get_weight_storage_size ( int  num_output_channels,
int  num_input_channels 
) const
overridevirtual

Determine how much memory (in units of T) to allocate for the transformed weights.

Parameters
[in]num_output_channelsNumber of output feature maps.
[in]num_input_channelsNumber of input feature maps.
Returns
Storage size (in units of T) required.

Implements ICpuWinogradConv2dTransformWeightsKernel.

Definition at line 194 of file CpuWinogradConv2dKernel.cpp.

References arm_compute::test::validation::shape.

195 {
196  const KernelShape shape(num_output_channels, KernelRows, KernelCols, num_input_channels);
197  return static_cast<unsigned int>(
198  WinogradConv::get_kernel_storage_size(num_input_channels, num_output_channels));
199 }

◆ is_parallelisable()

bool is_parallelisable ( ) const
overridevirtual

Indicates whether or not the kernel is parallelisable.

If the kernel is parallelisable then the window returned by window() can be split into sub-windows which can then be run in parallel.

If the kernel is not parallelisable then only the window returned by window() can be passed to run()

Returns
True if the kernel is parallelisable

Reimplemented from IKernel.

Definition at line 257 of file CpuWinogradConv2dKernel.cpp.

258 {
259  return false;
260 }

◆ name()

const char* name ( ) const
inlineoverridevirtual

◆ operator=() [1/2]

CpuWinogradConv2dTransformWeightsKernel& operator= ( const CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols > &  )
delete

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

◆ operator=() [2/2]

CpuWinogradConv2dTransformWeightsKernel& operator= ( CpuWinogradConv2dTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols > &&  )
default

Allow instances of this class to be moved.

◆ run_op()

void run_op ( ITensorPack tensors,
const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]tensorsA vector containing the tensors to operate on.
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Reimplemented from ICPPKernel.

Definition at line 236 of file CpuWinogradConv2dKernel.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensor::buffer(), ITensorPack::empty(), Window::Dimension::end(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), arm_gemm::roundup(), Window::Dimension::start(), and Window::x().

237 {
240  ARM_COMPUTE_ERROR_ON(tensors.empty());
241 
242  const size_t fst = window.x().start();
243  const size_t lst = window.x().end();
244 
245  const ITensor *weights_hwio = tensors.get_const_tensor(TensorType::ACL_SRC);
246  ITensor *output = tensors.get_tensor(TensorType::ACL_DST);
247 
248  _transform->set_weight_tensor(weights_hwio->buffer());
249  const int matrix_row_stride = roundup(_num_output_channels, WinogradConv::N_BLOCK);
250  _transform->set_output_matrices(output->buffer(), _matrix_stride, matrix_row_stride);
251  _transform->set_working_space(output->buffer());
252 
253  _transform->run(fst, lst);
254 }
T roundup(const T a, const T b)
Definition: utils.hpp:70
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#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
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:94
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const WinogradInfo winograd_info 
)
static

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

Parameters
[in]inputSource tensor info. The input is a 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] (NCHW data layout). kernel_x must be 3 and equal to kernel_y. Data types supported: F16/F32.
[in]outputDestination tensor info. The output is a 3D tensor with dimensions [OFM, IFM, 16] or [OFM, IFM, 36]. Data type supported: same as input
[in]winograd_infoContains Winograd's information described in WinogradInfo
Returns
a status

Definition at line 263 of file CpuWinogradConv2dKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, and ICloneable< T >::clone().

265 {
266  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_weight_trans(input, output, winograd_info));
267  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_winograd_weight_trans(input->clone().get(), output->clone().get(), winograd_info).first);
268  return Status{};
269 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

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