Compute Library
 19.08
NETransposeKernel Class Reference

NEON kernel which transposes the elements of a matrix. More...

#include <NETransposeKernel.h>

Collaboration diagram for NETransposeKernel:
[legend]

Public Member Functions

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

Detailed Description

NEON kernel which transposes the elements of a matrix.

[width, height, batch] -> [height, width, batch]

Definition at line 38 of file NETransposeKernel.h.

Constructor & Destructor Documentation

◆ NETransposeKernel() [1/3]

Default constructor.

Definition at line 495 of file NETransposeKernel.cpp.

496  : _func(nullptr), _input(nullptr), _output(nullptr)
497 {
498 }

◆ NETransposeKernel() [2/3]

NETransposeKernel ( const NETransposeKernel )
delete

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

◆ NETransposeKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NETransposeKernel()

~NETransposeKernel ( )
default

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Initialise the kernel's input 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

Definition at line 500 of file NETransposeKernel.cpp.

501 {
502  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
503 
504  // Output tensor auto inizialitation if not yet initialized
505  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(transposed_tensor_shape(input->info()->tensor_shape())));
506 
507  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
508 
509  _input = input;
510  _output = output;
511 
512  switch(input->info()->element_size())
513  {
514  case 1:
515  _func = &transpose_8bit_elements;
516  break;
517  case 2:
518  _func = &transpose_16bit_elements;
519  break;
520  case 4:
521  _func = &transpose_32bit_elements;
522  break;
523  default:
524  ARM_COMPUTE_ERROR("Element size not supported");
525  break;
526  }
527 
528  // Configure kernel window
529  auto win_config = validate_and_configure_window(input->info(), output->info());
530  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
531  INEKernel::configure(win_config.second);
532 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
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
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.
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

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), ICloneable< T >::clone(), ITensorInfo::element_size(), ITensor::info(), ITensorInfo::tensor_shape(), and arm_compute::validate_and_configure_window().

Referenced by NELSTMLayer::configure().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 41 of file NETransposeKernel.h.

42  {
43  return "NETransposeKernel";
44  }

◆ operator=() [1/2]

NETransposeKernel& operator= ( const NETransposeKernel )
delete

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

◆ operator=() [2/2]

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

535 {
539  ARM_COMPUTE_ERROR_ON(_func == nullptr);
540 
541  (*_func)(_input, _output, window);
542 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:337
#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, 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 
)
static

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

Parameters
[in]inputInput tensor. Data types supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32
[in]outputOutput tensor. Data type supported: Same as input
Returns
a status

Definition at line 487 of file NETransposeKernel.cpp.

488 {
489  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
490  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
491  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first);
492  return Status{};
493 }
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
Status class.
Definition: Error.h:52
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::validate_and_configure_window().

Referenced by NETranspose::validate(), and NEFullyConnectedLayerReshapeWeights::validate().


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