Compute Library
 21.08
CpuConcatenateWidthKernel Class Reference

Interface for the width concatenate kernel. More...

#include <CpuConcatenateWidthKernel.h>

Collaboration diagram for CpuConcatenateWidthKernel:
[legend]

Public Member Functions

 CpuConcatenateWidthKernel ()=default
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuConcatenateWidthKernel)
 
void configure (const ITensorInfo *src, unsigned int width_offset, ITensorInfo *dst)
 Configure kernel for a given list of arguments. 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, unsigned int width_offset, const ITensorInfo *dst)
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Interface for the width concatenate kernel.

The source tensor will be concatenated into the destination tensor.

Definition at line 40 of file CpuConcatenateWidthKernel.h.

Constructor & Destructor Documentation

◆ CpuConcatenateWidthKernel()

Member Function Documentation

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( CpuConcatenateWidthKernel  )

◆ configure()

void configure ( const ITensorInfo src,
unsigned int  width_offset,
ITensorInfo dst 
)

Configure kernel for a given list of arguments.

Parameters
[in]srcSource tensor info. Data types supported: All
[in]width_offsetThe offset on the X axis.
[in,out]dstDestination tensor info. Data types supported: Same as src.

Definition at line 65 of file CpuConcatenateWidthKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, ARM_COMPUTE_UNUSED, and arm_compute::calculate_max_window().

66 {
68  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, width_offset, dst));
70 
71  _width_offset = width_offset;
72 
73  // Configure kernel window
74  Window win = calculate_max_window(*src, Steps());
75 
76  ICpuKernel::configure(win);
77 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
SimpleTensor< float > src
Definition: DFT.cpp:155
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#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 169 of file CpuConcatenateWidthKernel.cpp.

170 {
171  return "CpuConcatenateWidthKernel";
172 }

◆ 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 85 of file CpuConcatenateWidthKernel.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, ITensor::buffer(), arm_compute::dequantize_qasymm8(), arm_compute::dequantize_qasymm8_signed(), Window::DimX, dt, Window::Dimension::end(), arm_compute::execute_window_loop(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), Iterator::offset(), Iterator::ptr(), arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::quantize_qasymm8(), arm_compute::quantize_qasymm8_signed(), Window::set(), Window::Dimension::start(), arm_compute::vdequantize(), arm_compute::wrapper::vloadq(), arm_compute::vquantize(), arm_compute::vquantize_signed(), arm_compute::wrapper::vstore(), IKernel::window(), and Window::x().

