blob: 6aa8e250a4aef2af976ed7317a2aa94f6ced39fc [file] [log] [blame]
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +01001/*
Michalis Spyrouf4643372019-11-29 16:17:13 +00002 * Copyright (c) 2017-2019 ARM Limited.
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +01003 *
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_NEGEMMASSEMBLYBASE_H
25#define ARM_COMPUTE_NEGEMMASSEMBLYBASE_H
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010026
27#include "arm_compute/core/NEON/INEKernel.h"
28
29namespace arm_compute
30{
31class ITensor;
32
Pablo Tello6ff12a02017-11-02 16:09:35 +000033/** Base class for GEMM NEON kernels implemented in Assembly. */
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010034class NEGEMMAssemblyBaseKernel : public INEKernel
35{
36public:
Anthony Barbiere8a49832018-01-18 10:04:05 +000037 const char *name() const override
38 {
39 return "NEGEMMAssemblyBaseKernel";
40 }
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010041 /** Constructor */
42 NEGEMMAssemblyBaseKernel()
Georgios Pinitas08c5a062017-12-14 17:53:39 +000043 : _input0(nullptr), _input1(nullptr), _output(nullptr), _workspace(nullptr), _alpha(1.f), _beta(0.f), _is_transposed_0(false), _is_transposed_1(false)
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010044 {
45 }
46
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 NEGEMMAssemblyBaseKernel(const NEGEMMAssemblyBaseKernel &) = delete;
49 /** Prevent instances of this class from being copied (As this class contains pointers) */
50 NEGEMMAssemblyBaseKernel &operator=(const NEGEMMAssemblyBaseKernel &) = delete;
51 /** Allow instances of this class to be moved */
52 NEGEMMAssemblyBaseKernel(NEGEMMAssemblyBaseKernel &&) = default;
53 /** Allow instances of this class to be moved */
54 NEGEMMAssemblyBaseKernel &operator=(NEGEMMAssemblyBaseKernel &&) = default;
55
56 virtual ~NEGEMMAssemblyBaseKernel() = default;
57
58 /** Initialise the kernel's input and output.
59 *
60 * The computed function is C = a * AxB + b * C.
61 *
Georgios Pinitas08c5a062017-12-14 17:53:39 +000062 * @param[in] input0 Input tensor containing the Matrix A. Data types supported: F32
63 * @param[in] input1 Input tensor containing the Matrix B. Data types supported: same as @p input0
64 * @param[in,out] output Output tensor to store the result of matrix multiplication. If @p beta is not zero the values are multiplied by @p beta before the result is accumulated. Otherwise the values are overwritten by the result. Data types supported: same as @p input0.
65 * @param[out] workspace Space for intermediate results.
66 * @param[in] alpha Weight of the matrix product
67 * @param[in] beta Weight of the accumulation.
68 * @param[in] is_transposed_0 (Optional)True if @p input0 is transposed else false. (Defaults to false)
69 * @param[in] is_transposed_1 (Optional)True if @p input1 is transposed else false. (Defaults to false)
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010070 */
Georgios Pinitas08c5a062017-12-14 17:53:39 +000071 void configure(const ITensor *input0, const ITensor *input1, ITensor *output, ITensor *workspace, float alpha = 1.f, float beta = 0.f, bool is_transposed_0 = false, bool is_transposed_1 = false)
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010072 {
Georgios Pinitas08c5a062017-12-14 17:53:39 +000073 internal_configure(input0, input1, output, workspace, alpha, beta, is_transposed_0, is_transposed_1);
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010074 }
75
76protected:
Georgios Pinitas08c5a062017-12-14 17:53:39 +000077 virtual void internal_configure(const ITensor *input0, const ITensor *input1, ITensor *output, ITensor *workspace, float alpha, float beta, bool _is_transposed_0, bool _is_transposed_1) = 0;
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010078
79 const ITensor *_input0;
80 const ITensor *_input1;
81 ITensor *_output;
82 ITensor *_workspace;
83 float _alpha;
84 float _beta;
Georgios Pinitas08c5a062017-12-14 17:53:39 +000085 bool _is_transposed_0;
86 bool _is_transposed_1;
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +010087};
88} // namespace arm_compute
Michalis Spyrouf4643372019-11-29 16:17:13 +000089#endif /*ARM_COMPUTE_NEGEMMASSEMBLYBASE_H*/