Compute Library
 19.08
NETileKernel Class Reference

NEON kernel to perform a tile operation. More...

#include <NETileKernel.h>

Collaboration diagram for NETileKernel:
[legend]

Public Member Functions

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

Detailed Description

NEON kernel to perform a tile operation.

Definition at line 34 of file NETileKernel.h.

Constructor & Destructor Documentation

◆ NETileKernel() [1/3]

Default constructor.

Definition at line 59 of file NETileKernel.cpp.

60  : _input(nullptr), _output(nullptr)
61 {
62 }

◆ NETileKernel() [2/3]

NETileKernel ( const NETileKernel )
delete

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

◆ NETileKernel() [3/3]

NETileKernel ( NETileKernel &&  )
default

Allow instances of this class to be moved.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output,
const Multiples multiples 
)

Set the source, destination of the kernel.

Parameters
[in]inputSource tensor. Data type supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
[out]outputDestination tensor. Same as input
[in]multiplesContains the number of times the input tensor should be replicated on the given dimension.

Definition at line 64 of file NETileKernel.cpp.

65 {
66  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
67 
68  // Auto initialize output
69  TensorShape tiled_shape = misc::shape_calculator::compute_tiled_shape(input->info()->tensor_shape(), multiples);
70  auto_init_if_empty(*output->info(), tiled_shape, 1, input->info()->data_type());
71 
72  // Validate
73  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), multiples));
74 
75  _input = input;
76  _output = output;
77 
78  // Configure window without padding
79  Window win = calculate_max_window(*output->info());
80  INEKernel::configure(win);
81 }
#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
TensorShape compute_tiled_shape(const TensorShape &input_shape, const Multiples &multiples)
Calculate the tiled shape of a tensor.
#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::calculate_max_window(), arm_compute::misc::shape_calculator::compute_tiled_shape(), ITensorInfo::data_type(), ITensor::info(), and ITensorInfo::tensor_shape().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 47 of file NETileKernel.h.

48  {
49  return "NETileKernel";
50  }

◆ operator=() [1/2]

NETileKernel& operator= ( const NETileKernel )
delete

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

◆ operator=() [2/2]

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

90 {
94 
95  Window output_window{ window };
96  output_window.set(Window::DimX, Window::Dimension(output_window.x().start(), output_window.x().end(), _input->info()->dimension(0)));
97  Window out_slice = output_window.first_slice_window_1D();
98 
99  const auto src_shape = _input->info()->tensor_shape();
100  do
101  {
102  Iterator output_it(_output, out_slice);
103 
104  execute_window_loop(out_slice, [&](const Coordinates & id)
105  {
106  const size_t x = id.x();
107  const size_t y = id.y();
108  const size_t z = id.z();
109  const size_t w = id[3];
110  Coordinates input_coords{ x % src_shape[0], y % src_shape[1], z % src_shape[2], w % src_shape[3] };
111  memcpy(output_it.ptr(), _input->ptr_to_element(input_coords), _input->info()->dimension(0) * _input->info()->element_size());
112  },
113  output_it);
114  }
115  while(output_window.slide_window_slice_1D(out_slice));
116 }
SimpleTensor< float > w
Definition: DFT.cpp:156
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
Definition: ITensor.h:63
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
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()
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:48
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:122
#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, ITensorInfo::dimension(), Window::DimX, ITensorInfo::element_size(), arm_compute::execute_window_loop(), Window::first_slice_window_1D(), ITensor::info(), arm_compute::test::validation::info, Iterator::ptr(), ITensor::ptr_to_element(), Window::set(), ITensorInfo::tensor_shape(), arm_compute::test::validation::w, IKernel::window(), and Window::x().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const Multiples multiples 
)
static

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

Parameters
[in]inputSource tensor info. Data type supported: U8/S8/QASYMM8/U16/S16/F16/U32/S32/F32.
[in]outputDestination tensor info. Same as input
[in]multiplesContains the number of times the input tensor should be replicated on the given dimension.
Returns
a status

Definition at line 83 of file NETileKernel.cpp.

84 {
85  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, multiples));
86  return Status{};
87 }
#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.

Referenced by NETile::validate().


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