Compute Library
 21.08
NETileKernel Class Reference

Basic 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...
 
 ~NETileKernel ()=default
 Default destructor. 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...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. 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...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. 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

Basic 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 62 of file NETileKernel.cpp.

63  : _input(nullptr), _output(nullptr)
64 {
65 }

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

◆ ~NETileKernel()

~NETileKernel ( )
default

Default destructor.

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: All.
[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 67 of file NETileKernel.cpp.

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(), arm_compute::test::validation::input, and ITensorInfo::tensor_shape().

Referenced by NETileKernel::name().

68 {
70 
71  // Auto initialize output
72  TensorShape tiled_shape = misc::shape_calculator::compute_tiled_shape(input->info()->tensor_shape(), multiples);
73  auto_init_if_empty(*output->info(), tiled_shape, 1, input->info()->data_type());
74 
75  // Validate
76  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), multiples));
77 
78  _input = input;
79  _output = output;
80 
81  // Configure window without padding
82  Window win = calculate_max_window(*output->info());
83  INEKernel::configure(win);
84 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
TensorShape compute_tiled_shape(const TensorShape &input_shape, const Multiples &multiples)
Calculate the tiled shape of a 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...
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 49 of file NETileKernel.h.

References NETileKernel::configure(), arm_compute::test::validation::info, arm_compute::test::validation::input, NETileKernel::run(), NETileKernel::validate(), and IKernel::window().

50  {
51  return "NETileKernel";
52  }

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

Reimplemented from ICPPKernel.

Definition at line 92 of file NETileKernel.cpp.

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(), Iterator::ptr(), ITensor::ptr_to_element(), Window::set(), ITensorInfo::tensor_shape(), arm_compute::test::validation::w, IKernel::window(), and Window::x().

Referenced by NETileKernel::name().

93 {
97 
98  Window output_window{ window };
99  output_window.set(Window::DimX, Window::Dimension(output_window.x().start(), output_window.x().end(), _input->info()->dimension(0)));
100  Window out_slice = output_window.first_slice_window_1D();
101 
102  const auto src_shape = _input->info()->tensor_shape();
103  do
104  {
105  Iterator output_it(_output, out_slice);
106 
107  execute_window_loop(out_slice, [&](const Coordinates & id)
108  {
109  const size_t x = id.x();
110  const size_t y = id.y();
111  const size_t z = id.z();
112  const size_t w = id[3];
113  Coordinates input_coords{ x % src_shape[0], y % src_shape[1], z % src_shape[2], w % src_shape[3] };
114  memcpy(output_it.ptr(), _input->ptr_to_element(input_coords), _input->info()->dimension(0) * _input->info()->element_size());
115  },
116  output_it);
117  }
118  while(output_window.slide_window_slice_1D(out_slice));
119 }
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:152
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&#39;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:49
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
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:77
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

◆ 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: All.
[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 86 of file NETileKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NETileKernel::name(), and NETile::validate().

87 {
88  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, multiples));
89  return Status{};
90 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204

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