David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 5aa1a0b | 2020-07-02 20:02:20 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2017-2018 ARM Limited. |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 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 | |
Georgios Pinitas | cfa2bba | 2019-06-27 17:00:52 +0100 | [diff] [blame] | 26 | #include "mergeresults.hpp" |
| 27 | #include "transform.hpp" |
| 28 | |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 29 | namespace arm_gemm { |
| 30 | |
| 31 | /* |
| 32 | * Define "standard" transforms for the blocked GEMMs with fixed vector |
| 33 | * length. |
| 34 | * |
| 35 | * This assumes that A is interleaved 'height' ways, B is interleaved |
| 36 | * 'width' ways and transposed, and that the merge needs to work in 'height' |
| 37 | * x 'width' blocks. |
| 38 | * |
| 39 | * The optional 'block' parameter is for kernels using dot-product type |
| 40 | * instructions like UDOT and SDOT. |
| 41 | */ |
| 42 | template<typename TOperand, typename TResult, unsigned int height, unsigned int width, unsigned int block=1> |
| 43 | class StdTransformsFixed |
| 44 | { |
| 45 | public: |
| 46 | template<typename TIn> |
| 47 | void PrepareA(TOperand *out, const TIn *in, const int stride, const int y0, |
Georgios Pinitas | 5aa1a0b | 2020-07-02 20:02:20 +0100 | [diff] [blame^] | 48 | const int ymax, const int k0, const int kmax, bool transposed) const { |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 49 | if (transposed) { |
| 50 | Transform<height, block, true>(out, in, stride, y0, ymax, k0, kmax); |
| 51 | } else { |
| 52 | Transform<height, block, false>(out, in, stride, y0, ymax, k0, kmax); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | template<typename TIn> |
| 57 | void PrepareB(TOperand *out, const TIn *in, const int stride, const int x0, |
Georgios Pinitas | 5aa1a0b | 2020-07-02 20:02:20 +0100 | [diff] [blame^] | 58 | const int xmax, const int k0, const int kmax, bool transposed) const { |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 59 | if (transposed) { |
| 60 | Transform<width, block, false>(out, in, stride, x0, xmax, k0, kmax); |
| 61 | } else { |
| 62 | Transform<width, block, true>(out, in, stride, x0, xmax, k0, kmax); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | template<typename TOut> |
Georgios Pinitas | 5aa1a0b | 2020-07-02 20:02:20 +0100 | [diff] [blame^] | 67 | 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 Pinitas | 48b3ef8 | 2019-10-14 19:03:09 +0100 | [diff] [blame] | 68 | MergeResults<width, height>(out, in, stride, y0, ymax, x0, xmax, bias, act, append); |
David Mansell | d93991e | 2018-07-06 14:52:52 +0100 | [diff] [blame] | 69 | } |
| 70 | }; |
| 71 | |
| 72 | } // namespace arm_gemm |