Compute Library
 21.02
NEGEMMInterleave4x4Kernel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2021 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_NEGEMMINTERLEAVE4x4KERNEL_H
25 #define ARM_COMPUTE_NEGEMMINTERLEAVE4x4KERNEL_H
26 
28 
29 namespace arm_compute
30 {
31 class ITensor;
32 
33 /** Neon kernel to interleave the elements of a matrix
34  *
35  * This function puts the values in a 4x4 block of Matrix A on the same row (Interleaved values)
36  *
37  * @f[
38  * \left( \begin{array}{cccc}
39  * a00 & a01 & a02 & a03 \\
40  * a10 & a11 & a12 & a13 \\
41  * a20 & a21 & a22 & a23 \\
42  * a30 & a31 & a32 & a33 \\
43  * \end{array} \right)
44  * \rightarrow
45  * \left( \begin{array}{ccccccccccccccccc}
46  * a00 & a10 & a20 & a30 & a01 & a11 & a21 & a31 & a02 & a12 & a22 & a32 & a03 & a13 & a23 & a33 \\
47  * \end{array} \right)
48  * @f]
49  *
50  * After this operation, the output matrix will have the following shape: [ height * 4, ceil(width / 4.0f) ]
51  */
53 {
54 public:
55  const char *name() const override
56  {
57  return "NEGEMMInterleave4x4Kernel";
58  }
59  /** Constructor */
61  /** Prevent instances of this class from being copied (As this class contains pointers) */
63  /** Prevent instances of this class from being copied (As this class contains pointers) */
65  /** Allow instances of this class to be moved */
67  /** Allow instances of this class to be moved */
69  /** Default destructor */
70  ~NEGEMMInterleave4x4Kernel() = default;
71  /** Initialise the kernel's input and output.
72  *
73  * @param[in] input Input tensor. Data types supported: All
74  * @param[out] output Output tensor which stores the interleaved matrix. Data type supported: same as @p input.
75  */
76  void configure(const ITensor *input, ITensor *output);
77  /** Static function to check if given info will lead to a valid configuration of @ref NEGEMMInterleave4x4Kernel
78  *
79  * @param[in] input Input tensor info. Data types supported: All
80  * @param[in] output Output tensor info which stores the interleaved matrix. Data type supported: same as @p input.
81  *
82  * @return a status
83  */
84  static Status validate(const ITensorInfo *input, const ITensorInfo *output);
85 
86  // Inherited methods overridden:
87  void run(const Window &window, const ThreadInfo &info) override;
88 
89 private:
90  /** Template function to run gemm interleave 4x4
91  *
92  * @tparam ScalarType Scalar datatype
93  *
94  * @param[in] input Input tensor. Data types supported: uint32_t, uint16_t and uint8_t
95  * @param[out] output Output tensor. Data types supported: uint32_t, uint16_t and uint8_t
96  * @param[in] window Region on which to execute the kernel. (Must be a valid region of the window returned by window()).
97  */
98  template <typename ScalarType>
99  void gemm_interleave4x4(const ITensor *input, ITensor *output, const Window &window);
100 
101  /** Common signature for all the specialised gemm interleave 4x4 functions
102  *
103  * @param[in] input Input tensor. Data types supported: uint32_t, uint16_t and uint8_t
104  * @param[out] output Output tensor. Data types supported: uint32_t, uint16_t and uint8_t
105  * @param[in] window Region on which to execute the kernel. (Must be a valid region of the window returned by window()).
106  */
107  using GEMMInterleaveFunctionFuncPtr = void (NEGEMMInterleave4x4Kernel::*)(const ITensor *input, ITensor *output, const Window &window);
108 
109  GEMMInterleaveFunctionFuncPtr _func;
110 };
111 } // namespace arm_compute
112 #endif /*ARM_COMPUTE_NEGEMMINTERLEAVE4x4KERNEL_H*/
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Interface for simple C++ kernels having 1 tensor input and 1 tensor output.
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
Neon kernel to interleave the elements of a matrix.
static Status validate(const ITensorInfo *input, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEGEMMInterleave4x4Kerne...
NEGEMMInterleave4x4Kernel & operator=(const NEGEMMInterleave4x4Kernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
void configure(const ITensor *input, ITensor *output)
Initialise the kernel&#39;s input and output.
~NEGEMMInterleave4x4Kernel()=default
Default destructor.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Definition: CPPTypes.h:235
const char * name() const override
Name of the kernel.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Describe a multidimensional execution window.
Definition: Window.h:39