blob: 44124a7b41339bc2fa65ca01250afe0772df75a1 [file] [log] [blame]
David Manselld93991e2018-07-06 14:52:52 +01001/*
2 * Copyright (c) 2017-2018 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#pragma once
25
26namespace arm_gemm {
27
28/*
29 * Define "standard" transforms for the blocked GEMMs with fixed vector
30 * length.
31 *
32 * This assumes that A is interleaved 'height' ways, B is interleaved
33 * 'width' ways and transposed, and that the merge needs to work in 'height'
34 * x 'width' blocks.
35 *
36 * The optional 'block' parameter is for kernels using dot-product type
37 * instructions like UDOT and SDOT.
38 */
39template<typename TOperand, typename TResult, unsigned int height, unsigned int width, unsigned int block=1>
40class StdTransformsFixed
41{
42public:
43 template<typename TIn>
44 void PrepareA(TOperand *out, const TIn *in, const int stride, const int y0,
45 const int ymax, const int k0, const int kmax, bool transposed) {
46 if (transposed) {
47 Transform<height, block, true>(out, in, stride, y0, ymax, k0, kmax);
48 } else {
49 Transform<height, block, false>(out, in, stride, y0, ymax, k0, kmax);
50 }
51 }
52
53 template<typename TIn>
54 void PrepareB(TOperand *out, const TIn *in, const int stride, const int x0,
55 const int xmax, const int k0, const int kmax, bool transposed) {
56 if (transposed) {
57 Transform<width, block, false>(out, in, stride, x0, xmax, k0, kmax);
58 } else {
59 Transform<width, block, true>(out, in, stride, x0, xmax, k0, kmax);
60 }
61 }
62
63 template<typename TOut>
64 void Merge(TOut *out, const TResult *in, int stride, int y0, int ymax, int x0, int xmax, const TOut alpha, const TOut beta) {
65 MergeResults<width, height>(out, in, stride, y0, ymax, x0, xmax, alpha, beta);
66 }
67};
68
69} // namespace arm_gemm