Compute Library
 21.08
CpuConvertQuantizedSignednessKernel Class Reference

Kernel to convert asymmetric signed to asymmetric signed and vice-versa. More...

#include <CpuConvertQuantizedSignednessKernel.h>

Collaboration diagram for CpuConvertQuantizedSignednessKernel:
[legend]

Public Member Functions

 CpuConvertQuantizedSignednessKernel ()=default
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuConvertQuantizedSignednessKernel)
 
void configure (const ITensorInfo *src, ITensorInfo *dst)
 Initialize the kernel input and output info. More...
 
void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
const char * name () const override
 Name of the kernel. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run (const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. 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...
 
- 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 *src, const ITensorInfo *dst)
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Kernel to convert asymmetric signed to asymmetric signed and vice-versa.

Definition at line 37 of file CpuConvertQuantizedSignednessKernel.h.

Constructor & Destructor Documentation

◆ CpuConvertQuantizedSignednessKernel()

Member Function Documentation

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( CpuConvertQuantizedSignednessKernel  )

◆ configure()

void configure ( const ITensorInfo src,
ITensorInfo dst 
)

Initialize the kernel input and output info.

Parameters
[in]srcSource tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED.
[out]dstDestination tensor info. Data types supported: opposite of src.

Definition at line 76 of file CpuConvertQuantizedSignednessKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, and ARM_COMPUTE_ERROR_THROW_ON.

77 {
79  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst));
80 
81  std::pair<Status, Window> win_config = validate_and_configure_window(src, dst);
82  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
83  ICpuKernel::configure(win_config.second);
84 }
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
SimpleTensor< float > src
Definition: DFT.cpp:155
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157

◆ name()

const char * name ( ) const
overridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 136 of file CpuConvertQuantizedSignednessKernel.cpp.

137 {
138  return "CpuConvertQuantizedSignednessKernel";
139 }

◆ run_op()

void run_op ( ITensorPack tensors,
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]tensorsA vector containing the tensors to operate on.
[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 CpuConvertQuantizedSignednessKernel.cpp.

References arm_compute::ACL_DST, arm_compute::ACL_SRC, 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(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), 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().

93 {
94  auto src = tensors.get_const_tensor(TensorType::ACL_SRC);
95  auto dst = tensors.get_tensor(TensorType::ACL_DST);
99 
100  Window win_collapsed = window.collapse_if_possible(window, Window::DimZ);
101  win_collapsed.set(Window::DimX, Window::Dimension(0, 1, 1));
102 
103  Iterator input(src, win_collapsed);
104  Iterator output(dst, win_collapsed);
105 
106  const int window_step_x = 16;
107  const auto window_start_x = static_cast<int>(window.x().start());
108  const auto window_end_x = static_cast<int>(window.x().end());
109 
110  const uint8_t mask = 128;
111  const auto vmask = wrapper::vdup_n(mask, wrapper::traits::vector_128_tag{});
112 
113  execute_window_loop(win_collapsed, [&](const Coordinates &)
114  {
115  const auto input_ptr = reinterpret_cast<const uint8_t *>(input.ptr());
116  const auto output_ptr = reinterpret_cast<uint8_t *>(output.ptr());
117 
118  // Compute S elements per iteration
119  int x = window_start_x;
120  for(; x <= (window_end_x - window_step_x); x += window_step_x)
121  {
122  const auto vin = wrapper::vloadq(input_ptr + x);
123  wrapper::vstore(output_ptr + x, wrapper::veor(vin, vmask));
124  }
125 
126  // Compute left-over elements
127  for(; x < window_end_x; ++x)
128  {
129  const uint8_t in = *(reinterpret_cast<const uint8_t *>(input_ptr + x));
130  *(output_ptr + x) = in ^ mask;
131  }
132  },
133  input, output);
134 }
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
SimpleTensor< float > src
Definition: DFT.cpp:155
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:915
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:201
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:145

◆ validate()

Status validate ( const ITensorInfo src,
const ITensorInfo dst 
)
static

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

Similar to CpuConvertQuantizedSignednessKernel::configure()

Returns
a status

Definition at line 86 of file CpuConvertQuantizedSignednessKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by CpuGemmLowpMatrixMultiplyCore::validate().

87 {
88  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, dst));
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
SimpleTensor< float > src
Definition: DFT.cpp:155

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