Compute Library
 21.02
NEGEMMLowpMatrixMultiplyKernel.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-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_NEGEMMLOWPMATRIXMULTIPLYKERNEL_H
25 #define ARM_COMPUTE_NEGEMMLOWPMATRIXMULTIPLYKERNEL_H
26 
28 
29 namespace arm_compute
30 {
31 class ITensor;
32 
33 /** Neon kernel to multiply matrices
34  *
35  * @note @ref NEGEMMLowpMatrixMultiplyKernel low precision matrix product kernel
36  * This kernel performs the following computation:
37  *
38  * -# Convert a values from int8 to int32
39  * -# Convert b values from int8 to int32
40  * -# Compute the int32 matrix product of the resulting a * b and store the result as int32
41  *
42  */
44 {
45 public:
46  const char *name() const override
47  {
48  return "NEGEMMLowpMatrixMultiplyKernel";
49  }
50  /** Constructor */
52  /** Prevent instances of this class from being copied (As this class contains pointers)*/
54  /** Prevent instances of this class from being copied (As this class contains pointers)*/
56  /** Allow instances of this class to be moved */
58  /** Allow instances of this class to be moved */
60  /** Default destructor */
62  /** Initialise the kernel's input and output.
63  *
64  * The input matrices @p input0 and @p input1 must be the output of the kernels: @ref NEGEMMInterleave4x4Kernel and @ref NEGEMMTranspose1xWKernel. These two
65  * kernels change the layout of the original matrices to be more cache-friendly.
66  *
67  * @param[in] input0 Input tensor containing the interleaved Matrix A. Data type supported: U8/QASYMM8/S8/QASYMM8_SIGNED
68  * @param[in] input1 Input tensor containing the transposed1xW Matrix B. Data type supported: U8/QASYMM8/S8/QASYMM8_SIGNED/QSYMM8/QSYMM8_PER_CHANNEL
69  * @param[out] output Output tensor to store the result of matrix multiplication. Data type supported: S32
70  */
71  void configure(const ITensor *input0, const ITensor *input1, ITensor *output);
72  /** Static function to check if given info will lead to a valid configuration of @ref NEGEMMLowpMatrixMultiplyKernel
73  *
74  * @param[in] input0 Input tensor info containing the interleaved Matrix A. Data type supported: U8/QASYMM8/S8/QASYMM8_SIGNED
75  * @param[in] input1 Input tensor info containing the transposed Matrix B. Data type supported: U8/QASYMM8/S8/QASYMM8_SIGNED/QSYMM8/QSYMM8_PER_CHANNEL
76  * @param[in] output Output tensor info to store the result of matrix multiplication. Data type supported: S32
77  *
78  * @return a status
79  */
80  static Status validate(const ITensorInfo *input0, const ITensorInfo *input1, const ITensorInfo *output);
81 
82  // Inherited methods overridden:
83  void run(const Window &window, const ThreadInfo &info) override;
84 
85 private:
86  const ITensor *_input0;
87  const ITensor *_input1;
88  ITensor *_output;
89  bool _slide_matrix_b;
90 };
91 } // namespace arm_compute
92 #endif /*ARM_COMPUTE_NEGEMMLOWPMATRIXMULTIPLYKERNEL_H*/
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
Common interface for all kernels implemented in C++.
Definition: ICPPKernel.h:38
NEGEMMLowpMatrixMultiplyKernel & operator=(const NEGEMMLowpMatrixMultiplyKernel &)=delete
Prevent instances of this class from being copied (As this class contains pointers) ...
Store the tensor's metadata.
Definition: ITensorInfo.h:40
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
Status class.
Definition: Error.h:52
void configure(const ITensor *input0, const ITensor *input1, ITensor *output)
Initialise the kernel's input and output.
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
~NEGEMMLowpMatrixMultiplyKernel()=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.
static Status validate(const ITensorInfo *input0, const ITensorInfo *input1, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of NEGEMMLowpMatrixMultiply...
Describe a multidimensional execution window.
Definition: Window.h:39