Compute Library
 19.11
NEGEMMLowpMatrixBReductionKernel Class Reference

NEON kernel used to compute the row-vectors of sums of all the entries in each column of Matrix B. More...

#include <NEGEMMLowpReductionKernel.h>

Collaboration diagram for NEGEMMLowpMatrixBReductionKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
void configure (const ITensor *mtx_b, ITensor *vector_sum_col, int32_t num_mtx_b_rows, bool is_transposed1xW) override
 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 INEGEMMLowpReductionKernel
 INEGEMMLowpReductionKernel ()
 Constructor. More...
 
 INEGEMMLowpReductionKernel (const INEGEMMLowpReductionKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INEGEMMLowpReductionKerneloperator= (const INEGEMMLowpReductionKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INEGEMMLowpReductionKernel (INEGEMMLowpReductionKernel &&)=default
 Allow instances of this class to be moved. More...
 
INEGEMMLowpReductionKerneloperator= (INEGEMMLowpReductionKernel &&)=default
 Allow instances of this class to be moved. 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 *mtx_b, const ITensorInfo *vector_sum_col, int32_t num_mtx_b_rows, bool is_transposed1xW)
 Static function to check if given info will lead to a valid configuration of NEGEMMLowpMatrixBReductionKernel. More...
 

Detailed Description

NEON kernel used to compute the row-vectors of sums of all the entries in each column of Matrix B.

Note
This stage is needed to handle the offset of matrix product https://github.com/google/gemmlowp/blob/master/doc/low-precision.md

Definition at line 112 of file NEGEMMLowpReductionKernel.h.

Member Function Documentation

◆ configure()

void configure ( const ITensor mtx_b,
ITensor vector_sum_col,
int32_t  num_mtx_b_rows,
bool  is_transposed1xW 
)
overridevirtual

Initialise the kernel's input and output.

Parameters
[in]mtx_bInput tensor. Data type supported: Data type supported: QASYMM8/QASYMM8_SIGNED
[out]vector_sum_colOutput row-vector of sums of all the entries in each column of mtx_b. Data type supported: S32
[in]num_mtx_b_rowsNumber of matrix B rows
[in]is_transposed1xWTrue if the input tensor is transposed 1xW

Implements INEGEMMLowpReductionKernel.

Definition at line 272 of file NEGEMMLowpReductionKernel.cpp.

273 {
274  ARM_COMPUTE_ERROR_ON_NULLPTR(mtx_b, vector_sum_col);
275  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments_matrix_b_reduction(mtx_b->info(), vector_sum_col->info()));
276 
277  _input = mtx_b;
278  _output = vector_sum_col;
279  _k = num_mtx_b_rows;
280  _is_reshaped = is_transposed1xW;
281 
282  // Configure kernel window
283  auto win_config = validate_and_configure_window_matrix_b_reduction(_input->info(), _output->info());
284  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
285  INEKernel::configure(win_config.second);
286 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
ITensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Definition: Tensor.cpp:33
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_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, and ITensor::info().

Referenced by NEGEMMLowpMatrixMultiplyCore::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 115 of file NEGEMMLowpReductionKernel.h.

116  {
117  return "NEGEMMLowpMatrixBReductionKernel";
118  }

◆ 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 479 of file NEGEMMLowpReductionKernel.cpp.

480 {
484 
485  switch(_input->info()->data_type())
486  {
487  case DataType::QASYMM8:
488  run_internal<uint8_t>(window, info);
489  break;
492  run_internal<int8_t>(window, info);
493  break;
494  default:
495  ARM_COMPUTE_ERROR("Unsupported data type");
496  }
497 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
quantized, asymmetric fixed-point 8-bit number unsigned
quantized, symmetric per channel fixed-point 8-bit number
quantized, asymmetric fixed-point 8-bit number signed
#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, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, arm_compute::test::validation::info, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM8_PER_CHANNEL, and IKernel::window().

◆ validate()

Status validate ( const ITensorInfo mtx_b,
const ITensorInfo vector_sum_col,
int32_t  num_mtx_b_rows,
bool  is_transposed1xW 
)
static

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

Parameters
[in]mtx_bInput tensor. Data type supported: Data type supported: QASYMM8/QASYMM8_SIGNED
[in]vector_sum_colOutput row-vector of sums of all the entries in each column of mtx_b. Data type supported: S32
[in]num_mtx_b_rowsNumber of matrix B rows
[in]is_transposed1xWTrue if the input tensor is transposed 1xW
Returns
a status

Definition at line 288 of file NEGEMMLowpReductionKernel.cpp.

289 {
290  ARM_COMPUTE_UNUSED(num_mtx_b_rows);
291  ARM_COMPUTE_UNUSED(is_transposed1xW);
292  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments_matrix_b_reduction(mtx_b, vector_sum_col));
293  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window_matrix_b_reduction(mtx_b->clone().get(), vector_sum_col->clone().get()).first);
294 
295  return Status{};
296 }
#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
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.

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

Referenced by NEGEMMLowpMatrixMultiplyCore::validate().


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