21.08
|
Kernel to perform reshaping on the weights used by convolution and locally connected layer. More...
#include <CpuWeightsReshapeKernel.h>
Public Member Functions | |
CpuWeightsReshapeKernel ()=default | |
Default constructor. More... | |
ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE (CpuWeightsReshapeKernel) | |
void | configure (const ITensorInfo *src, const ITensorInfo *biases, ITensorInfo *dst) |
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... | |
![]() | |
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... | |
![]() | |
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 Window & | window () 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 *biases, const ITensorInfo *dst) |
Static function to check if given info will lead to a valid configuration. More... | |
Kernel to perform reshaping on the weights used by convolution and locally connected layer.
Rearranges each 3-dimensional kernel to a single row leading to a matrix with linearized kernels. In combination with the cpu::kernels::CpuIm2ColKernel can transform a convolution to a matrix multiplication.
For example assuming a 3D weight kernel of 3x3 dimensions and depth of 2 we have:
\[ \left( \begin{array}{ccc} a000 & a001 & a002 \\ a010 & a011 & a012 \\ a020 & a021 & a022 \\ \end{array} \right) \left( \begin{array}{ccc} a100 & a101 & a102 \\ a110 & a111 & a112 \\ a120 & a121 & a122 \\ \end{array} \right) \rightarrow \left( \begin{array}{ccccccccc} a000 & a001 & a002 & a010 & a011 & a012 & a020 & a021 & a022 & a100 & a101 & a102 & a110 & a111 & a112 & a120 & a121 & a122 \\ \end{array} \right) \]
Definition at line 59 of file CpuWeightsReshapeKernel.h.
|
default |
Default constructor.
ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE | ( | CpuWeightsReshapeKernel | ) |
void configure | ( | const ITensorInfo * | src, |
const ITensorInfo * | biases, | ||
ITensorInfo * | dst | ||
) |
Set the input and output of the kernel.
[in] | src | The input tensor info to convert. Weights are 4D tensor with dimensions [kernel_x, kernel_y, IFM, OFM] if shared, and 5D tensor with dimensions [kernel_x, kernel_y, IFM, OFM, num_patches] if unshared. Data types supported: All |
[in] | biases | The shared biases tensor info to append. Bias is 1D tensor with dimensions [OFM] if shared and 2D tensor with dimensions [OFM, num_patches] if unshared. Data types supported: Same as input |
[out] | dst | The output tensor info. Data types supported: Same as src |
Definition at line 79 of file CpuWeightsReshapeKernel.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(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::DimZ, Window::set(), and IKernel::window().
|
overridevirtual |
Name of the kernel.
Implements ICPPKernel.
Definition at line 164 of file CpuWeightsReshapeKernel.cpp.
|
overridevirtual |
Execute the kernel on the passed window.
[in] | tensors | A vector containing the tensors to operate on. |
[in] | window | Region on which to execute the kernel. (Must be a region of the window returned by window()) |
[in] | info | Info about executing thread and CPU. |
Reimplemented from ICPPKernel.
Definition at line 105 of file CpuWeightsReshapeKernel.cpp.
References arm_compute::ACL_BIAS, arm_compute::ACL_DST, arm_compute::ACL_SRC, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::dimension(), arm_compute::execute_window_loop(), ITensorPack::get_const_tensor(), ITensorPack::get_tensor(), ITensor::info(), input_stride_y, input_stride_z, Iterator::ptr(), and IKernel::window().
|
static |
Static function to check if given info will lead to a valid configuration.
Similar to CpuWeightsReshapeKernel::configure()
Definition at line 99 of file CpuWeightsReshapeKernel.cpp.
References ARM_COMPUTE_RETURN_ON_ERROR.