Compute Library
 21.02
NEConvertQuantizedSignednessKernel Class Reference

Neon kernel to convert asymmetric signed to asymmetric signed and vice-versa. More...

#include <NEConvertQuantizedSignednessKernel.h>

Collaboration diagram for NEConvertQuantizedSignednessKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEConvertQuantizedSignednessKernel ()
 Default constructor. More...
 
 NEConvertQuantizedSignednessKernel (const NEConvertQuantizedSignednessKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers). More...
 
NEConvertQuantizedSignednessKerneloperator= (const NEConvertQuantizedSignednessKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers). More...
 
 NEConvertQuantizedSignednessKernel (NEConvertQuantizedSignednessKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEConvertQuantizedSignednessKerneloperator= (NEConvertQuantizedSignednessKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEConvertQuantizedSignednessKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output)
 Initialize the kernel's input, output. 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...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output)
 Static function to check if given info will lead to a valid configuration of NEConvertQuantizedSignednessKernel. More...
 

Detailed Description

Neon kernel to convert asymmetric signed to asymmetric signed and vice-versa.

Definition at line 36 of file NEConvertQuantizedSignednessKernel.h.

Constructor & Destructor Documentation

◆ NEConvertQuantizedSignednessKernel() [1/3]

Default constructor.

Definition at line 72 of file NEConvertQuantizedSignednessKernel.cpp.

Referenced by NEConvertQuantizedSignednessKernel::name().

73  : _input(nullptr), _output(nullptr)
74 {
75 }

◆ NEConvertQuantizedSignednessKernel() [2/3]

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

◆ NEConvertQuantizedSignednessKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEConvertQuantizedSignednessKernel()

Default destructor.

Referenced by NEConvertQuantizedSignednessKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Initialize the kernel's input, output.

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED.
[out]outputDestination tensor. Data types supported: opposite of input.

Definition at line 77 of file NEConvertQuantizedSignednessKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ITensor::info(), arm_compute::test::validation::input, and arm_compute::validate_arguments().

Referenced by NEConvertQuantizedSignednessKernel::name().

78 {
80  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
81 
82  _input = input;
83  _output = output;
84 
85  std::pair<Status, Window> win_config = validate_and_configure_window(input->info(), output->info());
86  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
87  INEKernel::configure(win_config.second);
88 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161

◆ name()

◆ operator=() [1/2]

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

Referenced by NEConvertQuantizedSignednessKernel::name().

◆ operator=() [2/2]

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 97 of file NEConvertQuantizedSignednessKernel.cpp.

References ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, Window::collapse_if_possible(), Window::DimX, Window::DimZ, Window::Dimension::end(), arm_compute::execute_window_loop(), arm_compute::test::validation::input, Iterator::ptr(), Window::set(), Window::Dimension::start(), arm_compute::wrapper::vdup_n(), arm_compute::wrapper::veor(), arm_compute::wrapper::vloadq(), arm_compute::wrapper::vstore(), IKernel::window(), and Window::x().

Referenced by NEConvertQuantizedSignednessKernel::name().

98 {
102 
103  Window win_collapsed = window.collapse_if_possible(window, Window::DimZ);
104  win_collapsed.set(Window::DimX, Window::Dimension(0, 1, 1));
105 
106  Iterator input(_input, win_collapsed);
107  Iterator output(_output, win_collapsed);
108 
109  const int window_step_x = 16;
110  const auto window_start_x = static_cast<int>(window.x().start());
111  const auto window_end_x = static_cast<int>(window.x().end());
112 
113  const uint8_t mask = 128;
114  const auto vmask = wrapper::vdup_n(mask, wrapper::traits::vector_128_tag{});
115 
116  execute_window_loop(win_collapsed, [&](const Coordinates &)
117  {
118  const auto input_ptr = reinterpret_cast<const uint8_t *>(input.ptr());
119  const auto output_ptr = reinterpret_cast<uint8_t *>(output.ptr());
120 
121  // Compute S elements per iteration
122  int x = window_start_x;
123  for(; x <= (window_end_x - window_step_x); x += window_step_x)
124  {
125  const auto vin = wrapper::vloadq(input_ptr + x);
126  wrapper::vstore(output_ptr + x, wrapper::veor(vin, vmask));
127  }
128 
129  // Compute left-over elements
130  for(; x < window_end_x; ++x)
131  {
132  const uint8_t in = *(reinterpret_cast<const uint8_t *>(input_ptr + x));
133  *(output_ptr + x) = in ^ mask;
134  }
135  },
136  input, output);
137 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
uint8x16_t vloadq(const uint8_t *ptr)
Definition: load.h:58
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
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
uint8x8_t veor(const uint8x8_t &a, const uint8x8_t &b)
Definition: eor.h:39
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:941
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
void vstore(uint8_t *ptr, uint8x8_t val)
Definition: store.h:39
uint8x8_t vdup_n(uint8_t value, traits::vector_64_tag)
Definition: dup_n.h:41
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
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:94
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145

◆ validate()

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

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

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED.
[in]outputDestination tensor. Data types supported: opposite of input.
Returns
a status

Definition at line 90 of file NEConvertQuantizedSignednessKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::validate_arguments().

Referenced by NEConvertQuantizedSignednessKernel::name(), and NEGEMMLowpMatrixMultiplyCore::validate().

91 {
93  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get()).first);
94  return Status{};
95 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)

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