24.02.1
|
Go to the documentation of this file.
39 validate_arguments(
const ITensorInfo *
input,
const ITensorInfo *output,
const ITensorInfo *axis,
bool use_inverted_axis)
48 "Current implementation only supports up to 4 dimensions.");
52 if (output->total_size() != 0)
74 _use_inverted_axis = use_inverted_axis;
88 bool use_inverted_axis)
99 unsigned int axis_bit = 0;
100 const int rank =
input->info()->num_dimensions();
102 for (
unsigned int i = 0; i < axis->
info()->dimension(0); ++i)
104 int axis_i = *(
reinterpret_cast<const int *
>(axis->
buffer()) + i);
107 if ((axis_i < -rank) || (axis_i >= rank))
109 ARM_COMPUTE_ERROR(
"the values of the axis tensor must be within [-rank, rank-1].");
115 axis_i = rank + axis_i;
119 if (use_inverted_axis)
121 axis_i = (rank - 1) - axis_i;
124 axis_bit |= 1 << axis_i;
128 const int window_step_x = 16 /
input->info()->element_size();
129 const int window_start_x = window.
x().
start();
130 const int window_end_x = window.
x().
end();
140 int x = window_start_x;
141 for (; x <= (window_end_x - window_step_x); x += window_step_x)
152 const int offset_x = (axis_bit & 0x1) ? output->
info()->
dimension(0) - x - window_step_x : x;
153 const int offset_y = (axis_bit & 0x2) ? output->
info()->
dimension(1) -
id.y() - 1 :
id.y();
154 const int offset_z = (axis_bit & 0x4) ? output->
info()->
dimension(2) -
id.z() - 1 :
id.z();
155 const int offset_w = (axis_bit & 0x8) ? output->
info()->
dimension(3) -
id[3] - 1 :
id[3];
163 for (; x < window_end_x; ++x)
165 const auto in = *(
reinterpret_cast<T *
>(input_it.
ptr()) + x);
167 const int offset_x = (axis_bit & 0x1) ? output->
info()->
dimension(0) - x - 1 : x;
168 const int offset_y = (axis_bit & 0x2) ? output->
info()->
dimension(1) -
id.y() - 1 :
id.y();
169 const int offset_z = (axis_bit & 0x4) ? output->
info()->
dimension(2) -
id.z() - 1 :
id.z();
170 const int offset_w = (axis_bit & 0x8) ? output->
info()->
dimension(3) -
id[3] - 1 :
id[3];
188 run_reverse<uint32_t>(
window, _input, _axis, _output, _use_inverted_axis);
191 run_reverse<uint16_t>(
window, _input, _axis, _output, _use_inverted_axis);
194 run_reverse<uint8_t>(
window, _input, _axis, _output, _use_inverted_axis);
constexpr int start() const
Return the start of the dimension.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Interface for CPU tensor.
uint8x16_t vloadq(const uint8_t *ptr)
Includes all wrapper headers at once.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *axis, bool use_inverted_axis)
Static function to check if given info will lead to a valid configuration of NEReverseKernel.
constexpr uint8_t * ptr() const
Return a pointer to the current pixel.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
@ U32
unsigned 32-bit number
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...
Iterator updated by execute_window_loop for each window element.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
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...
uint8x16_t vcombine(const uint8x8_t &a, const uint8x8_t &b)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Describe one of the image's dimensions with a start, end and step.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
void configure(const ITensor *input, ITensor *output, const ITensor *axis, bool use_inverted_axis)
Initialise the kernel's inputs and output.
const Window & window() const
The maximum window the kernel can be executed on.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
Information about executing thread and CPU.
uint8x8_t vgetlow(const uint8x16_t val)
void vstore(uint8_t *ptr, uint8x8_t val)
Describe a multidimensional execution window.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
uint8_t * ptr_to_element(const Coordinates &id) const
Return a pointer to the element at the passed coordinates.
@ S32
signed 32-bit number
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
NEReverseKernel()
Default constructor.
Store the tensor's metadata.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
@ UNKNOWN
Unknown data type.
constexpr int end() const
Return the end of the dimension.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
uint8x8_t vgethigh(const uint8x16_t val)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
void run_reverse(const Window &window, const ITensor *input, const ITensor *axis, ITensor *output, bool use_inverted_axis)
uint8x8_t vrev64(const uint8x8_t &a)
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory.