giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1 | /* |
SiCongLi | b88272e | 2021-02-24 15:40:57 +0000 | [diff] [blame] | 2 | * Copyright (c) 2019-2021 Arm Limited. |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +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 | ebcebf1 | 2020-10-21 00:04:14 +0100 | [diff] [blame] | 24 | #include "src/core/NEON/kernels/NEFFTRadixStageKernel.h" |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 25 | |
| 26 | #include "arm_compute/core/ITensor.h" |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 27 | #include "arm_compute/core/TensorInfo.h" |
| 28 | #include "arm_compute/core/Types.h" |
| 29 | #include "arm_compute/core/Utils.h" |
| 30 | #include "arm_compute/core/Window.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 31 | |
Sang-Hoon Park | 68dd25f | 2020-10-19 16:00:11 +0100 | [diff] [blame] | 32 | #include "src/core/helpers/AutoConfiguration.h" |
| 33 | #include "src/core/helpers/WindowHelpers.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 34 | #include "src/core/NEON/wrapper/traits.h" |
| 35 | #include "src/core/NEON/wrapper/wrapper.h" |
SiCongLi | 410e21e | 2020-12-11 15:07:53 +0000 | [diff] [blame] | 36 | #include "support/ToolchainSupport.h" |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 37 | |
| 38 | #include <arm_neon.h> |
| 39 | #include <cmath> |
| 40 | #include <complex> |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 41 | #include <map> |
| 42 | |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 43 | namespace arm_compute |
| 44 | { |
| 45 | namespace |
| 46 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 47 | // PI constant (from cmath) |
| 48 | constexpr float kPi = float(M_PI); |
| 49 | |
| 50 | // Constant used in the fft_3 kernel |
| 51 | constexpr float kSqrt3Div2 = 0.866025403784438; |
| 52 | |
| 53 | // Constants used in the fft_5 kernel |
| 54 | constexpr float kW5_0 = 0.30901699437494f; |
| 55 | constexpr float kW5_1 = 0.95105651629515f; |
| 56 | constexpr float kW5_2 = 0.80901699437494f; |
| 57 | constexpr float kW5_3 = 0.58778525229247f; |
| 58 | |
| 59 | // Constants used in the fft_7 kernel |
| 60 | constexpr float kW7_0 = 0.62348980185873f; |
| 61 | constexpr float kW7_1 = 0.78183148246802f; |
| 62 | constexpr float kW7_2 = 0.22252093395631f; |
| 63 | constexpr float kW7_3 = 0.97492791218182f; |
| 64 | constexpr float kW7_4 = 0.90096886790241f; |
| 65 | constexpr float kW7_5 = 0.43388373911755f; |
| 66 | |
| 67 | // Constant used in the fft_8 kernel |
| 68 | constexpr float kSqrt2Div2 = 0.707106781186548; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 69 | |
| 70 | float32x2_t c_mul_neon(float32x2_t a, float32x2_t b) |
| 71 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 72 | using ExactTagType = typename wrapper::traits::neon_vector<float, 2>::tag_type; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 73 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 74 | const float32x2_t mask = {-1.0, 1.0}; |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 75 | const float32x2_t tmp0 = wrapper::vdup_n(wrapper::vgetlane(a, 0), ExactTagType{}); |
| 76 | const float32x2_t tmp1 = wrapper::vdup_n(wrapper::vgetlane(a, 1), ExactTagType{}); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 77 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 78 | float32x2_t res = wrapper::vmul(tmp0, b); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 79 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 80 | b = wrapper::vrev64(b); |
| 81 | b = wrapper::vmul(b, mask); |
| 82 | res = wrapper::vmla(res, tmp1, b); |
| 83 | |
| 84 | return res; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | float32x2_t c_mul_neon_img(float32x2_t a, float img_constant) |
| 88 | { |
| 89 | const float a_r = wrapper::vgetlane(a, 0); |
| 90 | const float a_i = wrapper::vgetlane(a, 1); |
| 91 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 92 | const auto out = wrapper::vmul(float32x2_t{-a_i, a_r}, float32x2_t{img_constant, img_constant}); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 93 | return out; |
| 94 | } |
| 95 | |
| 96 | float32x2_t reduce_sum_5(float32x2_t a, float32x2_t b, float32x2_t c, float32x2_t d, float32x2_t e) |
| 97 | { |
| 98 | const auto t0 = wrapper::vadd(a, b); |
| 99 | const auto t1 = wrapper::vadd(c, d); |
| 100 | const auto t2 = wrapper::vadd(t0, t1); |
| 101 | return wrapper::vadd(t2, e); |
| 102 | } |
| 103 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 104 | float32x2_t reduce_sum_7( |
| 105 | float32x2_t x1, float32x2_t x2, float32x2_t x3, float32x2_t x4, float32x2_t x5, float32x2_t x6, float32x2_t x7) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 106 | { |
| 107 | const auto t0 = wrapper::vadd(x1, x2); |
| 108 | const auto t1 = wrapper::vadd(x3, x4); |
| 109 | const auto t2 = wrapper::vadd(x5, x6); |
| 110 | const auto t00 = wrapper::vadd(t0, t1); |
| 111 | const auto t01 = wrapper::vadd(t2, x7); |
| 112 | |
| 113 | return wrapper::vadd(t00, t01); |
| 114 | } |
| 115 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 116 | float32x2_t reduce_sum_8(float32x2_t x1, |
| 117 | float32x2_t x2, |
| 118 | float32x2_t x3, |
| 119 | float32x2_t x4, |
| 120 | float32x2_t x5, |
| 121 | float32x2_t x6, |
| 122 | float32x2_t x7, |
| 123 | float32x2_t x8) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 124 | { |
| 125 | const auto t0 = wrapper::vadd(x1, x2); |
| 126 | const auto t1 = wrapper::vadd(x3, x4); |
| 127 | const auto t2 = wrapper::vadd(x5, x6); |
| 128 | const auto t3 = wrapper::vadd(x7, x8); |
| 129 | const auto t00 = wrapper::vadd(t0, t1); |
| 130 | const auto t01 = wrapper::vadd(t2, t3); |
| 131 | |
| 132 | return wrapper::vadd(t00, t01); |
| 133 | } |
| 134 | |
| 135 | void fft_2(float32x2_t &x, float32x2_t &y, float32x2_t &w) |
| 136 | { |
| 137 | float32x2_t a = x; |
| 138 | float32x2_t b = c_mul_neon(w, y); |
| 139 | |
| 140 | x = wrapper::vadd(a, b); |
| 141 | y = wrapper::vsub(a, b); |
| 142 | } |
| 143 | |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 144 | void fft_3(float32x2_t &x, float32x2_t &y, float32x2_t &z, const float32x2_t &w, const float32x2_t &w2) |
| 145 | { |
| 146 | float32x2_t a = x; |
| 147 | float32x2_t b = c_mul_neon(w, y); |
| 148 | float32x2_t c = c_mul_neon(w2, z); |
| 149 | |
| 150 | x = wrapper::vadd(a, b); |
| 151 | x = wrapper::vadd(x, c); |
| 152 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 153 | const auto v1 = wrapper::vmul(float32x2_t{0.5f, 0.5}, wrapper::vadd(b, c)); |
| 154 | const auto v2 = c_mul_neon(float32x2_t{0.f, -kSqrt3Div2}, wrapper::vsub(b, c)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 155 | |
| 156 | y = z = wrapper::vsub(a, v1); |
| 157 | y = wrapper::vadd(y, v2); |
| 158 | z = wrapper::vsub(z, v2); |
| 159 | } |
| 160 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 161 | void fft_4(float32x2_t &x1, |
| 162 | float32x2_t &x2, |
| 163 | float32x2_t &x3, |
| 164 | float32x2_t &x4, |
| 165 | const float32x2_t &w, |
| 166 | const float32x2_t &w2, |
| 167 | const float32x2_t &w3) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 168 | { |
| 169 | float32x2_t a = x1; |
| 170 | float32x2_t b = c_mul_neon(w, x2); |
| 171 | float32x2_t c = c_mul_neon(w2, x3); |
| 172 | float32x2_t d = c_mul_neon(w3, x4); |
| 173 | |
| 174 | const auto x11 = wrapper::vadd(a, b); |
| 175 | const auto x12 = wrapper::vadd(c, d); |
| 176 | x1 = wrapper::vadd(x11, x12); |
| 177 | |
| 178 | const auto x21 = wrapper::vadd(a, c_mul_neon_img(b, -1)); |
| 179 | const auto x22 = wrapper::vadd(wrapper::vneg(c), c_mul_neon_img(d, 1.f)); |
| 180 | x2 = wrapper::vadd(x21, x22); |
| 181 | |
| 182 | const auto x31 = wrapper::vadd(a, wrapper::vneg(b)); |
| 183 | const auto x32 = wrapper::vadd(c, wrapper::vneg(d)); |
| 184 | x3 = wrapper::vadd(x31, x32); |
| 185 | |
| 186 | const auto x41 = wrapper::vadd(a, c_mul_neon_img(b, 1)); |
| 187 | const auto x42 = wrapper::vadd(wrapper::vneg(c), c_mul_neon_img(d, -1)); |
| 188 | x4 = wrapper::vadd(x41, x42); |
| 189 | } |
| 190 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 191 | void fft_5(float32x2_t &x1, |
| 192 | float32x2_t &x2, |
| 193 | float32x2_t &x3, |
| 194 | float32x2_t &x4, |
| 195 | float32x2_t &x5, |
| 196 | const float32x2_t &w, |
| 197 | const float32x2_t &w2, |
| 198 | const float32x2_t &w3, |
| 199 | const float32x2_t &w4) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 200 | { |
| 201 | const auto a = x1; |
| 202 | const auto b = c_mul_neon(w, x2); |
| 203 | const auto c = c_mul_neon(w2, x3); |
| 204 | const auto d = c_mul_neon(w3, x4); |
| 205 | const auto e = c_mul_neon(w4, x5); |
| 206 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 207 | const auto b0 = c_mul_neon(float32x2_t{kW5_0, -kW5_1}, b); |
| 208 | const auto b1 = c_mul_neon(float32x2_t{-kW5_2, -kW5_3}, b); |
| 209 | const auto b2 = c_mul_neon(float32x2_t{-kW5_2, kW5_3}, b); |
| 210 | const auto b3 = c_mul_neon(float32x2_t{kW5_0, kW5_1}, b); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 211 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 212 | const auto c0 = c_mul_neon(float32x2_t{-kW5_2, -kW5_3}, c); |
| 213 | const auto c1 = c_mul_neon(float32x2_t{kW5_0, kW5_1}, c); |
| 214 | const auto c2 = c_mul_neon(float32x2_t{kW5_0, -kW5_1}, c); |
| 215 | const auto c3 = c_mul_neon(float32x2_t{-kW5_2, kW5_3}, c); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 216 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 217 | const auto d0 = c_mul_neon(float32x2_t{-kW5_2, kW5_3}, d); |
| 218 | const auto d1 = c_mul_neon(float32x2_t{kW5_0, -kW5_1}, d); |
| 219 | const auto d2 = c_mul_neon(float32x2_t{kW5_0, kW5_1}, d); |
| 220 | const auto d3 = c_mul_neon(float32x2_t{-kW5_2, -kW5_3}, d); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 221 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 222 | const auto e0 = c_mul_neon(float32x2_t{kW5_0, kW5_1}, e); |
| 223 | const auto e1 = c_mul_neon(float32x2_t{-kW5_2, kW5_3}, e); |
| 224 | const auto e2 = c_mul_neon(float32x2_t{-kW5_2, -kW5_3}, e); |
| 225 | const auto e3 = c_mul_neon(float32x2_t{kW5_0, -kW5_1}, e); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 226 | |
| 227 | x1 = reduce_sum_5(a, b, c, d, e); |
| 228 | x2 = reduce_sum_5(a, b0, c0, d0, e0); |
| 229 | x3 = reduce_sum_5(a, b1, c1, d1, e1); |
| 230 | x4 = reduce_sum_5(a, b2, c2, d2, e2); |
| 231 | x5 = reduce_sum_5(a, b3, c3, d3, e3); |
| 232 | } |
| 233 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 234 | void fft_7(float32x2_t &x1, |
| 235 | float32x2_t &x2, |
| 236 | float32x2_t &x3, |
| 237 | float32x2_t &x4, |
| 238 | float32x2_t &x5, |
| 239 | float32x2_t &x6, |
| 240 | float32x2_t &x7, |
| 241 | const float32x2_t &w, |
| 242 | const float32x2_t &w2, |
| 243 | const float32x2_t &w3, |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 244 | const float32x2_t &w4, |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 245 | const float32x2_t &w5, |
| 246 | const float32x2_t &w6) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 247 | { |
| 248 | const auto a = x1; |
| 249 | const auto b = c_mul_neon(w, x2); |
| 250 | const auto c = c_mul_neon(w2, x3); |
| 251 | const auto d = c_mul_neon(w3, x4); |
| 252 | const auto e = c_mul_neon(w4, x5); |
| 253 | const auto f = c_mul_neon(w5, x6); |
| 254 | const auto g = c_mul_neon(w6, x7); |
| 255 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 256 | const auto b0 = c_mul_neon(float32x2_t{kW7_0, -kW7_1}, b); |
| 257 | const auto b1 = c_mul_neon(float32x2_t{-kW7_2, -kW7_3}, b); |
| 258 | const auto b2 = c_mul_neon(float32x2_t{-kW7_4, -kW7_5}, b); |
| 259 | const auto b3 = c_mul_neon(float32x2_t{-kW7_4, kW7_5}, b); |
| 260 | const auto b4 = c_mul_neon(float32x2_t{-kW7_2, kW7_3}, b); |
| 261 | const auto b5 = c_mul_neon(float32x2_t{kW7_0, kW7_1}, b); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 262 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 263 | const auto c0 = c_mul_neon(float32x2_t{-kW7_2, -kW7_3}, c); |
| 264 | const auto c1 = c_mul_neon(float32x2_t{-kW7_4, kW7_5}, c); |
| 265 | const auto c2 = c_mul_neon(float32x2_t{kW7_0, kW7_1}, c); |
| 266 | const auto c3 = c_mul_neon(float32x2_t{kW7_0, -kW7_1}, c); |
| 267 | const auto c4 = c_mul_neon(float32x2_t{-kW7_4, -kW7_5}, c); |
| 268 | const auto c5 = c_mul_neon(float32x2_t{-kW7_2, kW7_3}, c); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 269 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 270 | const auto d0 = c_mul_neon(float32x2_t{-kW7_4, -kW7_5}, d); |
| 271 | const auto d1 = c_mul_neon(float32x2_t{kW7_0, kW7_1}, d); |
| 272 | const auto d2 = c_mul_neon(float32x2_t{-kW7_2, -kW7_3}, d); |
| 273 | const auto d3 = c_mul_neon(float32x2_t{-kW7_2, +kW7_3}, d); |
| 274 | const auto d4 = c_mul_neon(float32x2_t{kW7_0, -kW7_1}, d); |
| 275 | const auto d5 = c_mul_neon(float32x2_t{-kW7_4, kW7_5}, d); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 276 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 277 | const auto e0 = c_mul_neon(float32x2_t{-kW7_4, kW7_5}, e); |
| 278 | const auto e1 = c_mul_neon(float32x2_t{kW7_0, -kW7_1}, e); |
| 279 | const auto e2 = c_mul_neon(float32x2_t{-kW7_2, kW7_3}, e); |
| 280 | const auto e3 = c_mul_neon(float32x2_t{-kW7_2, -kW7_3}, e); |
| 281 | const auto e4 = c_mul_neon(float32x2_t{kW7_0, kW7_1}, e); |
| 282 | const auto e5 = c_mul_neon(float32x2_t{-kW7_4, -kW7_5}, e); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 283 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 284 | const auto f0 = c_mul_neon(float32x2_t{-kW7_2, kW7_3}, f); |
| 285 | const auto f1 = c_mul_neon(float32x2_t{-kW7_4, -kW7_5}, f); |
| 286 | const auto f2 = c_mul_neon(float32x2_t{kW7_0, -kW7_1}, f); |
| 287 | const auto f3 = c_mul_neon(float32x2_t{kW7_0, kW7_1}, f); |
| 288 | const auto f4 = c_mul_neon(float32x2_t{-kW7_4, kW7_5}, f); |
| 289 | const auto f5 = c_mul_neon(float32x2_t{-kW7_2, -kW7_3}, f); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 290 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 291 | const auto g0 = c_mul_neon(float32x2_t{kW7_0, kW7_1}, g); |
| 292 | const auto g1 = c_mul_neon(float32x2_t{-kW7_2, kW7_3}, g); |
| 293 | const auto g2 = c_mul_neon(float32x2_t{-kW7_4, kW7_5}, g); |
| 294 | const auto g3 = c_mul_neon(float32x2_t{-kW7_4, -kW7_5}, g); |
| 295 | const auto g4 = c_mul_neon(float32x2_t{-kW7_2, -kW7_3}, g); |
| 296 | const auto g5 = c_mul_neon(float32x2_t{kW7_0, -kW7_1}, g); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 297 | |
| 298 | x1 = reduce_sum_7(a, b, c, d, e, f, g); |
| 299 | x2 = reduce_sum_7(a, b0, c0, d0, e0, f0, g0); |
| 300 | x3 = reduce_sum_7(a, b1, c1, d1, e1, f1, g1); |
| 301 | x4 = reduce_sum_7(a, b2, c2, d2, e2, f2, g2); |
| 302 | x5 = reduce_sum_7(a, b3, c3, d3, e3, f3, g3); |
| 303 | x6 = reduce_sum_7(a, b4, c4, d4, e4, f4, g4); |
| 304 | x7 = reduce_sum_7(a, b5, c5, d5, e5, f5, g5); |
| 305 | } |
| 306 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 307 | void fft_8(float32x2_t &x1, |
| 308 | float32x2_t &x2, |
| 309 | float32x2_t &x3, |
| 310 | float32x2_t &x4, |
| 311 | float32x2_t &x5, |
| 312 | float32x2_t &x6, |
| 313 | float32x2_t &x7, |
| 314 | float32x2_t &x8, |
| 315 | const float32x2_t &w, |
| 316 | const float32x2_t &w2, |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 317 | const float32x2_t &w3, |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 318 | const float32x2_t &w4, |
| 319 | const float32x2_t &w5, |
| 320 | const float32x2_t &w6, |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 321 | const float32x2_t &w7) |
| 322 | { |
| 323 | const auto a = x1; |
| 324 | const auto b = c_mul_neon(w, x2); |
| 325 | const auto c = c_mul_neon(w2, x3); |
| 326 | const auto d = c_mul_neon(w3, x4); |
| 327 | const auto e = c_mul_neon(w4, x5); |
| 328 | const auto f = c_mul_neon(w5, x6); |
| 329 | const auto g = c_mul_neon(w6, x7); |
| 330 | const auto h = c_mul_neon(w7, x8); |
| 331 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 332 | const auto b0 = c_mul_neon(float32x2_t{kSqrt2Div2, -kSqrt2Div2}, b); |
| 333 | const auto b1 = c_mul_neon(float32x2_t{0, -1}, b); |
| 334 | const auto b2 = c_mul_neon(float32x2_t{-kSqrt2Div2, -kSqrt2Div2}, b); |
| 335 | const auto b3 = c_mul_neon(float32x2_t{-1, 0}, b); |
| 336 | const auto b4 = c_mul_neon(float32x2_t{-kSqrt2Div2, kSqrt2Div2}, b); |
| 337 | const auto b5 = c_mul_neon(float32x2_t{0, 1}, b); |
| 338 | const auto b6 = c_mul_neon(float32x2_t{kSqrt2Div2, kSqrt2Div2}, b); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 339 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 340 | const auto c0 = c_mul_neon(float32x2_t{0, -1}, c); |
| 341 | const auto c1 = c_mul_neon(float32x2_t{-1, 0}, c); |
| 342 | const auto c2 = c_mul_neon(float32x2_t{0, 1}, c); |
| 343 | const auto c3 = c_mul_neon(float32x2_t{1, 0}, c); |
| 344 | const auto c4 = c_mul_neon(float32x2_t{0, -1}, c); |
| 345 | const auto c5 = c_mul_neon(float32x2_t{-1, 0}, c); |
| 346 | const auto c6 = c_mul_neon(float32x2_t{0, 1}, c); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 347 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 348 | const auto d0 = c_mul_neon(float32x2_t{-kSqrt2Div2, -kSqrt2Div2}, d); |
| 349 | const auto d1 = c_mul_neon(float32x2_t{0, 1}, d); |
| 350 | const auto d2 = c_mul_neon(float32x2_t{kSqrt2Div2, -kSqrt2Div2}, d); |
| 351 | const auto d3 = c_mul_neon(float32x2_t{-1, 0}, d); |
| 352 | const auto d4 = c_mul_neon(float32x2_t{kSqrt2Div2, kSqrt2Div2}, d); |
| 353 | const auto d5 = c_mul_neon(float32x2_t{0, -1}, d); |
| 354 | const auto d6 = c_mul_neon(float32x2_t{-kSqrt2Div2, kSqrt2Div2}, d); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 355 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 356 | const auto e0 = c_mul_neon(float32x2_t{-1, 0}, e); |
| 357 | const auto e1 = c_mul_neon(float32x2_t{1, 0}, e); |
| 358 | const auto e2 = c_mul_neon(float32x2_t{-1, 0}, e); |
| 359 | const auto e3 = c_mul_neon(float32x2_t{1, 0}, e); |
| 360 | const auto e4 = c_mul_neon(float32x2_t{-1, 0}, e); |
| 361 | const auto e5 = c_mul_neon(float32x2_t{1, 0}, e); |
| 362 | const auto e6 = c_mul_neon(float32x2_t{-1, 0}, e); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 363 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 364 | const auto f0 = c_mul_neon(float32x2_t{-kSqrt2Div2, kSqrt2Div2}, f); |
| 365 | const auto f1 = c_mul_neon(float32x2_t{0, -1}, f); |
| 366 | const auto f2 = c_mul_neon(float32x2_t{kSqrt2Div2, kSqrt2Div2}, f); |
| 367 | const auto f3 = c_mul_neon(float32x2_t{-1, 0}, f); |
| 368 | const auto f4 = c_mul_neon(float32x2_t{kSqrt2Div2, -kSqrt2Div2}, f); |
| 369 | const auto f5 = c_mul_neon(float32x2_t{0, 1}, f); |
| 370 | const auto f6 = c_mul_neon(float32x2_t{-kSqrt2Div2, -kSqrt2Div2}, f); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 371 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 372 | const auto g0 = c_mul_neon(float32x2_t{0, 1}, g); |
| 373 | const auto g1 = c_mul_neon(float32x2_t{-1, 0}, g); |
| 374 | const auto g2 = c_mul_neon(float32x2_t{0, -1}, g); |
| 375 | const auto g3 = c_mul_neon(float32x2_t{1, 0}, g); |
| 376 | const auto g4 = c_mul_neon(float32x2_t{0, 1}, g); |
| 377 | const auto g5 = c_mul_neon(float32x2_t{-1, 0}, g); |
| 378 | const auto g6 = c_mul_neon(float32x2_t{0, -1}, g); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 379 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 380 | const auto h0 = c_mul_neon(float32x2_t{kSqrt2Div2, kSqrt2Div2}, h); |
| 381 | const auto h1 = c_mul_neon(float32x2_t{0, 1}, h); |
| 382 | const auto h2 = c_mul_neon(float32x2_t{-kSqrt2Div2, kSqrt2Div2}, h); |
| 383 | const auto h3 = c_mul_neon(float32x2_t{-1, 0}, h); |
| 384 | const auto h4 = c_mul_neon(float32x2_t{-kSqrt2Div2, -kSqrt2Div2}, h); |
| 385 | const auto h5 = c_mul_neon(float32x2_t{0, -1}, h); |
| 386 | const auto h6 = c_mul_neon(float32x2_t{kSqrt2Div2, -kSqrt2Div2}, h); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 387 | |
| 388 | x1 = reduce_sum_8(a, b, c, d, e, f, g, h); |
| 389 | x2 = reduce_sum_8(a, b0, c0, d0, e0, f0, g0, h0); |
| 390 | x3 = reduce_sum_8(a, b1, c1, d1, e1, f1, g1, h1); |
| 391 | x4 = reduce_sum_8(a, b2, c2, d2, e2, f2, g2, h2); |
| 392 | x5 = reduce_sum_8(a, b3, c3, d3, e3, f3, g3, h3); |
| 393 | x6 = reduce_sum_8(a, b4, c4, d4, e4, f4, g4, h4); |
| 394 | x7 = reduce_sum_8(a, b5, c5, d5, e5, f5, g5, h5); |
| 395 | x8 = reduce_sum_8(a, b6, c6, d6, e6, f6, g6, h6); |
| 396 | } |
| 397 | |
| 398 | template <bool first_stage> |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 399 | void fft_radix_2_axes_0( |
| 400 | float *out, float *in, unsigned int Nx, unsigned int NxRadix, const float32x2_t &w_m, unsigned int N) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 401 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 402 | float32x2_t w{1.0f, 0.0f}; |
| 403 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 404 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 405 | for (unsigned int k = 2 * j; k < 2 * N; k += 2 * NxRadix) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 406 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 407 | auto a = float32x2_t{0, 0}; |
| 408 | auto b = float32x2_t{0, 0}; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 409 | |
| 410 | // Load inputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 411 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 412 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 413 | const auto ab = wrapper::vloadq(in + k); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 414 | a = wrapper::vgetlow(ab); |
| 415 | b = wrapper::vgethigh(ab); |
| 416 | } |
| 417 | else |
| 418 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 419 | a = wrapper::vload(in + k); |
| 420 | b = wrapper::vload(in + k + 2 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | // Base-case prime transform |
| 424 | fft_2(a, b, w); |
| 425 | |
| 426 | // Write outputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 427 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 428 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 429 | wrapper::vstore(out + k, wrapper::vcombine(a, b)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 430 | } |
| 431 | else |
| 432 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 433 | wrapper::vstore(out + k, a); |
| 434 | wrapper::vstore(out + k + 2 * Nx, b); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | |
| 438 | w = c_mul_neon(w, w_m); |
| 439 | } |
| 440 | } |
| 441 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 442 | void fft_radix_2_axes_1(float *out, |
| 443 | float *in, |
| 444 | unsigned int Nx, |
| 445 | unsigned int NxRadix, |
| 446 | const float32x2_t &w_m, |
| 447 | unsigned int N, |
| 448 | unsigned int M, |
| 449 | unsigned int in_pad_x, |
| 450 | unsigned int out_pad_x) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 451 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 452 | float32x2_t w{1.0f, 0.0f}; |
| 453 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 454 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 455 | for (unsigned int k = 2 * j; k < 2 * M; k += 2 * NxRadix) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 456 | { |
| 457 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 458 | float32x2_t a = wrapper::vload(in + (N + in_pad_x) * k); |
| 459 | float32x2_t b = wrapper::vload(in + (N + in_pad_x) * (k + 2 * Nx)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 460 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 461 | // Base-case prime transform |
| 462 | fft_2(a, b, w); |
| 463 | |
| 464 | // Write outputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 465 | wrapper::vstore(out + (N + out_pad_x) * k, a); |
| 466 | wrapper::vstore(out + (N + out_pad_x) * (k + 2 * Nx), b); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | w = c_mul_neon(w, w_m); |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | template <bool first_stage> |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 474 | void fft_radix_3_axes_0( |
| 475 | float *out, float *in, unsigned int Nx, unsigned int NxRadix, const float32x2_t &w_m, unsigned int N) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 476 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 477 | float32x2_t w{1.0f, 0.0f}; |
| 478 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 479 | { |
| 480 | const auto w2 = c_mul_neon(w, w); |
| 481 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 482 | for (unsigned int k = 2 * j; k < 2 * N; k += 2 * NxRadix) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 483 | { |
| 484 | // Load inputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 485 | float32x2_t a = {0, 0}; |
| 486 | float32x2_t b = {0, 0}; |
| 487 | float32x2_t c = {0, 0}; |
| 488 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 489 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 490 | const auto ab = wrapper::vloadq(in + k); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 491 | a = wrapper::vgetlow(ab); |
| 492 | b = wrapper::vgethigh(ab); |
| 493 | } |
| 494 | else |
| 495 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 496 | a = wrapper::vload(in + k); |
| 497 | b = wrapper::vload(in + k + 2 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 498 | } |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 499 | c = wrapper::vload(in + k + 4 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 500 | |
| 501 | // Base-case prime transform |
| 502 | fft_3(a, b, c, w, w2); |
| 503 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 504 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 505 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 506 | wrapper::vstore(out + k, wrapper::vcombine(a, b)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 507 | } |
| 508 | else |
| 509 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 510 | wrapper::vstore(out + k, a); |
| 511 | wrapper::vstore(out + k + 2 * Nx, b); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 512 | } |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 513 | wrapper::vstore(out + k + 4 * Nx, c); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 514 | } |
| 515 | w = c_mul_neon(w, w_m); |
| 516 | } |
| 517 | } |
| 518 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 519 | void fft_radix_3_axes_1(float *out, |
| 520 | float *in, |
| 521 | unsigned int Nx, |
| 522 | unsigned int NxRadix, |
| 523 | const float32x2_t &w_m, |
| 524 | unsigned int N, |
| 525 | unsigned int M, |
| 526 | unsigned int in_pad_x, |
| 527 | unsigned int out_pad_x) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 528 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 529 | float32x2_t w{1.0f, 0.0f}; |
| 530 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 531 | { |
| 532 | const auto w2 = c_mul_neon(w, w); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 533 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 534 | for (unsigned int k = 2 * j; k < 2 * M; k += 2 * NxRadix) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 535 | { |
| 536 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 537 | float32x2_t a = wrapper::vload(in + (N + in_pad_x) * k); |
| 538 | float32x2_t b = wrapper::vload(in + (N + in_pad_x) * (k + 2 * Nx)); |
| 539 | float32x2_t c = wrapper::vload(in + (N + in_pad_x) * (k + 4 * Nx)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 540 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 541 | // Base-case prime transform |
| 542 | fft_3(a, b, c, w, w2); |
| 543 | |
| 544 | // Store the output |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 545 | wrapper::vstore(out + (N + out_pad_x) * k, a); |
| 546 | wrapper::vstore(out + (N + out_pad_x) * (k + 2 * Nx), b); |
| 547 | wrapper::vstore(out + (N + out_pad_x) * (k + 4 * Nx), c); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 548 | } |
| 549 | w = c_mul_neon(w, w_m); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | template <bool first_stage> |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 554 | void fft_radix_4_axes_0( |
| 555 | float *out, float *in, unsigned int Nx, unsigned int NxRadix, const float32x2_t &w_m, unsigned int N) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 556 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 557 | float32x2_t w{1.0f, 0.0f}; |
| 558 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 559 | { |
| 560 | const auto w2 = c_mul_neon(w, w); |
| 561 | const auto w3 = c_mul_neon(w2, w); |
| 562 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 563 | for (unsigned int k = 2 * j; k < 2 * N; k += 2 * NxRadix) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 564 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 565 | float32x2_t a = {0, 0}; |
| 566 | float32x2_t b = {0, 0}; |
| 567 | float32x2_t c = {0, 0}; |
| 568 | float32x2_t d = {0, 0}; |
| 569 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 570 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 571 | const auto ab = wrapper::vloadq(in + k); |
| 572 | const auto cd = wrapper::vloadq(in + k + 4 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 573 | a = wrapper::vgetlow(ab); |
| 574 | b = wrapper::vgethigh(ab); |
| 575 | c = wrapper::vgetlow(cd); |
| 576 | d = wrapper::vgethigh(cd); |
| 577 | } |
| 578 | else |
| 579 | { |
| 580 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 581 | a = wrapper::vload(in + k); |
| 582 | b = wrapper::vload(in + k + 2 * Nx); |
| 583 | c = wrapper::vload(in + k + 4 * Nx); |
| 584 | d = wrapper::vload(in + k + 6 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | // Base-case prime transform |
| 588 | fft_4(a, b, c, d, w, w2, w3); |
| 589 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 590 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 591 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 592 | wrapper::vstore(out + k, wrapper::vcombine(a, b)); |
| 593 | wrapper::vstore(out + k + 4 * Nx, wrapper::vcombine(c, d)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 594 | } |
| 595 | else |
| 596 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 597 | wrapper::vstore(out + k, a); |
| 598 | wrapper::vstore(out + k + 2 * Nx, b); |
| 599 | wrapper::vstore(out + k + 4 * Nx, c); |
| 600 | wrapper::vstore(out + k + 6 * Nx, d); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 601 | } |
| 602 | } |
| 603 | |
| 604 | w = c_mul_neon(w, w_m); |
| 605 | } |
| 606 | } |
| 607 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 608 | void fft_radix_4_axes_1(float *out, |
| 609 | float *in, |
| 610 | unsigned int Nx, |
| 611 | unsigned int NxRadix, |
| 612 | const float32x2_t &w_m, |
| 613 | unsigned int N, |
| 614 | unsigned int M, |
| 615 | unsigned int in_pad_x, |
| 616 | unsigned int out_pad_x) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 617 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 618 | float32x2_t w{1.0f, 0.0f}; |
| 619 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 620 | { |
| 621 | const auto w2 = c_mul_neon(w, w); |
| 622 | const auto w3 = c_mul_neon(w2, w); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 623 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 624 | for (unsigned int k = 2 * j; k < 2 * M; k += 2 * NxRadix) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 625 | { |
| 626 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 627 | float32x2_t a = wrapper::vload(in + (N + in_pad_x) * k); |
| 628 | float32x2_t b = wrapper::vload(in + (N + in_pad_x) * (k + 2 * Nx)); |
| 629 | float32x2_t c = wrapper::vload(in + (N + in_pad_x) * (k + 4 * Nx)); |
| 630 | float32x2_t d = wrapper::vload(in + (N + in_pad_x) * (k + 6 * Nx)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 631 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 632 | // Base-case prime transform |
| 633 | fft_4(a, b, c, d, w, w2, w3); |
| 634 | |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 635 | wrapper::vstore(out + (N + out_pad_x) * k, a); |
| 636 | wrapper::vstore(out + (N + out_pad_x) * (k + 2 * Nx), b); |
| 637 | wrapper::vstore(out + (N + out_pad_x) * (k + 4 * Nx), c); |
| 638 | wrapper::vstore(out + (N + out_pad_x) * (k + 6 * Nx), d); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | w = c_mul_neon(w, w_m); |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | template <bool first_stage> |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 646 | void fft_radix_5_axes_0( |
| 647 | float *out, float *in, unsigned int Nx, unsigned int NxRadix, const float32x2_t &w_m, unsigned int N) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 648 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 649 | float32x2_t w{1.0f, 0.0f}; |
| 650 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 651 | { |
| 652 | const float32x2_t w2 = c_mul_neon(w, w); |
| 653 | const float32x2_t w3 = c_mul_neon(w2, w); |
| 654 | const float32x2_t w4 = c_mul_neon(w3, w); |
| 655 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 656 | for (unsigned int k = 2 * j; k < 2 * N; k += 2 * NxRadix) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 657 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 658 | float32x2_t a = {0, 0}; |
| 659 | float32x2_t b = {0, 0}; |
| 660 | float32x2_t c = {0, 0}; |
| 661 | float32x2_t d = {0, 0}; |
| 662 | float32x2_t e = {0, 0}; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 663 | |
| 664 | // Load inputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 665 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 666 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 667 | const auto ab = wrapper::vloadq(in + k); |
| 668 | const auto cd = wrapper::vloadq(in + k + 4 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 669 | |
| 670 | a = wrapper::vgetlow(ab); |
| 671 | b = wrapper::vgethigh(ab); |
| 672 | c = wrapper::vgetlow(cd); |
| 673 | d = wrapper::vgethigh(cd); |
| 674 | } |
| 675 | else |
| 676 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 677 | a = wrapper::vload(in + k); |
| 678 | b = wrapper::vload(in + k + 2 * Nx); |
| 679 | c = wrapper::vload(in + k + 4 * Nx); |
| 680 | d = wrapper::vload(in + k + 6 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 681 | } |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 682 | e = wrapper::vload(in + k + 8 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 683 | |
| 684 | // Base-case prime transform |
| 685 | fft_5(a, b, c, d, e, w, w2, w3, w4); |
| 686 | |
| 687 | // Store outputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 688 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 689 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 690 | wrapper::vstore(out + k, wrapper::vcombine(a, b)); |
| 691 | wrapper::vstore(out + k + 4 * Nx, wrapper::vcombine(c, d)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 692 | } |
| 693 | else |
| 694 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 695 | wrapper::vstore(out + k, a); |
| 696 | wrapper::vstore(out + k + 2 * Nx, b); |
| 697 | wrapper::vstore(out + k + 4 * Nx, c); |
| 698 | wrapper::vstore(out + k + 6 * Nx, d); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 699 | } |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 700 | wrapper::vstore(out + k + 8 * Nx, e); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | w = c_mul_neon(w, w_m); |
| 704 | } |
| 705 | } |
| 706 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 707 | void fft_radix_5_axes_1(float *out, |
| 708 | float *in, |
| 709 | unsigned int Nx, |
| 710 | unsigned int NxRadix, |
| 711 | const float32x2_t &w_m, |
| 712 | unsigned int N, |
| 713 | unsigned int M, |
| 714 | unsigned int in_pad_x, |
| 715 | unsigned int out_pad_x) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 716 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 717 | float32x2_t w{1.0f, 0.0f}; |
| 718 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 719 | { |
| 720 | const float32x2_t w2 = c_mul_neon(w, w); |
| 721 | const float32x2_t w3 = c_mul_neon(w2, w); |
| 722 | const float32x2_t w4 = c_mul_neon(w3, w); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 723 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 724 | for (unsigned int k = 2 * j; k < 2 * M; k += 2 * NxRadix) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 725 | { |
| 726 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 727 | float32x2_t a = wrapper::vload(in + (N + in_pad_x) * k); |
| 728 | float32x2_t b = wrapper::vload(in + (N + in_pad_x) * (k + 2 * Nx)); |
| 729 | float32x2_t c = wrapper::vload(in + (N + in_pad_x) * (k + 4 * Nx)); |
| 730 | float32x2_t d = wrapper::vload(in + (N + in_pad_x) * (k + 6 * Nx)); |
| 731 | float32x2_t e = wrapper::vload(in + (N + in_pad_x) * (k + 8 * Nx)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 732 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 733 | // Base-case prime transform |
| 734 | fft_5(a, b, c, d, e, w, w2, w3, w4); |
| 735 | |
| 736 | // Store outputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 737 | wrapper::vstore(out + (N + out_pad_x) * k, a); |
| 738 | wrapper::vstore(out + (N + out_pad_x) * (k + 2 * Nx), b); |
| 739 | wrapper::vstore(out + (N + out_pad_x) * (k + 4 * Nx), c); |
| 740 | wrapper::vstore(out + (N + out_pad_x) * (k + 6 * Nx), d); |
| 741 | wrapper::vstore(out + (N + out_pad_x) * (k + 8 * Nx), e); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | w = c_mul_neon(w, w_m); |
| 745 | } |
| 746 | } |
| 747 | |
| 748 | template <bool first_stage> |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 749 | void fft_radix_7_axes_0( |
| 750 | float *out, float *in, unsigned int Nx, unsigned int NxRadix, const float32x2_t &w_m, unsigned int N) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 751 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 752 | float32x2_t w{1.0f, 0.0f}; |
| 753 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 754 | { |
| 755 | const float32x2_t w2 = c_mul_neon(w, w); |
| 756 | const float32x2_t w3 = c_mul_neon(w2, w); |
| 757 | const float32x2_t w4 = c_mul_neon(w3, w); |
| 758 | const float32x2_t w5 = c_mul_neon(w4, w); |
| 759 | const float32x2_t w6 = c_mul_neon(w5, w); |
| 760 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 761 | for (unsigned int k = 2 * j; k < 2 * N; k += 2 * NxRadix) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 762 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 763 | float32x2_t a = {0, 0}; |
| 764 | float32x2_t b = {0, 0}; |
| 765 | float32x2_t c = {0, 0}; |
| 766 | float32x2_t d = {0, 0}; |
| 767 | float32x2_t e = {0, 0}; |
| 768 | float32x2_t f = {0, 0}; |
| 769 | float32x2_t g = {0, 0}; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 770 | |
| 771 | // Load inputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 772 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 773 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 774 | const auto ab = wrapper::vloadq(in + k); |
| 775 | const auto cd = wrapper::vloadq(in + k + 4 * Nx); |
| 776 | const auto ef = wrapper::vloadq(in + k + 8 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 777 | |
| 778 | a = wrapper::vgetlow(ab); |
| 779 | b = wrapper::vgethigh(ab); |
| 780 | c = wrapper::vgetlow(cd); |
| 781 | d = wrapper::vgethigh(cd); |
| 782 | e = wrapper::vgetlow(ef); |
| 783 | f = wrapper::vgethigh(ef); |
| 784 | } |
| 785 | else |
| 786 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 787 | a = wrapper::vload(in + k); |
| 788 | b = wrapper::vload(in + k + 2 * Nx); |
| 789 | c = wrapper::vload(in + k + 4 * Nx); |
| 790 | d = wrapper::vload(in + k + 6 * Nx); |
| 791 | e = wrapper::vload(in + k + 8 * Nx); |
| 792 | f = wrapper::vload(in + k + 10 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 793 | } |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 794 | g = wrapper::vload(in + k + 12 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 795 | |
| 796 | // Base-case prime transform |
| 797 | fft_7(a, b, c, d, e, f, g, w, w2, w3, w4, w5, w6); |
| 798 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 799 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 800 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 801 | wrapper::vstore(out + k, wrapper::vcombine(a, b)); |
| 802 | wrapper::vstore(out + k + 4 * Nx, wrapper::vcombine(c, d)); |
| 803 | wrapper::vstore(out + k + 8 * Nx, wrapper::vcombine(e, f)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 804 | } |
| 805 | else |
| 806 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 807 | wrapper::vstore(out + k, a); |
| 808 | wrapper::vstore(out + k + 2 * Nx, b); |
| 809 | wrapper::vstore(out + k + 4 * Nx, c); |
| 810 | wrapper::vstore(out + k + 6 * Nx, d); |
| 811 | wrapper::vstore(out + k + 8 * Nx, e); |
| 812 | wrapper::vstore(out + k + 10 * Nx, f); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 813 | } |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 814 | wrapper::vstore(out + k + 12 * Nx, g); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | w = c_mul_neon(w, w_m); |
| 818 | } |
| 819 | } |
| 820 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 821 | void fft_radix_7_axes_1(float *out, |
| 822 | float *in, |
| 823 | unsigned int Nx, |
| 824 | unsigned int NxRadix, |
| 825 | const float32x2_t &w_m, |
| 826 | unsigned int N, |
| 827 | unsigned int M, |
| 828 | unsigned int in_pad_x, |
| 829 | unsigned int out_pad_x) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 830 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 831 | float32x2_t w{1.0f, 0.0f}; |
| 832 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 833 | { |
| 834 | const float32x2_t w2 = c_mul_neon(w, w); |
| 835 | const float32x2_t w3 = c_mul_neon(w2, w); |
| 836 | const float32x2_t w4 = c_mul_neon(w3, w); |
| 837 | const float32x2_t w5 = c_mul_neon(w4, w); |
| 838 | const float32x2_t w6 = c_mul_neon(w5, w); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 839 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 840 | for (unsigned int k = 2 * j; k < 2 * M; k += 2 * NxRadix) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 841 | { |
| 842 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 843 | float32x2_t a = wrapper::vload(in + (N + in_pad_x) * k); |
| 844 | float32x2_t b = wrapper::vload(in + (N + in_pad_x) * (k + 2 * Nx)); |
| 845 | float32x2_t c = wrapper::vload(in + (N + in_pad_x) * (k + 4 * Nx)); |
| 846 | float32x2_t d = wrapper::vload(in + (N + in_pad_x) * (k + 6 * Nx)); |
| 847 | float32x2_t e = wrapper::vload(in + (N + in_pad_x) * (k + 8 * Nx)); |
| 848 | float32x2_t f = wrapper::vload(in + (N + in_pad_x) * (k + 10 * Nx)); |
| 849 | float32x2_t g = wrapper::vload(in + (N + in_pad_x) * (k + 12 * Nx)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 850 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 851 | // Base-case prime transform |
| 852 | fft_7(a, b, c, d, e, f, g, w, w2, w3, w4, w5, w6); |
| 853 | |
| 854 | // Store outputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 855 | wrapper::vstore(out + (N + out_pad_x) * k, a); |
| 856 | wrapper::vstore(out + (N + out_pad_x) * (k + 2 * Nx), b); |
| 857 | wrapper::vstore(out + (N + out_pad_x) * (k + 4 * Nx), c); |
| 858 | wrapper::vstore(out + (N + out_pad_x) * (k + 6 * Nx), d); |
| 859 | wrapper::vstore(out + (N + out_pad_x) * (k + 8 * Nx), e); |
| 860 | wrapper::vstore(out + (N + out_pad_x) * (k + 10 * Nx), f); |
| 861 | wrapper::vstore(out + (N + out_pad_x) * (k + 12 * Nx), g); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 862 | } |
| 863 | |
| 864 | w = c_mul_neon(w, w_m); |
| 865 | } |
| 866 | } |
| 867 | |
| 868 | template <bool first_stage> |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 869 | void fft_radix_8_axes_0( |
| 870 | float *out, float *in, unsigned int Nx, unsigned int NxRadix, const float32x2_t &w_m, unsigned int N) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 871 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 872 | float32x2_t w{1.0f, 0.0f}; |
| 873 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 874 | { |
| 875 | const float32x2_t w2 = c_mul_neon(w, w); |
| 876 | const float32x2_t w3 = c_mul_neon(w2, w); |
| 877 | const float32x2_t w4 = c_mul_neon(w3, w); |
| 878 | const float32x2_t w5 = c_mul_neon(w4, w); |
| 879 | const float32x2_t w6 = c_mul_neon(w5, w); |
| 880 | const float32x2_t w7 = c_mul_neon(w6, w); |
| 881 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 882 | for (unsigned int k = 2 * j; k < 2 * N; k += 2 * NxRadix) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 883 | { |
| 884 | // Load inputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 885 | float32x2_t a = {0, 0}; |
| 886 | float32x2_t b = {0, 0}; |
| 887 | float32x2_t c = {0, 0}; |
| 888 | float32x2_t d = {0, 0}; |
| 889 | float32x2_t e = {0, 0}; |
| 890 | float32x2_t f = {0, 0}; |
| 891 | float32x2_t g = {0, 0}; |
| 892 | float32x2_t h = {0, 0}; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 893 | |
| 894 | // Base-case prime transform |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 895 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 896 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 897 | const auto ab = wrapper::vloadq(in + k); |
| 898 | const auto cd = wrapper::vloadq(in + k + 4 * Nx); |
| 899 | const auto ef = wrapper::vloadq(in + k + 8 * Nx); |
| 900 | const auto gh = wrapper::vloadq(in + k + 12 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 901 | |
| 902 | a = wrapper::vgetlow(ab); |
| 903 | b = wrapper::vgethigh(ab); |
| 904 | c = wrapper::vgetlow(cd); |
| 905 | d = wrapper::vgethigh(cd); |
| 906 | e = wrapper::vgetlow(ef); |
| 907 | f = wrapper::vgethigh(ef); |
| 908 | g = wrapper::vgetlow(gh); |
| 909 | h = wrapper::vgethigh(gh); |
| 910 | } |
| 911 | else |
| 912 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 913 | a = wrapper::vload(in + k); |
| 914 | b = wrapper::vload(in + k + 2 * Nx); |
| 915 | c = wrapper::vload(in + k + 4 * Nx); |
| 916 | d = wrapper::vload(in + k + 6 * Nx); |
| 917 | e = wrapper::vload(in + k + 8 * Nx); |
| 918 | f = wrapper::vload(in + k + 10 * Nx); |
| 919 | g = wrapper::vload(in + k + 12 * Nx); |
| 920 | h = wrapper::vload(in + k + 14 * Nx); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 921 | } |
| 922 | |
| 923 | // Apply twiddle factors |
| 924 | fft_8(a, b, c, d, e, f, g, h, w, w2, w3, w4, w5, w6, w7); |
| 925 | |
| 926 | // Store outputs |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 927 | if (first_stage) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 928 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 929 | wrapper::vstore(out + k, wrapper::vcombine(a, b)); |
| 930 | wrapper::vstore(out + k + 4 * Nx, wrapper::vcombine(c, d)); |
| 931 | wrapper::vstore(out + k + 8 * Nx, wrapper::vcombine(e, f)); |
| 932 | wrapper::vstore(out + k + 12 * Nx, wrapper::vcombine(g, h)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 933 | } |
| 934 | else |
| 935 | { |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 936 | wrapper::vstore(out + k, a); |
| 937 | wrapper::vstore(out + k + 2 * Nx, b); |
| 938 | wrapper::vstore(out + k + 4 * Nx, c); |
| 939 | wrapper::vstore(out + k + 6 * Nx, d); |
| 940 | wrapper::vstore(out + k + 8 * Nx, e); |
| 941 | wrapper::vstore(out + k + 10 * Nx, f); |
| 942 | wrapper::vstore(out + k + 12 * Nx, g); |
| 943 | wrapper::vstore(out + k + 14 * Nx, h); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 944 | } |
| 945 | } |
| 946 | |
| 947 | w = c_mul_neon(w, w_m); |
| 948 | } |
| 949 | } |
| 950 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 951 | void fft_radix_8_axes_1(float *out, |
| 952 | float *in, |
| 953 | unsigned int Nx, |
| 954 | unsigned int NxRadix, |
| 955 | const float32x2_t &w_m, |
| 956 | unsigned int N, |
| 957 | unsigned int M, |
| 958 | unsigned int in_pad_x, |
| 959 | unsigned int out_pad_x) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 960 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 961 | float32x2_t w{1.0f, 0.0f}; |
| 962 | for (unsigned int j = 0; j < Nx; j++) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 963 | { |
| 964 | const float32x2_t w2 = c_mul_neon(w, w); |
| 965 | const float32x2_t w3 = c_mul_neon(w2, w); |
| 966 | const float32x2_t w4 = c_mul_neon(w3, w); |
| 967 | const float32x2_t w5 = c_mul_neon(w4, w); |
| 968 | const float32x2_t w6 = c_mul_neon(w5, w); |
| 969 | const float32x2_t w7 = c_mul_neon(w6, w); |
| 970 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 971 | for (unsigned int k = 2 * j; k < 2 * M; k += 2 * NxRadix) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 972 | { |
| 973 | // Load inputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 974 | float32x2_t a = wrapper::vload(in + (N + in_pad_x) * k); |
| 975 | float32x2_t b = wrapper::vload(in + (N + in_pad_x) * (k + 2 * Nx)); |
| 976 | float32x2_t c = wrapper::vload(in + (N + in_pad_x) * (k + 4 * Nx)); |
| 977 | float32x2_t d = wrapper::vload(in + (N + in_pad_x) * (k + 6 * Nx)); |
| 978 | float32x2_t e = wrapper::vload(in + (N + in_pad_x) * (k + 8 * Nx)); |
| 979 | float32x2_t f = wrapper::vload(in + (N + in_pad_x) * (k + 10 * Nx)); |
| 980 | float32x2_t g = wrapper::vload(in + (N + in_pad_x) * (k + 12 * Nx)); |
| 981 | float32x2_t h = wrapper::vload(in + (N + in_pad_x) * (k + 14 * Nx)); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 982 | |
| 983 | // Base-case prime transform |
| 984 | fft_8(a, b, c, d, e, f, g, h, w, w2, w3, w4, w5, w6, w7); |
| 985 | |
| 986 | // Store outputs |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 987 | wrapper::vstore(out + (N + out_pad_x) * k, a); |
| 988 | wrapper::vstore(out + (N + out_pad_x) * (k + 2 * Nx), b); |
| 989 | wrapper::vstore(out + (N + out_pad_x) * (k + 4 * Nx), c); |
| 990 | wrapper::vstore(out + (N + out_pad_x) * (k + 6 * Nx), d); |
| 991 | wrapper::vstore(out + (N + out_pad_x) * (k + 8 * Nx), e); |
| 992 | wrapper::vstore(out + (N + out_pad_x) * (k + 10 * Nx), f); |
| 993 | wrapper::vstore(out + (N + out_pad_x) * (k + 12 * Nx), g); |
| 994 | wrapper::vstore(out + (N + out_pad_x) * (k + 14 * Nx), h); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 995 | } |
| 996 | |
| 997 | w = c_mul_neon(w, w_m); |
| 998 | } |
| 999 | } |
| 1000 | |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1001 | Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const FFTRadixStageKernelInfo &config) |
| 1002 | { |
| 1003 | ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 2, DataType::F32); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1004 | ARM_COMPUTE_RETURN_ERROR_ON(config.axis > 1); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1005 | ARM_COMPUTE_RETURN_ERROR_ON(NEFFTRadixStageKernel::supported_radix().count(config.radix) == 0); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1006 | ARM_COMPUTE_UNUSED(config); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1007 | |
| 1008 | // Checks performed when output is configured |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1009 | if ((output != nullptr) && (output->total_size() != 0)) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1010 | { |
| 1011 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(input, output); |
| 1012 | ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output); |
| 1013 | } |
| 1014 | |
| 1015 | return Status{}; |
| 1016 | } |
| 1017 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1018 | std::pair<Status, Window> |
| 1019 | validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, const FFTRadixStageKernelInfo &config) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1020 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1021 | ARM_COMPUTE_UNUSED(config); |
| 1022 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1023 | if (output != nullptr) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1024 | { |
| 1025 | auto_init_if_empty(*output, *input); |
| 1026 | } |
| 1027 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1028 | Window win = calculate_max_window(*input, Steps()); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1029 | |
| 1030 | return std::make_pair(Status{}, win); |
| 1031 | } |
| 1032 | } // namespace |
| 1033 | |
| 1034 | NEFFTRadixStageKernel::NEFFTRadixStageKernel() |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 1035 | : _input(nullptr), _output(nullptr), _Nx(0), _axis(0), _radix(0), _func_0(), _func_1() |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1036 | { |
| 1037 | } |
| 1038 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1039 | void NEFFTRadixStageKernel::set_radix_stage_axis0(const FFTRadixStageKernelInfo &config) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1040 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1041 | // FFT table axis 0: [radix, first_stage] |
| 1042 | static std::map<unsigned int, std::map<bool, FFTFunctionPointerAxis0>> fft_table_axis0; |
| 1043 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1044 | if (fft_table_axis0.empty()) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1045 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1046 | fft_table_axis0[2][false] = &fft_radix_2_axes_0<false>; |
| 1047 | fft_table_axis0[3][false] = &fft_radix_3_axes_0<false>; |
| 1048 | fft_table_axis0[4][false] = &fft_radix_4_axes_0<false>; |
| 1049 | fft_table_axis0[5][false] = &fft_radix_5_axes_0<false>; |
| 1050 | fft_table_axis0[7][false] = &fft_radix_7_axes_0<false>; |
| 1051 | fft_table_axis0[8][false] = &fft_radix_8_axes_0<false>; |
| 1052 | |
| 1053 | fft_table_axis0[2][true] = &fft_radix_2_axes_0<true>; |
| 1054 | fft_table_axis0[3][true] = &fft_radix_3_axes_0<true>; |
| 1055 | fft_table_axis0[4][true] = &fft_radix_4_axes_0<true>; |
| 1056 | fft_table_axis0[5][true] = &fft_radix_5_axes_0<true>; |
| 1057 | fft_table_axis0[7][true] = &fft_radix_7_axes_0<true>; |
| 1058 | fft_table_axis0[8][true] = &fft_radix_8_axes_0<true>; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1059 | } |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1060 | |
| 1061 | _func_0 = fft_table_axis0[config.radix][config.is_first_stage]; |
| 1062 | } |
| 1063 | |
| 1064 | void NEFFTRadixStageKernel::set_radix_stage_axis1(const FFTRadixStageKernelInfo &config) |
| 1065 | { |
| 1066 | // FFT table axis 1: [radix, first_stage] |
| 1067 | static std::map<unsigned int, FFTFunctionPointerAxis1> fft_table_axis1; |
| 1068 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1069 | if (fft_table_axis1.empty()) |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1070 | { |
| 1071 | fft_table_axis1[2] = &fft_radix_2_axes_1; |
| 1072 | fft_table_axis1[3] = &fft_radix_3_axes_1; |
| 1073 | fft_table_axis1[4] = &fft_radix_4_axes_1; |
| 1074 | fft_table_axis1[5] = &fft_radix_5_axes_1; |
| 1075 | fft_table_axis1[7] = &fft_radix_7_axes_1; |
| 1076 | fft_table_axis1[8] = &fft_radix_8_axes_1; |
| 1077 | } |
| 1078 | |
| 1079 | _func_1 = fft_table_axis1[config.radix]; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1080 | } |
| 1081 | |
| 1082 | void NEFFTRadixStageKernel::configure(ITensor *input, ITensor *output, const FFTRadixStageKernelInfo &config) |
| 1083 | { |
| 1084 | ARM_COMPUTE_ERROR_ON_NULLPTR(input); |
| 1085 | |
| 1086 | // Output auto inizialitation if not yet initialized |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1087 | if (output != nullptr) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1088 | { |
| 1089 | auto_init_if_empty(*output->info(), *input->info()->clone()); |
| 1090 | } |
| 1091 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1092 | ARM_COMPUTE_ERROR_THROW_ON( |
| 1093 | validate_arguments(input->info(), (output != nullptr) ? output->info() : nullptr, config)); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1094 | |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 1095 | _input = input; |
| 1096 | _output = (output == nullptr) ? input : output; |
| 1097 | _Nx = config.Nx; |
| 1098 | _axis = config.axis; |
| 1099 | _radix = config.radix; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1100 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1101 | switch (config.axis) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1102 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1103 | case 0: |
| 1104 | set_radix_stage_axis0(config); |
| 1105 | break; |
| 1106 | case 1: |
| 1107 | set_radix_stage_axis1(config); |
| 1108 | break; |
| 1109 | default: |
| 1110 | ARM_COMPUTE_ERROR("Axis not supported"); |
| 1111 | break; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1112 | } |
| 1113 | |
| 1114 | // Configure kernel window |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1115 | auto win_config = |
| 1116 | validate_and_configure_window(input->info(), (output != nullptr) ? output->info() : nullptr, config); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1117 | ARM_COMPUTE_ERROR_THROW_ON(win_config.first); |
| 1118 | INEKernel::configure(win_config.second); |
| 1119 | } |
| 1120 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1121 | Status NEFFTRadixStageKernel::validate(const ITensorInfo *input, |
| 1122 | const ITensorInfo *output, |
| 1123 | const FFTRadixStageKernelInfo &config) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1124 | { |
| 1125 | const bool run_in_place = (output == nullptr) || (output == input); |
| 1126 | ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, config)); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1127 | ARM_COMPUTE_RETURN_ON_ERROR( |
| 1128 | validate_and_configure_window(input->clone().get(), (run_in_place) ? nullptr : output->clone().get(), config) |
| 1129 | .first); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1130 | |
| 1131 | return Status{}; |
| 1132 | } |
| 1133 | |
| 1134 | std::set<unsigned int> NEFFTRadixStageKernel::supported_radix() |
| 1135 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1136 | return std::set<unsigned int>{2, 3, 4, 5, 7, 8}; |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | void NEFFTRadixStageKernel::run(const Window &window, const ThreadInfo &info) |
| 1140 | { |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1141 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 1142 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1143 | ARM_COMPUTE_UNUSED(info); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1144 | |
| 1145 | Window input_window = window; |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1146 | input_window.set(_axis, 0); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1147 | |
| 1148 | Iterator in(_input, input_window); |
Manuel Bottini | 9a81cd8 | 2021-04-15 17:44:55 +0100 | [diff] [blame] | 1149 | Iterator out(_output, input_window); |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1150 | |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1151 | // Precompute FFT constants |
| 1152 | const unsigned int NxRadix = _radix * _Nx; |
| 1153 | const float alpha = 2.0f * kPi / float(NxRadix); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1154 | const float32x2_t w_m{cosf(alpha), -sinf(alpha)}; |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1155 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1156 | if (_axis == 0) |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1157 | { |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1158 | const unsigned int N = _input->info()->dimension(0); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1159 | execute_window_loop( |
| 1160 | input_window, |
| 1161 | [&](const Coordinates &) { |
| 1162 | _func_0(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, |
| 1163 | N); |
| 1164 | }, |
| 1165 | in, out); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1166 | } |
| 1167 | else |
| 1168 | { |
| 1169 | const unsigned int N = _input->info()->dimension(0); |
| 1170 | const unsigned int M = _input->info()->dimension(1); |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 1171 | execute_window_loop( |
| 1172 | input_window, |
| 1173 | [&](const Coordinates &) |
| 1174 | { |
| 1175 | _func_1(reinterpret_cast<float *>(out.ptr()), reinterpret_cast<float *>(in.ptr()), _Nx, NxRadix, w_m, N, |
| 1176 | M, _input->info()->padding().right + _input->info()->padding().left, |
| 1177 | _output->info()->padding().right + _output->info()->padding().left); |
| 1178 | }, |
| 1179 | in, out); |
giuros01 | 05fb448 | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1180 | } |
giuros01 | 14c4e0f | 2019-03-26 17:44:40 +0000 | [diff] [blame] | 1181 | |
| 1182 | ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this); |
| 1183 | ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window); |
| 1184 | } |
| 1185 | } // namespace arm_compute |