Compute Library
CpuCol2ImKernel Class Reference

Kernel to perform col2im reshaping. More...

#include <CpuCol2ImKernel.h>

Collaboration diagram for CpuCol2ImKernel:

Public Member Functions

 CpuCol2ImKernel ()=default
 Default constructor. More...
void configure (const ITensorInfo *src, ITensorInfo *dst, const Size2D &convolved_dims)
 Set the input and output of the kernel. 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, const Size2D &convolved_dims)
 Static function to check if given info will lead to a valid configuration. More...

Detailed Description

Kernel to perform col2im reshaping.

Rearranges each matrix column into image blocks. It's the inverse operation of CpuIm2ColKernel.

For example, a vector of 9 elements can be reshaped to a block(image) of 3x3:

\[ \left( \begin{array}{ccccccccc} a0 & a1 & a2 & a3 & a4 & a5 & a6 & a7 & a8 \\ \end{array} \right) \rightarrow \left( \begin{array}{ccc} a0 & a1 & a2 \\ a3 & a4 & a5 \\ a6 & a7 & a8 \\ \end{array} \right) \]

Definition at line 55 of file CpuCol2ImKernel.h.

Constructor & Destructor Documentation

◆ CpuCol2ImKernel()

CpuCol2ImKernel ( )

Default constructor.

Member Function Documentation



◆ configure()

void configure ( const ITensorInfo src,
ITensorInfo dst,
const Size2D convolved_dims 

Set the input and output of the kernel.

[in]srcThe input tensor info to convert. Data types supported: All
[out]dstThe output tensor info. 3 lower dimensions represent a single output [width, height, OFM], while the rest represent batch of outputs. Data types supported: Same as input
[in]convolved_dimsOutput convolved dimensions.

Definition at line 63 of file CpuCol2ImKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_col2im_shape(), and arm_compute::test::validation::configure().

64 {
66  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, convolved_dims));
68  _convolved_dims = convolved_dims;
70  // Configure kernel window
71  // Output auto inizialitation if not yet initialized
72  auto_init_if_empty(*dst, src->clone()->set_tensor_shape(compute_col2im_shape(*src, convolved_dims, false)));
74  // Configure kernel window
75  Window win = calculate_max_window(*src, Steps());
77  ICpuKernel::configure(win);
78 }
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Definition: Error.h:455
SimpleTensor< float > src
Definition: DFT.cpp:155
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...
Definition: Validate.h:157
TensorShape compute_col2im_shape(const ITensorInfo &input, const Size2D &convolved_dims, bool batch_size_on_z, unsigned int num_groups=1)
Calculate the Col2Im shape.

◆ name()

const char * name ( ) const

Name of the kernel.

Kernel name

Implements ICPPKernel.

Definition at line 118 of file CpuCol2ImKernel.cpp.

119 {
120  return "CpuCol2ImKernel";
121 }

◆ run_op()

void run_op ( ITensorPack tensors,
const Window window,
const ThreadInfo info 

Execute the kernel on the passed window.

If is_parallelisable() returns false then the passed window must be equal to window()
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().
[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 86 of file CpuCol2ImKernel.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::DimX, Window::DimY, Window::DimZ, ITensorInfo::element_size(), arm_compute::execute_window_loop(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), ITensor::info(), Iterator::ptr(), Window::set(), and Window::y().

87 {
92  auto src = tensors.get_const_tensor(TensorType::ACL_SRC);
93  auto dst = tensors.get_tensor(TensorType::ACL_DST);
95  const uint8_t el_size = src->info()->element_size();
96  const int output_stride_x = dst->info()->strides_in_bytes().x();
97  const int output_stride_y = dst->info()->strides_in_bytes().y();
98  const int output_stride_z = dst->info()->strides_in_bytes().z();
100  Window window_out(window);
101  window_out.set(Window::DimX, Window::Dimension(0, 0, 0));
102  window_out.set(Window::DimY, Window::Dimension(0, 0, 0));
103  window_out.set(Window::DimZ, Window::Dimension(0, 0, 0));
105  // Create iterators
106  Iterator in(src, window);
107  Iterator out(dst, window_out);
109  execute_window_loop(window, [&](const Coordinates & id)
110  {
111  const int hidx = id.y();
112  const int idx = id.x() * output_stride_z + (hidx / _convolved_dims.width) * output_stride_y + (hidx % _convolved_dims.width) * output_stride_x;
113  std::memcpy(out.ptr() + idx, in.ptr(), el_size);
114  },
115  in, out);
116 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
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
To avoid unused variables warnings.
Definition: Error.h:152
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)
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:89
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
Definition: Window.h:154
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
Definition: Validate.h:201

◆ validate()

Status validate ( const ITensorInfo src,
const ITensorInfo dst,
const Size2D convolved_dims 

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

Similar to CpuCol2ImKernel::configure()

a status

Definition at line 80 of file CpuCol2ImKernel.cpp.


Referenced by CpuGemmConvolution::validate().

81 {
82  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, output, convolved_dims));
83  return Status{};
84 }
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: