blob: e298bfdebd0f8ad229146216536f2fb93caab0af [file] [log] [blame]
Moritz Pflanzerbeabe3b2017-08-31 14:56:32 +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_NEGEMMASSEMBLYBASE_H__
25#define __ARM_COMPUTE_NEGEMMASSEMBLYBASE_H__
26
27#include "arm_compute/core/NEON/INEKernel.h"
28
29namespace arm_compute
30{
31class ITensor;
32
33/** AssemblyBase/armv7a NEON kernel to multiply two input matrices "A" and "B". */
34class NEGEMMAssemblyBaseKernel : public INEKernel
35{
36public:
37 /** Constructor */
38 NEGEMMAssemblyBaseKernel()
39 : _input0(nullptr), _input1(nullptr), _output(nullptr), _workspace(nullptr), _alpha(1.f), _beta(0.f), _transform_0(true), _transform_1(true)
40 {
41 }
42
43 /** Prevent instances of this class from being copied (As this class contains pointers) */
44 NEGEMMAssemblyBaseKernel(const NEGEMMAssemblyBaseKernel &) = delete;
45 /** Prevent instances of this class from being copied (As this class contains pointers) */
46 NEGEMMAssemblyBaseKernel &operator=(const NEGEMMAssemblyBaseKernel &) = delete;
47 /** Allow instances of this class to be moved */
48 NEGEMMAssemblyBaseKernel(NEGEMMAssemblyBaseKernel &&) = default;
49 /** Allow instances of this class to be moved */
50 NEGEMMAssemblyBaseKernel &operator=(NEGEMMAssemblyBaseKernel &&) = default;
51
52 virtual ~NEGEMMAssemblyBaseKernel() = default;
53
54 /** Initialise the kernel's input and output.
55 *
56 * The computed function is C = a * AxB + b * C.
57 *
58 * @param[in] input0 Input tensor containing the Matrix A. Data types supported: F32
59 * @param[in] input1 Input tensor containing the Matrix B. Data types supported: same as @p input0
60 * @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.
61 * @param[out] workspace Space for intermediate results.
62 * @param[in] alpha Weight of the matrix product
63 * @param[in] beta Weight of the accumulation.
64 * @param[in] transform_0 If true the kernel will transform @p input0 prior to the multiplication.
65 * @param[in] transform_1 If true the kernel will transform @p input1 prior to the multiplication.
66 */
67 void configure(const ITensor *input0, const ITensor *input1, ITensor *output, ITensor *workspace, float alpha = 1.f, float beta = 0.f, bool transform_0 = true, bool transform_1 = true)
68 {
69 internal_configure(input0, input1, output, workspace, alpha, beta, transform_0, transform_1);
70 }
71
72protected:
73 virtual void internal_configure(const ITensor *input0, const ITensor *input1, ITensor *output, ITensor *workspace, float alpha, float beta, bool transform_0, bool transform_1) = 0;
74
75 const ITensor *_input0;
76 const ITensor *_input1;
77 ITensor *_output;
78 ITensor *_workspace;
79 float _alpha;
80 float _beta;
81 bool _transform_0;
82 bool _transform_1;
83};
84} // namespace arm_compute
85#endif /*__ARM_COMPUTE_NEGEMMASSEMBLYBASE_H__*/