Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 1 | /* |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2020 Arm Limited. |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [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 | */ |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 24 | #ifndef ARM_COMPUTE_NEGEMMLOWPASSEMBLYMATRIXMULTIPLYCORE_H |
| 25 | #define ARM_COMPUTE_NEGEMMLOWPASSEMBLYMATRIXMULTIPLYCORE_H |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 26 | |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 27 | #include "arm_compute/runtime/IFunction.h" |
| 28 | #include "arm_compute/runtime/IMemoryManager.h" |
| 29 | #include "arm_compute/runtime/MemoryGroup.h" |
Anthony Barbier | 71d9b57 | 2018-07-06 17:05:59 +0100 | [diff] [blame] | 30 | #include "arm_compute/runtime/NEON/functions/NEGEMMAssemblyDispatch.h" |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 31 | #include "arm_compute/runtime/Tensor.h" |
| 32 | |
| 33 | #include <memory> |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
Georgios Pinitas | cfa2bba | 2019-06-27 17:00:52 +0100 | [diff] [blame] | 37 | // Forward declarations |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 38 | class ITensor; |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 39 | class NEGEMMInterleave4x4Kernel; |
| 40 | class NEGEMMTranspose1xWKernel; |
| 41 | class NEGEMMLowpMatrixMultiplyKernel; |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 42 | |
Georgios Pinitas | cfa2bba | 2019-06-27 17:00:52 +0100 | [diff] [blame] | 43 | /** Basic function to execute matrix multiply assembly kernels. */ |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 44 | class NEGEMMLowpAssemblyMatrixMultiplyCore : public IFunction |
| 45 | { |
| 46 | public: |
| 47 | /** Constructor */ |
| 48 | NEGEMMLowpAssemblyMatrixMultiplyCore(std::shared_ptr<IMemoryManager> memory_manager = nullptr); |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 49 | /** Destructor */ |
| 50 | ~NEGEMMLowpAssemblyMatrixMultiplyCore(); |
| 51 | |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 52 | /** Initialise the kernel's inputs, output |
Anthony Barbier | f202e50 | 2017-11-23 18:02:04 +0000 | [diff] [blame] | 53 | * |
| 54 | * @param[in] a First input tensor (Matrix A). Data type supported: U8, S8. |
| 55 | * @param[in] b Second input tensor (Matrix B). Data type supported: same as @p a |
Georgios Pinitas | cfa2bba | 2019-06-27 17:00:52 +0100 | [diff] [blame] | 56 | * @param[in] c Third input tensor (Matrix C). Data type supported: same as @p a |
Manuel Bottini | 581c898 | 2019-02-07 10:31:57 +0000 | [diff] [blame] | 57 | * @param[out] output Output tensor. Data type supported: Data type supported: U32, S32 |
Anthony Barbier | f202e50 | 2017-11-23 18:02:04 +0000 | [diff] [blame] | 58 | */ |
Georgios Pinitas | cfa2bba | 2019-06-27 17:00:52 +0100 | [diff] [blame] | 59 | void configure(const ITensor *a, const ITensor *b, const ITensor *c, ITensor *output); |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 60 | |
| 61 | // Inherited methods overridden: |
| 62 | void run() override; |
| 63 | |
| 64 | private: |
Michalis Spyrou | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 65 | MemoryGroup _memory_group; |
| 66 | NEGEMMAssemblyDispatch _asm_glue; |
| 67 | std::unique_ptr<NEGEMMLowpMatrixMultiplyKernel> _mm_kernel; |
| 68 | std::unique_ptr<NEGEMMInterleave4x4Kernel> _mtx_a_reshape_kernel; |
| 69 | std::unique_ptr<NEGEMMTranspose1xWKernel> _mtx_b_reshape_kernel; |
| 70 | Tensor _tmp_a; |
| 71 | Tensor _tmp_b; |
Pablo Tello | 181e651 | 2017-11-15 13:28:27 +0000 | [diff] [blame] | 72 | }; |
Georgios Pinitas | cfa2bba | 2019-06-27 17:00:52 +0100 | [diff] [blame] | 73 | } // namespace arm_compute |
Michalis Spyrou | f464337 | 2019-11-29 16:17:13 +0000 | [diff] [blame] | 74 | #endif /*ARM_COMPUTE_NEGEMMLOWPASSEMBLYMATRIXMULTIPLYCORE_H */ |