86 {
90 
91  const auto src = tensors.get_const_tensor(TensorType::ACL_SRC);
92  auto dst = tensors.get_tensor(TensorType::ACL_DST);
93 
94  // Offset output pointer to the correct position
95  uint8_t *dst_ptr = dst->buffer() + dst->info()->offset_first_element_in_bytes() + _width_offset * dst->info()->strides_in_bytes()[0];
96 
97  const auto window_start_x = static_cast<int>(window.x().start());
98  const auto window_end_x = static_cast<int>(window.x().end()) * static_cast<int>(dst->info()->element_size());
99  constexpr int window_step_x = 16;
100 
101  Window win{ window };
102  win.set(Window::DimX, Window::Dimension(0, 1, 1));
103 
104  // Create iterators
105  Iterator src_it(src, win);
106  Iterator dst_it(dst, win);
107  const DataType dt = src->info()->data_type();
108  const UniformQuantizationInfo &src_qinfo = src->info()->quantization_info().uniform();
109  const UniformQuantizationInfo &dst_qinfo = dst->info()->quantization_info().uniform();
110  if(dt == DataType::QASYMM8 && src_qinfo != dst_qinfo)
111  {
112  execute_window_loop(win, [&](const Coordinates &)
113  {
114  int x = window_start_x;
115  for(; x <= (window_end_x - window_step_x); x += window_step_x)
116  {
117  vst1q_u8(dst_ptr + dst_it.offset() + x, vquantize(vdequantize(vld1q_u8(src_it.ptr() + x), src_qinfo), dst_qinfo));
118  }
119 
120  // Compute left-over elements
121  for(; x < window_end_x; ++x)
122  {
123  *(dst_ptr + dst_it.offset() + x) = quantize_qasymm8(dequantize_qasymm8(*(src_it.ptr() + x), src_qinfo), dst_qinfo);
124  }
125  },
126  src_it, dst_it);
127  }
128  else if(dt == DataType::QASYMM8_SIGNED && src_qinfo != dst_qinfo)
129  {
130  execute_window_loop(win, [&](const Coordinates &)
131  {
132  int x = window_start_x;
133  for(; x <= (window_end_x - window_step_x); x += window_step_x)
134  {
135  vst1q_s8(reinterpret_cast<int8_t *>(dst_ptr + dst_it.offset() + x),
136  vquantize_signed(vdequantize(vld1q_s8(reinterpret_cast<int8_t *>(src_it.ptr() + x)), src_qinfo), dst_qinfo));
137  }
138 
139  // Compute left-over elements
140  for(; x < window_end_x; ++x)
141  {
142  *(dst_ptr + dst_it.offset() + x) = quantize_qasymm8_signed(dequantize_qasymm8_signed(*(src_it.ptr() + x), src_qinfo), dst_qinfo);
143  }
144  },
145  src_it, dst_it);
146  }
147  else
148  {
149  execute_window_loop(win, [&](const Coordinates &)
150  {
151  const auto in_ptr = src_it.ptr();
152  const auto out_ptr = dst_ptr + dst_it.offset();
153  int x = window_start_x;
154  for(; x <= (window_end_x - window_step_x); x += window_step_x)
155  {
156  wrapper::vstore(out_ptr + x, wrapper::vloadq(in_ptr + x));
157  }
158 
159  // Compute left-over elements
160  for(; x < window_end_x; ++x)
161  {
162  *(out_ptr + x) = *(in_ptr + x);
163  }
164  },
165  src_it, dst_it);
166  }
167 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
float dequantize_qasymm8(uint8_t value, const INFO_TYPE &qinfo)
Dequantize a value given an unsigned 8-bit asymmetric quantization scheme.
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
float32x4x2_t vdequantize(const uint8x8_t &qv, const UniformQuantizationInfo &qi)
Dequantize a neon vector holding 8 quantized values.
Definition: NEAsymm.h:415
uint8x16_t vloadq(const uint8_t *ptr)
Definition: load.h:58
SimpleTensor< float > src
Definition: DFT.cpp:155
DataType dt
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
int8_t quantize_qasymm8_signed(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given a signed 8-bit asymmetric quantization scheme.
quantized, asymmetric fixed-point 8-bit number unsigned
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)
uint8x8_t vquantize(const float32x4x2_t &qv, const UniformQuantizationInfo &qi)
Quantize a neon vector holding 8 floating point values.
Definition: NEAsymm.h:602
void vstore(uint8_t *ptr, uint8x8_t val)
Definition: store.h:39
float dequantize_qasymm8_signed(int8_t value, const INFO_TYPE &qinfo)
Dequantize a value given a signed 8-bit asymmetric quantization scheme.
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
quantized, asymmetric fixed-point 8-bit number signed
int8x8_t vquantize_signed(const float32x4x2_t &qv, const UniformQuantizationInfo &qi)
Quantize a neon vector holding 8 floating point values.
Definition: NEAsymm.h:630
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:99
DataType
Available data types.
Definition: Types.h:77
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,
unsigned int  width_offset,
const ITensorInfo dst 
)
static

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

Similar to CpuConcatenateWidthKernel::configure()

Returns
a status

Definition at line 79 of file CpuConcatenateWidthKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by CpuConcatenate::validate().

80 {
81  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, width_offset, dst));
82  return Status{};
83 }
#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: