Compute Library
 23.11
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...
 
virtual size_t get_mws (const CPUInfo &platform, size_t thread_count) const
 Return minimum workload size of the relevant kernel. 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...
 

Additional Inherited Members

- Static Public Attributes inherited from ICPPKernel
static constexpr size_t default_mws = 1
 

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

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

◆ 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 65 of file NETileKernel.cpp.

66 {
68 
69  // Auto initialize output
70  TensorShape tiled_shape = misc::shape_calculator::compute_tiled_shape(input->info()->tensor_shape(), multiples);
71  auto_init_if_empty(*output->info(), tiled_shape, 1, input->info()->data_type());
72 
73  // Validate
74  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), multiples));
75 
76  _input = input;
77  _output = output;
78 
79  // Configure window without padding
80  Window win = calculate_max_window(*output->info());
81  INEKernel::configure(win);
82 }

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(), ITensor::info(), arm_compute::test::validation::input, and arm_compute::cpu::kernels::validate_arguments().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 49 of file NETileKernel.h.

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

91 {
95 
96  Window output_window{window};
97  output_window.set(Window::DimX, Window::Dimension(output_window.x().start(), output_window.x().end(),
98  _input->info()->dimension(0)));
99  Window out_slice = output_window.first_slice_window_1D();
100 
101  const auto src_shape = _input->info()->tensor_shape();
102  do
103  {
104  Iterator output_it(_output, out_slice);
105 
107  out_slice,
108  [&](const Coordinates &id)
109  {
110  const size_t x = id.x();
111  const size_t y = id.y();
112  const size_t z = id.z();
113  const size_t w = id[3];
114  Coordinates input_coords{x % src_shape[0], y % src_shape[1], z % src_shape[2], w % src_shape[3]};
115  memcpy(output_it.ptr(), _input->ptr_to_element(input_coords),
116  _input->info()->dimension(0) * _input->info()->element_size());
117  },
118  output_it);
119  } while (output_window.slide_window_slice_1D(out_slice));
120 }

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: 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 84 of file NETileKernel.cpp.

85 {
87  return Status{};
88 }

References ARM_COMPUTE_RETURN_ON_ERROR, arm_compute::test::validation::input, and arm_compute::cpu::kernels::validate_arguments().

Referenced by NETile::validate().


The documentation for this class was generated from the following files:
arm_compute::ITensorInfo::tensor_shape
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
arm_compute::calculate_max_window
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Definition: WindowHelpers.cpp:29
arm_compute::cpu::kernels::validate_arguments
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
Definition: CpuDirectConv2dKernel.cpp:57
ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:1079
arm_compute::ITensorInfo::element_size
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
arm_compute::Window::DimX
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
ARM_COMPUTE_RETURN_ON_ERROR
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:205
arm_compute::ITensorInfo::dimension
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
ARM_COMPUTE_ERROR_ON_NULLPTR
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159
arm_compute::ITensor::info
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
ARM_COMPUTE_ERROR_THROW_ON
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
arm_compute::execute_window_loop
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:74
arm_compute::auto_init_if_empty
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: AutoConfiguration.h:43
arm_compute::test::validation::w
SimpleTensor< float > w
Definition: DFT.cpp:156
ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:203
arm_compute::misc::shape_calculator::compute_tiled_shape
TensorShape compute_tiled_shape(const TensorShape &input_shape, const Multiples &multiples)
Calculate the tiled shape of a tensor.
Definition: ShapeCalculator.h:1385
ARM_COMPUTE_UNUSED
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:151
arm_compute::Window::set
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:53
arm_compute::IKernel::window
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
arm_compute::ITensor::ptr_to_element
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
Definition: ITensor.h:63
arm_compute::test::validation::info
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
arm_compute::test::validation::input
auto input
Definition: LSTMLayerQuantized.cpp:486