Compute Library
 21.05
NEReverseKernel Class Reference

Interface for the reverse layer kernel. More...

#include <NEReverseKernel.h>

Collaboration diagram for NEReverseKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEReverseKernel ()
 Default constructor. More...
 
 NEReverseKernel (const NEReverseKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEReverseKerneloperator= (const NEReverseKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEReverseKernel (NEReverseKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEReverseKerneloperator= (NEReverseKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEReverseKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output, const ITensor *axis)
 Initialise the kernel's inputs 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 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 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...
 
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 ITensorInfo *axis)
 Static function to check if given info will lead to a valid configuration of NEReverseKernel. More...
 

Detailed Description

Interface for the reverse layer kernel.

Definition at line 34 of file NEReverseKernel.h.

Constructor & Destructor Documentation

◆ NEReverseKernel() [1/3]

Default constructor.

Definition at line 58 of file NEReverseKernel.cpp.

59  : _input(nullptr), _output(nullptr), _axis(nullptr)
60 {
61 }

◆ NEReverseKernel() [2/3]

NEReverseKernel ( const NEReverseKernel )
delete

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

◆ NEReverseKernel() [3/3]

NEReverseKernel ( NEReverseKernel &&  )
default

Allow instances of this class to be moved.

◆ ~NEReverseKernel()

~NEReverseKernel ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output,
const ITensor axis 
)

Initialise the kernel's inputs and output.

Parameters
[in]inputInput tensor. Data types supported: All
[out]outputOutput tensor. Data type supported: Same as input
[in]axisAxis tensor. Contains the indices of the dimensions to reverse. Data type supported: U32

Definition at line 63 of file NEReverseKernel.cpp.

64 {
65  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, axis);
66 
67  _input = input;
68  _output = output;
69  _axis = axis;
70 
71  // Output tensor auto initialization if not yet initialized
72  auto_init_if_empty(*output->info(), *input->info()->clone());
73 
74  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis->info()));
75 
76  // Configure kernel window
77  INEKernel::configure(calculate_max_window(*output->info()));
78 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
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...
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ITensor::info(), arm_compute::test::validation::input, and arm_compute::validate_arguments().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 37 of file NEReverseKernel.h.

38  {
39  return "NEReverseKernel";
40  }

◆ operator=() [1/2]

NEReverseKernel& operator= ( const NEReverseKernel )
delete

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

◆ operator=() [2/2]

NEReverseKernel& operator= ( NEReverseKernel &&  )
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 145 of file NEReverseKernel.cpp.

146 {
150 
151  switch(_input->info()->element_size())
152  {
153  case 4:
154  run_reverse<uint32_t>(window, _input, _axis, _output);
155  break;
156  case 2:
157  run_reverse<uint16_t>(window, _input, _axis, _output);
158  break;
159  case 1:
160  run_reverse<uint8_t>(window, _input, _axis, _output);
161  break;
162  default:
163  ARM_COMPUTE_ERROR("Element size not supported");
164  }
165 }
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
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::element_size(), ITensor::info(), arm_compute::test::validation::info, and IKernel::window().

◆ validate()

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

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

Parameters
[in]inputInput tensor info. Data types supported: All
[in]outputOutput tensor info. Data type supported: Same as input
[in]axisAxis tensor info. Contains the indices of the dimensions to reverse. Data type supported: U32
Returns
a status

Definition at line 80 of file NEReverseKernel.cpp.

81 {
83 
84  return Status{};
85 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)

References ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::test::validation::input, and arm_compute::validate_arguments().

Referenced by NEReverse::validate().


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