Compute Library
 19.11
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 231 of file NEPermuteKernel.cpp.

232  : _func(), _input(nullptr), _output(nullptr), _perm()
233 {
234 }

◆ 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 236 of file NEPermuteKernel.cpp.

237 {
240  // Output auto inizialitation if not yet initialized
241  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(output_shape));
242 
243  // Perform validation step
244  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), perm));
245 
246  _input = input;
247  _output = output;
248  _perm = perm;
249 
250  switch(input->info()->element_size())
251  {
252  case 1:
253  _func = &NEPermuteKernel::run_permute<uint8_t>;
254  break;
255  case 2:
256  _func = &NEPermuteKernel::run_permute<uint16_t>;
257  break;
258  case 4:
259  _func = &NEPermuteKernel::run_permute<uint32_t>;
260  break;
261  default:
262  ARM_COMPUTE_ERROR("Element size not supported");
263  break;
264  }
265 
266  // Configure kernel window
267  Window win = calculate_max_window(*input->info(), Steps());
268 
269  // The NEPermute doesn't need padding so update_window_and_padding() can be skipped
270  Coordinates coord;
271  coord.set_num_dimensions(output->info()->num_dimensions());
272  output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
273 
274  ICPPKernel::configure(win);
275 }
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(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
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:202
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 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
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:183
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(), arm_compute::misc::shape_calculator::compute_permutation_output_shape(), ITensor::info(), arm_compute::test::validation::input, ITensorInfo::num_dimensions(), arm_compute::test::validation::output_shape, Dimensions< T >::set_num_dimensions(), ITensorInfo::set_valid_region(), and ITensorInfo::tensor_shape().

Referenced by NEGenerateProposalsLayer::configure().

◆ 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 283 of file NEPermuteKernel.cpp.

284 {
288 
289  if(_func != nullptr)
290  {
291  (this->*_func)(window);
292  }
293 }
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:152
#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_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 277 of file NEPermuteKernel.cpp.

278 {
279  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, perm));
280  return Status{};
281 }
#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

References ARM_COMPUTE_RETURN_ON_ERROR, and arm_compute::test::validation::input.

Referenced by NEPermute::validate(), and NEGenerateProposalsLayer::validate().


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