blob: 083ee187effe5703cb6f27aa0c67008483505b14 [file] [log] [blame]
Manuel Bottinicfac51c2021-06-18 15:47:28 +01001/*
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_CPU_GEMMLOWP_MATRIXMULTIPLY_KERNEL_H
25#define ARM_COMPUTE_CPU_GEMMLOWP_MATRIXMULTIPLY_KERNEL_H
26
27#include "src/core/common/Macros.h"
Georgios Pinitas7891a732021-08-20 21:39:25 +010028#include "src/cpu/ICpuKernel.h"
Manuel Bottinicfac51c2021-06-18 15:47:28 +010029
30namespace arm_compute
31{
32namespace cpu
33{
34namespace kernels
35{
36/** Kernel to multiply matrices
37 *
38 * @note @ref CpuGemmLowpMatrixMultiplyKernel low precision matrix product kernel
39 * This kernel performs the following computation:
40 *
41 * -# Convert a values from int8 to int32
42 * -# Convert b values from int8 to int32
43 * -# Compute the int32 matrix product of the resulting a * b and store the result as int32
44 *
45 */
46class CpuGemmLowpMatrixMultiplyKernel : public ICpuKernel
47{
48public:
49 /** Default constructor */
50 CpuGemmLowpMatrixMultiplyKernel() = default;
51 ARM_COMPUTE_DISALLOW_COPY_ALLOW_MOVE(CpuGemmLowpMatrixMultiplyKernel);
52 /** Initialise the kernel's input and output.
53 *
54 * The input matrices @p src0 and @p src1 must be the output of the kernels: @ref CpuGemmInterleave4x4Kernel and @ref CpuGemmTranspose1xWKernel. These two
55 * kernels change the layout of the original matrices to be more cache-friendly.
56 *
57 * @param[in] src0 Input tensor info containing the interleaved Matrix A. Data type supported: U8/QASYMM8/S8/QASYMM8_SIGNED
58 * @param[in] src1 Input tensor info containing the transposed1xW Matrix B. Data type supported: U8/QASYMM8/S8/QASYMM8_SIGNED/QSYMM8/QSYMM8_PER_CHANNEL
59 * @param[out] dst Output tensor info to store the result of matrix multiplication. Data type supported: S32
60 */
61 void configure(const ITensorInfo *src0, const ITensorInfo *src1, ITensorInfo *dst);
62 /** Static function to check if given info will lead to a valid configuration
63 *
64 * Similar to CpuGemmLowpMatrixMultiplyKernel::configure()
65 *
66 * @return a status
67 */
68 static Status validate(const ITensorInfo *src0, const ITensorInfo *src1, const ITensorInfo *dst);
69
70 // Inherited methods overridden:
71 void run_op(ITensorPack &tensors, const Window &window, const ThreadInfo &info) override;
72 const char *name() const override;
73
74private:
75 bool _slide_matrix_b{ true };
76};
77} // namespace kernels
78} // namespace cpu
79} // namespace arm_compute
80#endif /*ARM_COMPUTE_CPU_GEMMLOWP_MATRIXMULTIPLY_KERNEL_H*/