blob: 4866e781f5f8ae57e989915b398ebe4d60371877 [file] [log] [blame]
Gian Marco Iodiceab182122017-10-09 15:05:40 +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_NEGEMMLOWPMATRIXMULTIPLYCORE_H__
25#define __ARM_COMPUTE_NEGEMMLOWPMATRIXMULTIPLYCORE_H__
26
27#include "arm_compute/core/NEON/INEKernel.h"
28#include "arm_compute/runtime/IFunction.h"
29#include "arm_compute/runtime/IMemoryManager.h"
30#include "arm_compute/runtime/MemoryGroup.h"
31#include "arm_compute/runtime/Tensor.h"
32
33#include <memory>
34
35namespace arm_compute
36{
37class ITensor;
38
39/** Basic function to execute GEMMLowpMatrixMultiplyCore on NEON. This function calls the following NEON kernels if the DOT product instruction is not available:
40 *
41 * -# @ref NEGEMMInterleave4x4Kernel
42 * -# @ref NEGEMMTranspose1xWKernel
43 * -# @ref NEGEMMLowpMatrixMultiplyKernel
44 *
45 * otherwise if the DOT product instruction is available:
46 *
47 * -# @ref NEGEMMInterleaveBlockedKernel
48 * -# @ref NEGEMMLowpAArch64V8P4Kernel
49 *
50*/
51class NEGEMMLowpMatrixMultiplyCore : public IFunction
52{
53public:
54 /** Constructor */
55 NEGEMMLowpMatrixMultiplyCore(std::shared_ptr<IMemoryManager> memory_manager = nullptr);
56 /** Initialise the kernel's inputs, output
57 *
58 * @note GEMM_LOWP: low precision GEMM kernel
59 * This kernel performs the following computations:
60 *
61 * -# Convert a values from uint8 to int32
62 * -# Convert b values from uint8 to int32
63 * -# Compute the int32 matrix product of the resulting a * b.
64 *
65 * @param[in] a First input tensor (Matrix A). Data type supported: U8.
66 * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a
67 * @param[out] output Output tensor. Data type supported: Data type supported: S32
68 */
69 void configure(const ITensor *a, const ITensor *b, ITensor *output);
70
71 // Inherited methods overridden:
72 void run() override;
73
74private:
75 MemoryGroup _memory_group;
76 std::unique_ptr<INEKernel> _mm_kernel;
77 std::unique_ptr<INEKernel> _mtx_a_reshape_kernel;
78 std::unique_ptr<INEKernel> _mtx_b_reshape_kernel;
79 Tensor _tmp_a;
80 Tensor _tmp_b;
81};
82}
83#endif /*__ARM_COMPUTE_NEGEMMLOWPMATRIXMULTIPLYCORE_H__ */