Compute Library
 19.08
NEReductionOperationKernel Class Reference

NEON kernel to perform a reduction operation. More...

#include <NEReductionOperationKernel.h>

Collaboration diagram for NEReductionOperationKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEReductionOperationKernel ()
 Default constructor. More...
 
 NEReductionOperationKernel (const NEReductionOperationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEReductionOperationKerneloperator= (const NEReductionOperationKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEReductionOperationKernel (NEReductionOperationKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEReductionOperationKerneloperator= (NEReductionOperationKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEReductionOperationKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output, unsigned int axis, ReductionOperation op)
 Set the source, destination of the kernel. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
BorderSize border_size () const override
 The size of the border for that kernel. 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...
 
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, unsigned int axis, ReductionOperation op)
 Static function to check if given info will lead to a valid configuration of NEReductionOperationKernel. More...
 

Detailed Description

NEON kernel to perform a reduction operation.

Definition at line 34 of file NEReductionOperationKernel.h.

Constructor & Destructor Documentation

◆ NEReductionOperationKernel() [1/3]

Default constructor.

Definition at line 1226 of file NEReductionOperationKernel.cpp.

1227  : _input(nullptr), _output(nullptr), _reduction_axis(0), _op(ReductionOperation::SUM_SQUARE), _border_size()
1228 {
1229 }

References arm_compute::SUM_SQUARE.

◆ NEReductionOperationKernel() [2/3]

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

◆ NEReductionOperationKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEReductionOperationKernel()

Default destructor.

Member Function Documentation

◆ border_size()

BorderSize border_size ( ) const
overridevirtual

The size of the border for that kernel.

Returns
The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 1231 of file NEReductionOperationKernel.cpp.

1232 {
1233  return _border_size;
1234 }

Referenced by NEReductionOperation::configure(), and NEArgMinMaxLayer::configure().

◆ configure()

void configure ( const ITensor input,
ITensor output,
unsigned int  axis,
ReductionOperation  op 
)

Set the source, destination of the kernel.

Parameters
[in]inputSource tensor. Data type supported: QASYMM8/F16/F32. Data layouts supported: NCHW.
[out]outputDestination tensor.Data types and data layouts supported: same as input. Output will have the same number of dimensions as input.
[in]axisAxis along which to reduce. Supported reduction axis : 0
[in]opReduction operation to perform.

Definition at line 1236 of file NEReductionOperationKernel.cpp.

1237 {
1238  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
1239 
1240  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op));
1241 
1242  unsigned int num_elems_processed_per_iteration = 16 / data_size_from_type(input->info()->data_type());
1243 
1244  _input = input;
1245  _output = output;
1246  _border_size = (axis == 0) ? BorderSize(0, num_elems_processed_per_iteration - (input->info()->dimension(0) % num_elems_processed_per_iteration), 0, 0) : BorderSize();
1247  _op = op;
1248  _reduction_axis = axis;
1249 
1250  // Configure kernel window
1251  auto win_config = validate_and_configure_window(_input->info(), _output->info(), axis, op);
1252 
1253  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
1254 
1255  INEKernel::configure(std::get<1>(win_config));
1256 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
size_t data_size_from_type(DataType data_type)
The size in bytes of the data type.
Definition: Utils.h:109
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::test::validation::axis, arm_compute::data_size_from_type(), ITensorInfo::data_type(), ITensorInfo::dimension(), ITensor::info(), and arm_compute::validate_and_configure_window().

Referenced by NEReductionOperation::configure(), and NEArgMinMaxLayer::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 37 of file NEReductionOperationKernel.h.

38  {
39  return "NEReductionOperationKernel";
40  }

◆ operator=() [1/2]

NEReductionOperationKernel& operator= ( const NEReductionOperationKernel )
delete

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

◆ operator=() [2/2]

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.

Implements ICPPKernel.

Definition at line 1266 of file NEReductionOperationKernel.cpp.

1267 {
1271 
1272  reduce_op(window, _input, _output, _reduction_axis, _op);
1273 }
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:160
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References 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,
unsigned int  axis,
ReductionOperation  op 
)
static

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

Parameters
[in]inputSource tensor info. Data type supported: QASYMM8/F16/F32. Data layouts supported: NCHW.
[in]outputDestination tensor info.Data types and data layouts supported: same as input. Output will have the same number of dimensions as input.
[in]axisAxis along which to reduce. Supported reduction axis : 0
[in]opReduction operation to perform.
Returns
a status

Definition at line 1258 of file NEReductionOperationKernel.cpp.

1259 {
1260  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op));
1261  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), axis, op)));
1262 
1263  return Status{};
1264 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193

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

Referenced by NEArgMinMaxLayer::validate(), and NEReductionOperation::validate().


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