xref: /aosp_15_r20/external/ComputeLibrary/src/core/NEON/kernels/convolution/winograd/input_transforms_fp32.cpp (revision c217d954acce2dbc11938adb493fc0abd69584f3)
1 /*
2  * Copyright (c) 2022 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 
25 #include "input_transform.hpp"
26 #include "winograd_implementations.hpp"
27 
28 #include <memory>
29 #include <string>
30 
31 namespace arm_conv {
32 namespace winograd {
33 namespace input_transform {
34 
35 #if defined(__aarch64__)
36 #if defined(ARM_COMPUTE_ENABLE_SVE)
37 #if defined(ARM_COMPUTE_ENABLE_SME)
38 void sme_fp32_mla_6x6(unsigned int, const float *, size_t, size_t, float *, size_t);
39 #endif  // defined(ARM_COMPUTE_ENABLE_SME)
40 void sve_fp32_6x6(unsigned int, const float *, size_t, size_t, float *, size_t);
41 #endif  // defined(ARM_COMPUTE_ENABLE_SVE)
42 void a64_fp32_6x6(unsigned int, const float *, size_t, size_t, float *, size_t);
43 #else  // defined(__aarch64__)
44 void arm_fp32_6x6(unsigned int, const float *, size_t, size_t, float *, size_t);
45 #endif  // defined(__aarch64__)
46 void arm_fp32_4x4(unsigned int, const float *, size_t, size_t, float *, size_t);
47 void arm_fp32_1x8(unsigned int, const float *, size_t, size_t, float *, size_t);
48 
49 #define IMPL(HEIGHT, WIDTH, FUNC, DRIVER) new Transform ## DRIVER <float, float>(#FUNC, HEIGHT, WIDTH, FUNC)
50 
51 static const TransformImplementation<float> transforms_fp32[] = {
52 #if defined(__aarch64__)
53 #if defined(ARM_COMPUTE_ENABLE_SVE)
54 #if defined(ARM_COMPUTE_ENABLE_SME)
55   { IMPL(6, 6, sme_fp32_mla_6x6, Unpadded), MethodConstraints::RequiresSME },
56 #endif  // defined(ARM_COMPUTE_ENABLE_SME)
57   { IMPL(6, 6, sve_fp32_6x6, Unpadded), MethodConstraints::RequiresSVE },
58 #endif  // defined(ARM_COMPUTE_ENABLE_SVE)
59   { IMPL(6, 6, a64_fp32_6x6, Unpadded) },
60 #else  // defined(__aarch64__)
61   { IMPL(6, 6, arm_fp32_6x6, Unpadded) },
62 #endif  // defined(__aarch64__)
63   { IMPL(4, 4, arm_fp32_4x4, Unpadded) },
64   { IMPL(1, 8, arm_fp32_1x8, Unpadded) },
65   { new TransformUnpadded<float, float>("arm_fp32_1x8", 8, 1, TransformUnpadded<float, float>::get_transposed_kernel(arm_fp32_1x8)) },
66   { nullptr },
67 };
68 
69 template <>
implementation_list(void)70 const TransformImplementation<float> *implementation_list(void)
71 {
72   return transforms_fp32;
73 }
74 
75 }  // namespace input_transform
76 }  // namespace winograd
77 }  // namespace arm_conv
78