blob: f145eb6ca36bbb8d646c6ac75319df38b7fffc45 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
2 * Copyright (c) 2017 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
27#include "arm_compute/core/NEON/INEKernel.h"
28
29namespace arm_compute
30{
31class 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 *
Pablo Tello6ff12a02017-11-02 16:09:35 +000038 * -# Convert a values from int8 to int32
39 * -# Convert b values from int8 to int32
Gian Marco Iodiceab182122017-10-09 15:05:40 +010040 * -# Compute the int32 matrix product of the resulting a * b and store the result as int32
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041 *
42 */
43class NEGEMMLowpMatrixMultiplyKernel : public INEKernel
44{
45public:
46 /** Constructor */
47 NEGEMMLowpMatrixMultiplyKernel();
48 /** Prevent instances of this class from being copied (As this class contains pointers)*/
49 NEGEMMLowpMatrixMultiplyKernel(const NEGEMMLowpMatrixMultiplyKernel &) = delete;
50 /** Prevent instances of this class from being copied (As this class contains pointers)*/
51 NEGEMMLowpMatrixMultiplyKernel &operator=(const NEGEMMLowpMatrixMultiplyKernel &) = delete;
52 /** Allow instances of this class to be moved */
53 NEGEMMLowpMatrixMultiplyKernel(NEGEMMLowpMatrixMultiplyKernel &&) = default;
54 /** Allow instances of this class to be moved */
55 NEGEMMLowpMatrixMultiplyKernel &operator=(NEGEMMLowpMatrixMultiplyKernel &&) = default;
56 /** Initialise the kernel's input and output.
57 *
58 * The input matrices @p input0 and @p input1 must be the output of the kernels: @ref NEGEMMInterleave4x4Kernel and @ref NEGEMMTranspose1xWKernel. These two
59 * kernels change the layout of the original matrices to be more cache-friendly.
60 *
Pablo Tello6ff12a02017-11-02 16:09:35 +000061 * @param[in] input0 Input tensor containing the interleaved Matrix A. Data type supported: S8
Gian Marco Iodiceab182122017-10-09 15:05:40 +010062 * @param[in] input1 Input tensor containing the transposed Matrix B. Data type supported: same as @p input0
63 * @param[out] output Output tensor to store the result of matrix multiplication. Data type supported: S32
Anthony Barbier6ff3b192017-09-04 18:44:23 +010064 */
Gian Marco Iodiceab182122017-10-09 15:05:40 +010065 void configure(const ITensor *input0, const ITensor *input1, ITensor *output);
66
Anthony Barbier6ff3b192017-09-04 18:44:23 +010067 // Inherited methods overridden:
Moritz Pflanzerc186b572017-09-07 09:48:04 +010068 void run(const Window &window, const ThreadInfo &info) override;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010069
70private:
71 const ITensor *_input0;
72 const ITensor *_input1;
73 ITensor *_output;
Gian Marco Iodiceab182122017-10-09 15:05:40 +010074 bool _slide_matrix_b;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010075};
Gian Marco Iodice356f6432017-09-22 11:32:21 +010076} // namespace arm_compute
Pablo Tello6ff12a02017-11-02 16:09:35 +000077#endif /*__ARM_COMPUTE_NEGEMMLOWPMATRIXMULTIPLYKERNEL_H__*/