Compute Library
 21.08
CpuConcatenateHeightKernel Class Reference

Interface for the height concatenate kernel. More...

#include <CpuConcatenateHeightKernel.h>

Collaboration diagram for CpuConcatenateHeightKernel:
[legend]

Public Member Functions

 CpuConcatenateHeightKernel ()=default
 
 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuConcatenateHeightKernel)
 
void configure (const ITensorInfo *src, unsigned int height_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 height_offset, const ITensorInfo *dst)
 Static function to check if given info will lead to a valid configuration. More...
 

Detailed Description

Interface for the height concatenate kernel.

The source tensor will be concatenated into the destination tensor.

Definition at line 39 of file CpuConcatenateHeightKernel.h.

Constructor & Destructor Documentation

◆ CpuConcatenateHeightKernel()

Member Function Documentation

◆ ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE()

ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE ( CpuConcatenateHeightKernel  )

◆ configure()

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

Configure kernel for a given list of arguments.

Parameters
[in]srcSource tensor info. Data types supported: All
[in]height_offsetThe starting offset on the Y axis for the output tensor.
[in,out]dstDestination tensor info. Data types supported: Same as src.

Definition at line 65 of file CpuConcatenateHeightKernel.cpp.

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

66 {
69  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, height_offset, dst));
70 
71  _height_offset = height_offset;
72 
73  // Configure kernel window
74  Window win = calculate_max_window(*dst, Steps());
75  ICpuKernel::configure(win);
76 }
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 172 of file CpuConcatenateHeightKernel.cpp.

173 {
174  return "CpuConcatenateHeightKernel";
175 }

◆ 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 84 of file CpuConcatenateHeightKernel.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, Window::DimY, 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().

85 {
89 
90  const auto src = tensors.get_const_tensor(TensorType::ACL_SRC);
91  auto dst = tensors.get_tensor(TensorType::ACL_DST);
92 
93  // Offset destination pointer to the correct position
94  uint8_t *dst_ptr = dst->buffer() + dst->info()->offset_first_element_in_bytes() + _height_offset * dst->info()->strides_in_bytes()[Window::DimY];
95 
96  const auto window_start_x = static_cast<int>(window.x().start());
97  const auto window_end_x = static_cast<int>(window.x().end()) * static_cast<int>(dst->info()->element_size());
98  const int window_step_x = 16;
99 
100  Window win{ window };
101  win.set(Window::DimX, Window::Dimension(0, 1, 1));
102  win.set(Window::DimY, Window::Dimension(0, src->info()->tensor_shape().y(), 1));
103 
104  // Create iterators
105  Iterator src_it(src, win);
106  Iterator dst_it(dst, win);
107 
108  const DataType dt = src->info()->data_type();
109  const UniformQuantizationInfo &src_qinfo = src->info()->quantization_info().uniform();
110  const UniformQuantizationInfo &dst_qinfo = dst->info()->quantization_info().uniform();
111  if(dt == DataType::QASYMM8 && src_qinfo != dst_qinfo)
112  {
113  execute_window_loop(win, [&](const Coordinates &)
114  {
115  int x = window_start_x;
116  for(; x <= (window_end_x - window_step_x); x += window_step_x)
117  {
118  vst1q_u8(dst_ptr + dst_it.offset() + x, vquantize(vdequantize(vld1q_u8(src_it.ptr() + x), src_qinfo), dst_qinfo));
119  }
120 
121  // Compute left-over elements
122  for(; x < window_end_x; ++x)
123  {
124  *(dst_ptr + dst_it.offset() + x) = quantize_qasymm8(dequantize_qasymm8(*(src_it.ptr() + x), src_qinfo), dst_qinfo);
125  }
126 
127  },
128  src_it, dst_it);
129  }
130  else if(dt == DataType::QASYMM8_SIGNED && src_qinfo != dst_qinfo)
131  {
132  execute_window_loop(win, [&](const Coordinates &)
133  {
134  int x = window_start_x;
135  for(; x <= (window_end_x - window_step_x); x += window_step_x)
136  {
137  vst1q_s8(reinterpret_cast<int8_t *>(dst_ptr + dst_it.offset() + x),
138  vquantize_signed(vdequantize(vld1q_s8(reinterpret_cast<int8_t *>(src_it.ptr()) + x), src_qinfo), dst_qinfo));
139  }
140 
141  // Compute left-over elements
142  for(; x < window_end_x; ++x)
143  {
144  *(dst_ptr + dst_it.offset() + x) = quantize_qasymm8_signed(dequantize_qasymm8_signed(*(src_it.ptr() + x), src_qinfo), dst_qinfo);
145  }
146  },
147  src_it, dst_it);
148  }
149  else
150  {
151  execute_window_loop(win, [&](const Coordinates &)
152  {
153  const auto in_ptr = src_it.ptr();
154  const auto out_ptr = dst_ptr + dst_it.offset();
155 
156  int x = window_start_x;
157  for(; x <= (window_end_x - window_step_x); x += window_step_x)
158  {
159  wrapper::vstore(out_ptr + x, wrapper::vloadq(in_ptr + x));
160  }
161 
162  // Compute left-over elements
163  for(; x < window_end_x; ++x)
164  {
165  *(out_ptr + x) = *(in_ptr + x);
166  }
167  },
168  src_it, dst_it);
169  }
170 }
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
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
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  height_offset,
const ITensorInfo dst 
)
static

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

Similar to CpuConcatenateHeightKernel::configure()

Returns
a status

Definition at line 78 of file CpuConcatenateHeightKernel.cpp.

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by CpuConcatenate::validate().

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