48 void validate_indices(
const ITensor *indices)
50 for(
size_t i = 0; i < indices->info()->tensor_shape()[0]; ++i)
56 Status
validate_arguments(
const ITensorInfo *
input,
const ITensorInfo *indices,
const ITensorInfo *output,
int axis)
64 axis +=
input->num_dimensions();
70 if(output->total_size() != 0)
85 : _input{}, _indices{}, _axis{}, _output{}, _func{}
90 inline void NEGatherKernel::gather_0_axis(
const Window &window,
const ThreadInfo &
info)
95 validate_indices<U>(_indices);
97 Iterator output_it(_output,
window);
100 Coordinates gather_id(
id);
102 auto new_index = *(reinterpret_cast<U *>(_indices->
ptr_to_element(Coordinates(
id[0]))));
103 gather_id.set(0, new_index);
110 template <
typename U>
111 void NEGatherKernel::gather_n_axis(
const Window &window,
const ThreadInfo &
info)
116 validate_indices<U>(_indices);
118 Window output_window{
window };
121 Iterator output_it(_output, output_window);
124 Coordinates gather_id(
id);
126 auto new_index = *(reinterpret_cast<U *>(_indices->
ptr_to_element(Coordinates(
id[_axis]))));
127 gather_id.set(_axis, new_index);
146 _axis +=
input->info()->num_dimensions();
155 _func = &NEGatherKernel::gather_0_axis<uint32_t>;
158 _func = &NEGatherKernel::gather_0_axis<int32_t>;
170 _func = &NEGatherKernel::gather_n_axis<uint32_t>;
173 _func = &NEGatherKernel::gather_n_axis<int32_t>;
187 INEKernel::configure(win);
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Interface for CPU tensor.
Copyright (c) 2017-2021 Arm Limited.
void configure(const ITensor *input, const ITensor *indices, ITensor *output, int axis=0)
Initialise the kernel's inputs and outputs.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
1 channel, 1 S32 per channel
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
1 channel, 1 U32 per channel
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Class to describe a number of elements in each dimension.
size_t total_size() const
Collapses all dimensions to a single linear total size.
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...
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.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
static Status validate(const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, int axis)
Static function to check if given info will lead to a valid configuration of NEGatherKernel.
NEGatherKernel()
Default constructor.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
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...
Describe a multidimensional execution window.
TensorShape compute_gather_shape(const TensorShape &input_shape, const TensorShape &indices_shape, uint32_t actual_axis)