Compute Library
 19.08
NEPermuteKernel Class Reference

NEON kernel to perform tensor permutation. More...

#include <NEPermuteKernel.h>

Collaboration diagram for NEPermuteKernel:
[legend]

Public Member Functions

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

Detailed Description

NEON kernel to perform tensor permutation.

Permutes given a permutation vector

Definition at line 37 of file NEPermuteKernel.h.

Constructor & Destructor Documentation

◆ NEPermuteKernel() [1/3]

Default constructor.

Definition at line 237 of file NEPermuteKernel.cpp.

238  : _func(), _input(nullptr), _output(nullptr), _perm()
239 {
240 }

◆ NEPermuteKernel() [2/3]

NEPermuteKernel ( const NEPermuteKernel )
delete

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

◆ NEPermuteKernel() [3/3]

NEPermuteKernel ( NEPermuteKernel &&  )
default

Allow instances of this class to be moved.

◆ ~NEPermuteKernel()

~NEPermuteKernel ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output,
const PermutationVector perm 
)

Set the input and output of the kernel.

Note
Supported permutation vectors : [2, 0, 1], [1, 2, 0]
Parameters
[in]inputThe input tensor to permute. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32
[out]outputThe output tensor. Data types supported: Same as input
[in]permPermutation vector

Definition at line 242 of file NEPermuteKernel.cpp.

243 {
244  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
246  // Output auto inizialitation if not yet initialized
247  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(output_shape));
248 
249  // Perform validation step
250  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), perm));
251 
252  _input = input;
253  _output = output;
254  _perm = perm;
255 
256  switch(input->info()->element_size())
257  {
258  case 1:
259  _func = &NEPermuteKernel::run_permute<uint8_t>;
260  break;
261  case 2:
262  _func = &NEPermuteKernel::run_permute<uint16_t>;
263  break;
264  case 4:
265  _func = &NEPermuteKernel::run_permute<uint32_t>;
266  break;
267  default:
268  ARM_COMPUTE_ERROR("Element size not supported");
269  break;
270  }
271 
272  // Configure kernel window
273  Window win = calculate_max_window(*input->info(), Steps());
274 
275  // The NEPermute doesn't need padding so update_window_and_padding() can be skipped
276  Coordinates coord;
277  coord.set_num_dimensions(output->info()->num_dimensions());
278  output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
279 
280  ICPPKernel::configure(win);
281 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
Shape of a tensor.
Definition: TensorShape.h:39
TensorShape compute_permutation_output_shape(const ITensorInfo &input, const PermutationVector &perm)
Calculate the permuted shape of an input given a permutation vector.
#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
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the 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:201
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Coordinates of an item.
Definition: Coordinates.h:37
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
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_NULLPTR(...)
Definition: Validate.h:161
void set_num_dimensions(size_t num_dimensions)
Set number of dimensions.
Definition: Dimensions.h:128
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_permutation_output_shape(), ITensorInfo::element_size(), ITensor::info(), ITensorInfo::num_dimensions(), arm_compute::test::validation::output_shape, Dimensions< T >::set_num_dimensions(), ITensorInfo::set_valid_region(), and ITensorInfo::tensor_shape().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 40 of file NEPermuteKernel.h.

41  {
42  return "NEPermuteKernel";
43  }

◆ operator=() [1/2]

NEPermuteKernel& operator= ( const NEPermuteKernel )
delete

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

◆ operator=() [2/2]

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

290 {
294 
295  if(_func != nullptr)
296  {
297  (this->*_func)(window);
298  }
299 }
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,
const PermutationVector perm 
)
static

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

Note
Supported permutation vectors : [2, 0, 1], [1, 2, 0]
Parameters
[in]inputThe input tensor to permute. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32
[in]outputThe output tensor. Data types supported: Same as input
[in]permPermutation vector
Returns
a status

Definition at line 283 of file NEPermuteKernel.cpp.

284 {
285  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, perm));
286  return Status{};
287 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
Status class.
Definition: Error.h:52

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NEPermute::validate().


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