blob: 4669be9993f2db1a97b66c289208232e48c98689 [file] [log] [blame]
David Manselld93991e2018-07-06 14:52:52 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2018 Arm Limited.
David Manselld93991e2018-07-06 14:52:52 +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 */
24#pragma once
25
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000026#include "convolver.hpp"
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010027#include "mergeresults.hpp"
28#include "transform.hpp"
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000029#include "interleave_indirect.hpp"
Georgios Pinitascfa2bba2019-06-27 17:00:52 +010030
David Manselld93991e2018-07-06 14:52:52 +010031namespace arm_gemm {
32
33/*
34 * Define "standard" transforms for the blocked GEMMs with fixed vector
35 * length.
36 *
37 * This assumes that A is interleaved 'height' ways, B is interleaved
38 * 'width' ways and transposed, and that the merge needs to work in 'height'
39 * x 'width' blocks.
40 *
41 * The optional 'block' parameter is for kernels using dot-product type
42 * instructions like UDOT and SDOT.
43 */
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000044template<typename TOperand, typename TResult, unsigned int height, unsigned int width, unsigned int block=1, bool integrate_sums=false>
David Manselld93991e2018-07-06 14:52:52 +010045class StdTransformsFixed
46{
47public:
48 template<typename TIn>
49 void PrepareA(TOperand *out, const TIn *in, const int stride, const int y0,
Georgios Pinitasc0b6f762020-11-02 01:37:17 +000050 const int ymax, const int k0, const int kmax, int32_t row_sum_multiplier) const {
51 Interleave<height, block, VLType::None>(out, in, stride, y0, ymax, k0, kmax, integrate_sums, row_sum_multiplier);
52 }
53
54 template<typename TIn>
55 void PrepareA_indirect(TOperand *out, const TIn * const * const *ptr, size_t stringlen, size_t rounded_stringlen, const int y0,
56 const int ymax, const int k0, const int kmax, int32_t row_sum_multiplier) {
57 IndirectInterleave<height, block, VLType::None>(out, ptr, stringlen, rounded_stringlen, y0, ymax, k0, kmax, integrate_sums, row_sum_multiplier);
58 }
59
60 template<typename TIn>
61 void PrepareA_convolution(TOperand *out, const TIn *ptr, size_t stride, const convolver<TIn> &conv, size_t rounded_stringlen,
62 const int y0, const int ymax, const int k0, const int kmax, int32_t row_sum_multiplier) {
63 ConvolutionInterleave<height, block, VLType::None>(out, ptr, stride, conv, rounded_stringlen, y0, ymax, k0, kmax, integrate_sums, row_sum_multiplier);
David Manselld93991e2018-07-06 14:52:52 +010064 }
65
66 template<typename TIn>
67 void PrepareB(TOperand *out, const TIn *in, const int stride, const int x0,
Georgios Pinitas0cc50ed2020-07-06 19:10:38 +010068 const int xmax, const int k0, const int kmax) const {
69 Transform<width, block, true>(out, in, stride, x0, xmax, k0, kmax);
David Manselld93991e2018-07-06 14:52:52 +010070 }
71
72 template<typename TOut>
Georgios Pinitas5aa1a0b2020-07-02 20:02:20 +010073 void Merge(TOut *out, const TResult *in, int stride, int y0, int ymax, int x0, int xmax, const TOut *bias, const Activation act, bool append) const {
Georgios Pinitas48b3ef82019-10-14 19:03:09 +010074 MergeResults<width, height>(out, in, stride, y0, ymax, x0, xmax, bias, act, append);
David Manselld93991e2018-07-06 14:52:52 +010075 }
76};
77
78} // namespace arm_gemm