blob: 3a0b22f148d303e5a39452e4ae4904f3902f79e0 [file] [log] [blame]
Anthony Barbier7068f992017-10-26 15:23:08 +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_GCGEMMMATRIXMULTIPLYKERNEL_H__
25#define __ARM_COMPUTE_GCGEMMMATRIXMULTIPLYKERNEL_H__
26
27#include "arm_compute/core/GLES_COMPUTE/IGCKernel.h"
28
29namespace arm_compute
30{
31class IGCTensor;
32
33/** GLES Compute kernel to multiply two input matrices "A" and "B" or to multiply a vector "A" by a matrix "B". All elements of the output matrix/vector will be multiplied by alpha
34 *
35 * @note If the output tensor is a matrix, the implementation assumes that the input tensors @p input0 and @p input1 are both matrices and reshaped respectively with @ref GCGEMMInterleave4x4Kernel" and @ref GCGEMMTranspose1xWKernel
36 * @note If the output tensor is a vector and the data type is F32, the implementation assumes that the first input tensor @p input0 is a vector and the second input tensor @p input1 a matrix. The implementation also assumes that both tensors have not been reshaped
37 *
38 * @attention The second input tensor must have at least 2 dimensions (matrix)
39 *
40 */
41class GCGEMMMatrixMultiplyKernel : public IGCKernel
42{
43public:
44 /** Default constructor */
45 GCGEMMMatrixMultiplyKernel();
46
47 /** Prevent instances of this class from being copied (As this class contains pointers) */
48 GCGEMMMatrixMultiplyKernel(const GCGEMMMatrixMultiplyKernel &) = delete;
49
50 /** Prevent instances of this class from being copied (As this class contains pointers) */
51 GCGEMMMatrixMultiplyKernel &operator=(const GCGEMMMatrixMultiplyKernel &) = delete;
52
53 /** Allow instances of this class to be moved */
54 GCGEMMMatrixMultiplyKernel(GCGEMMMatrixMultiplyKernel &&) = default;
55
56 /** Allow instances of this class to be moved */
57 GCGEMMMatrixMultiplyKernel &operator=(GCGEMMMatrixMultiplyKernel &&) = default;
58
59 /** Initialise the kernel's input, output and alpha
60 *
61 * @param[in] input0 Input tensor containing the interleaved Matrix A or the vector A. Data types supported: F16/F32
62 * @param[in] input1 Input tensor containing the transposed Matrix B if the first input tensor A is not a vector.
63 * If the output tensor is a vector, input1 must contain the matrix B not reshaped. Data type supported: same as @p input0
64 * @param[out] output Output tensor to store the result of matrix multiplication. Data type supported: same as @p input0
65 * @param[in] alpha Weight of the matrix product
66 * @param[in] is_interleaved_transposed (Optional) True if input0 and input1 have been reshaped respectively using @ref GCGEMMInterleave4x4Kernel and @ref GCGEMMTranspose1xWKernel
67 */
68 void configure(const IGCTensor *input0, const IGCTensor *input1, IGCTensor *output, float alpha, bool is_interleaved_transposed = true);
69
70 // Inherited methods overridden:
71 void run(const Window &window) override;
72
73private:
74 const IGCTensor *_input0;
75 const IGCTensor *_input1;
76 IGCTensor *_output;
77};
78}
79#endif /* __ARM_COMPUTE_GCGEMMMATRIXMULTIPLYKERNEL_H__ */