Compute Library
 19.11
NEGEMMInterleave4x4Kernel Class Reference

NEON kernel to interleave the elements of a matrix. More...

#include <NEGEMMInterleave4x4Kernel.h>

Collaboration diagram for NEGEMMInterleave4x4Kernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEGEMMInterleave4x4Kernel ()
 
void configure (const ITensor *input, ITensor *output)
 Initialise the kernel's input and output. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPSimpleKernel
 ICPPSimpleKernel ()
 Constructor. More...
 
 ICPPSimpleKernel (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
ICPPSimpleKerneloperator= (const ICPPSimpleKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 ICPPSimpleKernel (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
ICPPSimpleKerneloperator= (ICPPSimpleKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~ICPPSimpleKernel ()=default
 Default destructor. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. 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)
 Static function to check if given info will lead to a valid configuration of NEGEMMInterleave4x4Kernel. More...
 

Detailed Description

NEON kernel to interleave the elements of a matrix.

This function puts the values in a 4x4 block of Matrix A on the same row (Interleaved values)

\[ \left( \begin{array}{cccc} a00 & a01 & a02 & a03 \\ a10 & a11 & a12 & a13 \\ a20 & a21 & a22 & a23 \\ a30 & a31 & a32 & a33 \\ \end{array} \right) \rightarrow \left( \begin{array}{ccccccccccccccccc} a00 & a10 & a20 & a30 & a01 & a11 & a21 & a31 & a02 & a12 & a22 & a32 & a03 & a13 & a23 & a33 \\ \end{array} \right) \]

After this operation, the output matrix will have the following shape: [ height * 4, ceil(width / 4.0f) ]

Definition at line 52 of file NEGEMMInterleave4x4Kernel.h.

Constructor & Destructor Documentation

◆ NEGEMMInterleave4x4Kernel()

Definition at line 172 of file NEGEMMInterleave4x4Kernel.cpp.

173  : _func(nullptr)
174 {
175 }

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Initialise the kernel's input and output.

Parameters
[in]inputInput tensor. Data types supported: All
[out]outputOutput tensor which stores the interleaved matrix. Data type supported: same as input.

Definition at line 177 of file NEGEMMInterleave4x4Kernel.cpp.

178 {
180 
181  // Output auto inizialitation if not yet initialized
182  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(compute_interleaved_shape(*input->info())));
183 
184  // Perform validate step
185  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
186 
187  _input = input;
188  _output = output;
189 
190  switch(input->info()->element_size())
191  {
192  case 1:
193  _func = &gemm_interleave_8bit_elements;
194  break;
195  case 2:
196  _func = &gemm_interleave_16bit_elements;
197  break;
198  case 4:
199  _func = &gemm_interleave_32bit_elements;
200  break;
201  default:
202  ARM_COMPUTE_ERROR_ON("Element size not supported");
203  break;
204  }
205 
206  // Configure kernel window
207  auto win_config = validate_and_configure_window(input->info(), output->info());
208  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
209  INEKernel::configure(win_config.second);
210 }
#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_ERROR_THROW_ON(status)
Definition: Error.h:455
TensorShape compute_interleaved_shape(const ITensorInfo &a, int mult_interleave4x4_height=1, bool reinterpret_input_as_3d=false)
Calculate the interleaved shape of an input tensor.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
Definition: Helpers.inl:202
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::misc::shape_calculator::compute_interleaved_shape(), ITensor::info(), and arm_compute::test::validation::input.

Referenced by NEGEMM::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 55 of file NEGEMMInterleave4x4Kernel.h.

56  {
57  return "NEGEMMInterleave4x4Kernel";
58  }

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

Implements ICPPKernel.

Definition at line 220 of file NEGEMMInterleave4x4Kernel.cpp.

221 {
225  ARM_COMPUTE_ERROR_ON(_func == nullptr);
226  /*
227  * This kernel puts the values in a 4x4 block of Matrix A on the same row (Interleaved values)
228  * |a00 a01 a02 a03|
229  * |a10 a11 a12 a13|
230  * |a20 a21 a22 a23| = | a00 a10 a20 a30 || a01 a11 a21 a31 || a02 a12 a22 a32 || a03 a13 a23 a33 |
231  * |a30 a31 a32 a33|
232  *
233  * After this operation, the output matrix will have the following shape: [ height * 4, ceil(width / 4.0f) ]
234  */
235  (*_func)(_input, _output, window);
236 }
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_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::info, and IKernel::window().

◆ validate()

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

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

Parameters
[in]inputInput tensor info. Data types supported: All
[in]outputOutput tensor info which stores the interleaved matrix. Data type supported: same as input.
Returns
a status

Definition at line 212 of file NEGEMMInterleave4x4Kernel.cpp.

213 {
214  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
215  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first);
216 
217  return Status{};
218 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status class.
Definition: Error.h:52
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.

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

Referenced by NEGEMM::validate(), and NEGEMMLowpMatrixMultiplyCore::validate().


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