blob: 961b1901e736c0052be107338a97a89d9d3c66ba [file] [log] [blame]
Pablo Tello181e6512017-11-15 13:28:27 +00001/*
Michalis Spyrouebcebf12020-10-21 00:04:14 +01002 * Copyright (c) 2017-2020 Arm Limited.
Pablo Tello181e6512017-11-15 13:28:27 +00003 *
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 */
Michalis Spyrouf4643372019-11-29 16:17:13 +000024#ifndef ARM_COMPUTE_NEGEMMLOWPASSEMBLYMATRIXMULTIPLYCORE_H
25#define ARM_COMPUTE_NEGEMMLOWPASSEMBLYMATRIXMULTIPLYCORE_H
Pablo Tello181e6512017-11-15 13:28:27 +000026
Pablo Tello181e6512017-11-15 13:28:27 +000027#include "arm_compute/runtime/IFunction.h"
28#include "arm_compute/runtime/IMemoryManager.h"
29#include "arm_compute/runtime/MemoryGroup.h"
Anthony Barbier71d9b572018-07-06 17:05:59 +010030#include "arm_compute/runtime/NEON/functions/NEGEMMAssemblyDispatch.h"
Pablo Tello181e6512017-11-15 13:28:27 +000031#include "arm_compute/runtime/Tensor.h"
32
33#include <memory>
34
35namespace arm_compute
36{
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010037// Forward declarations
Pablo Tello181e6512017-11-15 13:28:27 +000038class ITensor;
Michalis Spyrouebcebf12020-10-21 00:04:14 +010039class NEGEMMInterleave4x4Kernel;
40class NEGEMMTranspose1xWKernel;
41class NEGEMMLowpMatrixMultiplyKernel;
Pablo Tello181e6512017-11-15 13:28:27 +000042
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010043/** Basic function to execute matrix multiply assembly kernels. */
Pablo Tello181e6512017-11-15 13:28:27 +000044class NEGEMMLowpAssemblyMatrixMultiplyCore : public IFunction
45{
46public:
47 /** Constructor */
48 NEGEMMLowpAssemblyMatrixMultiplyCore(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
Michalis Spyrouebcebf12020-10-21 00:04:14 +010049 /** Destructor */
50 ~NEGEMMLowpAssemblyMatrixMultiplyCore();
51
Pablo Tello181e6512017-11-15 13:28:27 +000052 /** Initialise the kernel's inputs, output
Anthony Barbierf202e502017-11-23 18:02:04 +000053 *
54 * @param[in] a First input tensor (Matrix A). Data type supported: U8, S8.
55 * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010056 * @param[in] c Third input tensor (Matrix C). Data type supported: same as @p a
Manuel Bottini581c8982019-02-07 10:31:57 +000057 * @param[out] output Output tensor. Data type supported: Data type supported: U32, S32
Anthony Barbierf202e502017-11-23 18:02:04 +000058 */
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010059 void configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *output);
Pablo Tello181e6512017-11-15 13:28:27 +000060
61 // Inherited methods overridden:
62 void run() override;
63
64private:
Michalis Spyrouebcebf12020-10-21 00:04:14 +010065 MemoryGroup _memory_group;
66 NEGEMMAssemblyDispatch _asm_glue;
67 std::unique_ptr<NEGEMMLowpMatrixMultiplyKernel> _mm_kernel;
68 std::unique_ptr<NEGEMMInterleave4x4Kernel> _mtx_a_reshape_kernel;
69 std::unique_ptr<NEGEMMTranspose1xWKernel> _mtx_b_reshape_kernel;
70 Tensor _tmp_a;
71 Tensor _tmp_b;
Pablo Tello181e6512017-11-15 13:28:27 +000072};
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010073} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000074#endif /*ARM_COMPUTE_NEGEMMLOWPASSEMBLYMATRIXMULTIPLYCORE_H */