Compute Library
 19.08
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...
 
- 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, 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 72 of file NEReverseKernel.cpp.

73  : _input(nullptr), _output(nullptr), _axis(nullptr)
74 {
75 }

◆ 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: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32
[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 77 of file NEReverseKernel.cpp.

78 {
79  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output, axis);
80 
81  _input = input;
82  _output = output;
83  _axis = axis;
84 
85  // Output tensor auto initialization if not yet initialized
86  auto_init_if_empty(*output->info(), *input->info()->clone());
87 
88  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis->info()));
89 
90  // Configure kernel window
91  INEKernel::configure(calculate_max_window(*output->info()));
92 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
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:201
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::test::validation::axis, arm_compute::calculate_max_window(), ICloneable< T >::clone(), and ITensor::info().

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

Implements ICPPKernel.

Definition at line 182 of file NEReverseKernel.cpp.

183 {
187 
188  switch(_input->info()->data_type())
189  {
190  case DataType::F32:
191  case DataType::U32:
192  case DataType::S32:
193  run_reverse<uint32_t>(window, _input, _axis, _output);
194  break;
195 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
196  case DataType::F16:
197 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
198  case DataType::S16:
199  case DataType::U16:
200  run_reverse<uint16_t>(window, _input, _axis, _output);
201  break;
202  case DataType::QASYMM8:
203  case DataType::U8:
204  case DataType::S8:
205  run_reverse<uint8_t>(window, _input, _axis, _output);
206  break;
207  default:
208  ARM_COMPUTE_ERROR("Data type not supported");
209  }
210 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
1 channel, 1 U8 per channel
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
1 channel, 1 U16 per channel
1 channel, 1 F16 per channel
1 channel, 1 S32 per channel
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
1 channel, 1 U32 per channel
quantized, asymmetric fixed-point 8-bit number
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
1 channel, 1 S16 per channel
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
signed 8-bit number
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_type(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::test::validation::info, arm_compute::QASYMM8, arm_compute::S16, arm_compute::S32, arm_compute::S8, arm_compute::U16, arm_compute::U32, arm_compute::U8, 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: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32
[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 94 of file NEReverseKernel.cpp.

95 {
96  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis));
97 
98  return Status{};
99 }
#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, and arm_compute::test::validation::axis.

Referenced by NEReverse::validate().


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