Compute Library
 21.02
NEWinogradLayerTransformWeightsKernel< T, OutputTileRows, OutputTileCols, KernelRows, KernelCols > Class Template Referencefinal

Neon kernel to perform Winograd weights transform. More...

#include <NEWinogradConvolutionLayerKernel.h>

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

Public Member Functions

 NEWinogradLayerTransformWeightsKernel (const NEWinogradLayerTransformWeightsKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEWinogradLayerTransformWeightsKerneloperator= (const NEWinogradLayerTransformWeightsKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEWinogradLayerTransformWeightsKernel (NEWinogradLayerTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEWinogradLayerTransformWeightsKerneloperator= (NEWinogradLayerTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEWinogradLayerTransformWeightsKernel ()=default
 Default destructor. More...
 
 NEWinogradLayerTransformWeightsKernel ()
 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 (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 INEWinogradLayerTransformWeightsKernel
 INEWinogradLayerTransformWeightsKernel (const INEWinogradLayerTransformWeightsKernel &)=default
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEWinogradLayerTransformWeightsKerneloperator= (const INEWinogradLayerTransformWeightsKernel &)=default
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEWinogradLayerTransformWeightsKernel (INEWinogradLayerTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
INEWinogradLayerTransformWeightsKerneloperator= (INEWinogradLayerTransformWeightsKernel &&)=default
 Allow instances of this class to be moved. More...
 
 INEWinogradLayerTransformWeightsKernel ()
 
virtual ~INEWinogradLayerTransformWeightsKernel ()
 
virtual void configure (const ITensor *weights_hwio, ITensor *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_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...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. 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...
 

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 NEWinogradLayerTransformWeightsKernel. More...
 
- Static Public Member Functions inherited from INEWinogradLayerTransformWeightsKernel
static Status validate (const ITensorInfo *input, const ITensorInfo *weights)
 Static function to check if given info will lead to a valid configuration of NEWinogradLayerTransformWeightsKernel. More...
 

Detailed Description

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

Neon kernel to perform Winograd weights transform.

Definition at line 500 of file NEWinogradConvolutionLayerKernel.h.

Constructor & Destructor Documentation

◆ NEWinogradLayerTransformWeightsKernel() [1/3]

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

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

◆ NEWinogradLayerTransformWeightsKernel() [2/3]

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

Allow instances of this class to be moved.

◆ ~NEWinogradLayerTransformWeightsKernel()

Default destructor.

◆ NEWinogradLayerTransformWeightsKernel() [3/3]

Default constructor.

Definition at line 203 of file NEWinogradConvolutionLayerKernel.cpp.

204  : _transform(nullptr), _weights_hwio(nullptr), _output(nullptr), _matrix_stride(0), _num_output_channels(0), _num_input_channels(0)
205 {
206 }

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 INEWinogradLayerTransformWeightsKernel.

Definition at line 209 of file NEWinogradConvolutionLayerKernel.cpp.

References INEWinogradLayerTransformWeightsKernel::configure(), and Window::DimX.

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

◆ 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 INEWinogradLayerTransformWeightsKernel.

Definition at line 194 of file NEWinogradConvolutionLayerKernel.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 returns the size in bytes, we divide by `sizeof(T)` to express that in units of T
199  WinogradConv::get_kernel_storage_size(num_input_channels, num_output_channels) / sizeof(T));
200 }

◆ 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 253 of file NEWinogradConvolutionLayerKernel.cpp.

254 {
255  return false;
256 }

◆ name()

◆ operator=() [1/2]

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

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

◆ operator=() [2/2]

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

Allow instances of this class to be moved.

◆ run()

void run ( 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]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 238 of file NEWinogradConvolutionLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensor::buffer(), Window::Dimension::end(), arm_gemm::roundup(), Window::Dimension::start(), and Window::x().

239 {
242  const size_t fst = window.x().start();
243  const size_t lst = window.x().end();
244  _transform->set_weight_tensor(_weights_hwio->buffer());
245  const int matrix_row_stride = roundup(_num_output_channels, WinogradConv::N_BLOCK);
246  _transform->set_output_matrices(_output->buffer(), _matrix_stride, matrix_row_stride);
247  _transform->set_working_space(_output->buffer());
248 
249  _transform->run(fst, lst);
250 }
T roundup(const T a, const T b)
Definition: utils.hpp:45
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory. ...
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
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 NEWinogradLayerTransformWeightsKernel.

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 259 of file NEWinogradConvolutionLayerKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::test::validation::winograd_info.

261 {
262  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_winograd_weight_trans(input, output, winograd_info));
263  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_winograd_weight_trans(input->clone().get(), output->clone().get(), winograd_info).first);
264  return Status{};
265 }
#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: