| 1 |
/* SPDX-License-Identifier: MIT |
| 2 |
* |
| 3 |
* Permission is hereby granted, free of charge, to any person |
| 4 |
* obtaining a copy of this software and associated documentation |
| 5 |
* files (the "Software"), to deal in the Software without |
| 6 |
* restriction, including without limitation the rights to use, copy, |
| 7 |
* modify, merge, publish, distribute, sublicense, and/or sell copies |
| 8 |
* of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be |
| 12 |
* included in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 15 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 16 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 17 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 18 |
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 19 |
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 20 |
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
* SOFTWARE. |
| 22 |
* |
| 23 |
* Copyright: |
| 24 |
* 2020 Evan Nemerson <[email protected]> |
| 25 |
* 2020 Sean Maher <[email protected]> (Copyright owned by Google, LLC) |
| 26 |
*/ |
| 27 |
|
| 28 |
#if !defined(SIMDE_ARM_NEON_DOT_LANE_H) |
| 29 |
#define SIMDE_ARM_NEON_DOT_LANE_H |
| 30 |
|
| 31 |
#include "types.h" |
| 32 |
|
| 33 |
#include "add.h" |
| 34 |
#include "dup_lane.h" |
| 35 |
#include "paddl.h" |
| 36 |
#include "movn.h" |
| 37 |
#include "mull.h" |
| 38 |
|
| 39 |
HEDLEY_DIAGNOSTIC_PUSH |
| 40 |
SIMDE_DISABLE_UNWANTED_DIAGNOSTICS |
| 41 |
SIMDE_BEGIN_DECLS_ |
| 42 |
|
| 43 |
SIMDE_FUNCTION_ATTRIBUTES |
| 44 |
simde_int32x2_t |
| 45 |
simde_vdot_lane_s32(simde_int32x2_t r, simde_int8x8_t a, simde_int8x8_t b, const int lane) |
| 46 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) { |
| 47 |
simde_int32x2_t result; |
| 48 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 49 |
SIMDE_CONSTIFY_2_(vdot_lane_s32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 50 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 51 |
simde_int32x2_t |
| 52 |
b_lane, |
| 53 |
b_32 = vreinterpret_s32_s8(b); |
| 54 |
|
| 55 |
SIMDE_CONSTIFY_2_(vdup_lane_s32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 56 |
result = |
| 57 |
vadd_s32( |
| 58 |
r, |
| 59 |
vmovn_s64( |
| 60 |
vpaddlq_s32( |
| 61 |
vpaddlq_s16( |
| 62 |
vmull_s8(a, vreinterpret_s8_s32(b_lane)) |
| 63 |
) |
| 64 |
) |
| 65 |
) |
| 66 |
); |
| 67 |
#else |
| 68 |
simde_int32x2_private r_ = simde_int32x2_to_private(r); |
| 69 |
simde_int8x8_private |
| 70 |
a_ = simde_int8x8_to_private(a), |
| 71 |
b_ = simde_int8x8_to_private(b); |
| 72 |
|
| 73 |
for (int i = 0 ; i < 2 ; i++) { |
| 74 |
int32_t acc = 0; |
| 75 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 76 |
for (int j = 0 ; j < 4 ; j++) { |
| 77 |
const int idx_b = j + (lane << 2); |
| 78 |
const int idx_a = j + (i << 2); |
| 79 |
acc += HEDLEY_STATIC_CAST(int32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(int32_t, b_.values[idx_b]); |
| 80 |
} |
| 81 |
r_.values[i] += acc; |
| 82 |
} |
| 83 |
|
| 84 |
result = simde_int32x2_from_private(r_); |
| 85 |
#endif |
| 86 |
|
| 87 |
return result; |
| 88 |
} |
| 89 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 90 |
#undef vdot_lane_s32 |
| 91 |
#define vdot_lane_s32(r, a, b, lane) simde_vdot_lane_s32((r), (a), (b), (lane)) |
| 92 |
#endif |
| 93 |
|
| 94 |
SIMDE_FUNCTION_ATTRIBUTES |
| 95 |
simde_uint32x2_t |
| 96 |
simde_vdot_lane_u32(simde_uint32x2_t r, simde_uint8x8_t a, simde_uint8x8_t b, const int lane) |
| 97 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) { |
| 98 |
simde_uint32x2_t result; |
| 99 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 100 |
SIMDE_CONSTIFY_2_(vdot_lane_u32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 101 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 102 |
simde_uint32x2_t |
| 103 |
b_lane, |
| 104 |
b_32 = vreinterpret_u32_u8(b); |
| 105 |
|
| 106 |
SIMDE_CONSTIFY_2_(vdup_lane_u32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 107 |
result = |
| 108 |
vadd_u32( |
| 109 |
r, |
| 110 |
vmovn_u64( |
| 111 |
vpaddlq_u32( |
| 112 |
vpaddlq_u16( |
| 113 |
vmull_u8(a, vreinterpret_u8_u32(b_lane)) |
| 114 |
) |
| 115 |
) |
| 116 |
) |
| 117 |
); |
| 118 |
#else |
| 119 |
simde_uint32x2_private r_ = simde_uint32x2_to_private(r); |
| 120 |
simde_uint8x8_private |
| 121 |
a_ = simde_uint8x8_to_private(a), |
| 122 |
b_ = simde_uint8x8_to_private(b); |
| 123 |
|
| 124 |
for (int i = 0 ; i < 2 ; i++) { |
| 125 |
uint32_t acc = 0; |
| 126 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 127 |
for (int j = 0 ; j < 4 ; j++) { |
| 128 |
const int idx_b = j + (lane << 2); |
| 129 |
const int idx_a = j + (i << 2); |
| 130 |
acc += HEDLEY_STATIC_CAST(uint32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(uint32_t, b_.values[idx_b]); |
| 131 |
} |
| 132 |
r_.values[i] += acc; |
| 133 |
} |
| 134 |
|
| 135 |
result = simde_uint32x2_from_private(r_); |
| 136 |
#endif |
| 137 |
|
| 138 |
return result; |
| 139 |
} |
| 140 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 141 |
#undef vdot_lane_u32 |
| 142 |
#define vdot_lane_u32(r, a, b, lane) simde_vdot_lane_u32((r), (a), (b), (lane)) |
| 143 |
#endif |
| 144 |
|
| 145 |
SIMDE_FUNCTION_ATTRIBUTES |
| 146 |
simde_int32x2_t |
| 147 |
simde_vdot_laneq_s32(simde_int32x2_t r, simde_int8x8_t a, simde_int8x16_t b, const int lane) |
| 148 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) { |
| 149 |
simde_int32x2_t result; |
| 150 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 151 |
SIMDE_CONSTIFY_4_(vdot_laneq_s32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 152 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 153 |
simde_int32x2_t b_lane; |
| 154 |
simde_int32x4_t b_32 = vreinterpretq_s32_s8(b); |
| 155 |
|
| 156 |
SIMDE_CONSTIFY_4_(simde_vdup_laneq_s32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 157 |
result = |
| 158 |
vadd_s32( |
| 159 |
r, |
| 160 |
vmovn_s64( |
| 161 |
vpaddlq_s32( |
| 162 |
vpaddlq_s16( |
| 163 |
vmull_s8(a, vreinterpret_s8_s32(b_lane)) |
| 164 |
) |
| 165 |
) |
| 166 |
) |
| 167 |
); |
| 168 |
#else |
| 169 |
simde_int32x2_private r_ = simde_int32x2_to_private(r); |
| 170 |
simde_int8x8_private a_ = simde_int8x8_to_private(a); |
| 171 |
simde_int8x16_private b_ = simde_int8x16_to_private(b); |
| 172 |
|
| 173 |
for (int i = 0 ; i < 2 ; i++) { |
| 174 |
int32_t acc = 0; |
| 175 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 176 |
for (int j = 0 ; j < 4 ; j++) { |
| 177 |
const int idx_b = j + (lane << 2); |
| 178 |
const int idx_a = j + (i << 2); |
| 179 |
acc += HEDLEY_STATIC_CAST(int32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(int32_t, b_.values[idx_b]); |
| 180 |
} |
| 181 |
r_.values[i] += acc; |
| 182 |
} |
| 183 |
|
| 184 |
result = simde_int32x2_from_private(r_); |
| 185 |
#endif |
| 186 |
|
| 187 |
return result; |
| 188 |
} |
| 189 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 190 |
#undef vdot_laneq_s32 |
| 191 |
#define vdot_laneq_s32(r, a, b, lane) simde_vdot_laneq_s32((r), (a), (b), (lane)) |
| 192 |
#endif |
| 193 |
|
| 194 |
SIMDE_FUNCTION_ATTRIBUTES |
| 195 |
simde_uint32x2_t |
| 196 |
simde_vdot_laneq_u32(simde_uint32x2_t r, simde_uint8x8_t a, simde_uint8x16_t b, const int lane) |
| 197 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) { |
| 198 |
simde_uint32x2_t result; |
| 199 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 200 |
SIMDE_CONSTIFY_4_(vdot_laneq_u32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 201 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 202 |
simde_uint32x2_t b_lane; |
| 203 |
simde_uint32x4_t b_32 = vreinterpretq_u32_u8(b); |
| 204 |
|
| 205 |
SIMDE_CONSTIFY_4_(simde_vdup_laneq_u32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 206 |
result = |
| 207 |
vadd_u32( |
| 208 |
r, |
| 209 |
vmovn_u64( |
| 210 |
vpaddlq_u32( |
| 211 |
vpaddlq_u16( |
| 212 |
vmull_u8(a, vreinterpret_u8_u32(b_lane)) |
| 213 |
) |
| 214 |
) |
| 215 |
) |
| 216 |
); |
| 217 |
#else |
| 218 |
simde_uint32x2_private r_ = simde_uint32x2_to_private(r); |
| 219 |
simde_uint8x8_private a_ = simde_uint8x8_to_private(a); |
| 220 |
simde_uint8x16_private b_ = simde_uint8x16_to_private(b); |
| 221 |
|
| 222 |
for (int i = 0 ; i < 2 ; i++) { |
| 223 |
uint32_t acc = 0; |
| 224 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 225 |
for (int j = 0 ; j < 4 ; j++) { |
| 226 |
const int idx_b = j + (lane << 2); |
| 227 |
const int idx_a = j + (i << 2); |
| 228 |
acc += HEDLEY_STATIC_CAST(uint32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(uint32_t, b_.values[idx_b]); |
| 229 |
} |
| 230 |
r_.values[i] += acc; |
| 231 |
} |
| 232 |
|
| 233 |
result = simde_uint32x2_from_private(r_); |
| 234 |
#endif |
| 235 |
return result; |
| 236 |
} |
| 237 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 238 |
#undef vdot_laneq_u32 |
| 239 |
#define vdot_laneq_u32(r, a, b, lane) simde_vdot_laneq_u32((r), (a), (b), (lane)) |
| 240 |
#endif |
| 241 |
|
| 242 |
SIMDE_FUNCTION_ATTRIBUTES |
| 243 |
simde_uint32x4_t |
| 244 |
simde_vdotq_laneq_u32(simde_uint32x4_t r, simde_uint8x16_t a, simde_uint8x16_t b, const int lane) |
| 245 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) { |
| 246 |
simde_uint32x4_t result; |
| 247 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 248 |
SIMDE_CONSTIFY_4_(vdotq_laneq_u32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 249 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 250 |
simde_uint32x4_t |
| 251 |
b_lane, |
| 252 |
b_32 = vreinterpretq_u32_u8(b); |
| 253 |
SIMDE_CONSTIFY_4_(simde_vdupq_laneq_u32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 254 |
|
| 255 |
result = |
| 256 |
vcombine_u32( |
| 257 |
vadd_u32( |
| 258 |
vget_low_u32(r), |
| 259 |
vmovn_u64( |
| 260 |
vpaddlq_u32( |
| 261 |
vpaddlq_u16( |
| 262 |
vmull_u8(vget_low_u8(a), vget_low_u8(vreinterpretq_u8_u32(b_lane))) |
| 263 |
) |
| 264 |
) |
| 265 |
) |
| 266 |
), |
| 267 |
vadd_u32( |
| 268 |
vget_high_u32(r), |
| 269 |
vmovn_u64( |
| 270 |
vpaddlq_u32( |
| 271 |
vpaddlq_u16( |
| 272 |
vmull_u8(vget_high_u8(a), vget_high_u8(vreinterpretq_u8_u32(b_lane))) |
| 273 |
) |
| 274 |
) |
| 275 |
) |
| 276 |
) |
| 277 |
); |
| 278 |
#else |
| 279 |
simde_uint32x4_private r_ = simde_uint32x4_to_private(r); |
| 280 |
simde_uint8x16_private |
| 281 |
a_ = simde_uint8x16_to_private(a), |
| 282 |
b_ = simde_uint8x16_to_private(b); |
| 283 |
|
| 284 |
for(int i = 0 ; i < 4 ; i++) { |
| 285 |
uint32_t acc = 0; |
| 286 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 287 |
for(int j = 0 ; j < 4 ; j++) { |
| 288 |
const int idx_b = j + (lane << 2); |
| 289 |
const int idx_a = j + (i << 2); |
| 290 |
acc += HEDLEY_STATIC_CAST(uint32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(uint32_t, b_.values[idx_b]); |
| 291 |
} |
| 292 |
r_.values[i] += acc; |
| 293 |
} |
| 294 |
|
| 295 |
result = simde_uint32x4_from_private(r_); |
| 296 |
#endif |
| 297 |
return result; |
| 298 |
} |
| 299 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 300 |
#undef vdotq_laneq_u32 |
| 301 |
#define vdotq_laneq_u32(r, a, b, lane) simde_vdotq_laneq_u32((r), (a), (b), (lane)) |
| 302 |
#endif |
| 303 |
|
| 304 |
SIMDE_FUNCTION_ATTRIBUTES |
| 305 |
simde_int32x4_t |
| 306 |
simde_vdotq_laneq_s32(simde_int32x4_t r, simde_int8x16_t a, simde_int8x16_t b, const int lane) |
| 307 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 3) { |
| 308 |
simde_int32x4_t result; |
| 309 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 310 |
SIMDE_CONSTIFY_4_(vdotq_laneq_s32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 311 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 312 |
simde_int32x4_t |
| 313 |
b_lane, |
| 314 |
b_32 = vreinterpretq_s32_s8(b); |
| 315 |
SIMDE_CONSTIFY_4_(simde_vdupq_laneq_s32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 316 |
|
| 317 |
result = |
| 318 |
vcombine_s32( |
| 319 |
vadd_s32( |
| 320 |
vget_low_s32(r), |
| 321 |
vmovn_s64( |
| 322 |
vpaddlq_s32( |
| 323 |
vpaddlq_s16( |
| 324 |
vmull_s8(vget_low_s8(a), vget_low_s8(vreinterpretq_s8_s32(b_lane))) |
| 325 |
) |
| 326 |
) |
| 327 |
) |
| 328 |
), |
| 329 |
vadd_s32( |
| 330 |
vget_high_s32(r), |
| 331 |
vmovn_s64( |
| 332 |
vpaddlq_s32( |
| 333 |
vpaddlq_s16( |
| 334 |
vmull_s8(vget_high_s8(a), vget_high_s8(vreinterpretq_s8_s32(b_lane))) |
| 335 |
) |
| 336 |
) |
| 337 |
) |
| 338 |
) |
| 339 |
); |
| 340 |
#else |
| 341 |
simde_int32x4_private r_ = simde_int32x4_to_private(r); |
| 342 |
simde_int8x16_private |
| 343 |
a_ = simde_int8x16_to_private(a), |
| 344 |
b_ = simde_int8x16_to_private(b); |
| 345 |
|
| 346 |
for(int i = 0 ; i < 4 ; i++) { |
| 347 |
int32_t acc = 0; |
| 348 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 349 |
for(int j = 0 ; j < 4 ; j++) { |
| 350 |
const int idx_b = j + (lane << 2); |
| 351 |
const int idx_a = j + (i << 2); |
| 352 |
acc += HEDLEY_STATIC_CAST(int32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(int32_t, b_.values[idx_b]); |
| 353 |
} |
| 354 |
r_.values[i] += acc; |
| 355 |
} |
| 356 |
|
| 357 |
result = simde_int32x4_from_private(r_); |
| 358 |
#endif |
| 359 |
return result; |
| 360 |
} |
| 361 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 362 |
#undef vdotq_laneq_s32 |
| 363 |
#define vdotq_laneq_s32(r, a, b, lane) simde_vdotq_laneq_s32((r), (a), (b), (lane)) |
| 364 |
#endif |
| 365 |
|
| 366 |
SIMDE_FUNCTION_ATTRIBUTES |
| 367 |
simde_uint32x4_t |
| 368 |
simde_vdotq_lane_u32(simde_uint32x4_t r, simde_uint8x16_t a, simde_uint8x8_t b, const int lane) |
| 369 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) { |
| 370 |
simde_uint32x4_t result; |
| 371 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 372 |
SIMDE_CONSTIFY_2_(vdotq_lane_u32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 373 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 374 |
simde_uint32x2_t |
| 375 |
b_lane, |
| 376 |
b_32 = vreinterpret_u32_u8(b); |
| 377 |
SIMDE_CONSTIFY_2_(simde_vdup_lane_u32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 378 |
|
| 379 |
result = |
| 380 |
vcombine_u32( |
| 381 |
vadd_u32( |
| 382 |
vget_low_u32(r), |
| 383 |
vmovn_u64( |
| 384 |
vpaddlq_u32( |
| 385 |
vpaddlq_u16( |
| 386 |
vmull_u8(vget_low_u8(a), vreinterpret_u8_u32(b_lane)) |
| 387 |
) |
| 388 |
) |
| 389 |
) |
| 390 |
), |
| 391 |
vadd_u32( |
| 392 |
vget_high_u32(r), |
| 393 |
vmovn_u64( |
| 394 |
vpaddlq_u32( |
| 395 |
vpaddlq_u16( |
| 396 |
vmull_u8(vget_high_u8(a), vreinterpret_u8_u32(b_lane)) |
| 397 |
) |
| 398 |
) |
| 399 |
) |
| 400 |
) |
| 401 |
); |
| 402 |
#else |
| 403 |
simde_uint32x4_private r_ = simde_uint32x4_to_private(r); |
| 404 |
simde_uint8x16_private a_ = simde_uint8x16_to_private(a); |
| 405 |
simde_uint8x8_private b_ = simde_uint8x8_to_private(b); |
| 406 |
|
| 407 |
for(int i = 0 ; i < 4 ; i++) { |
| 408 |
uint32_t acc = 0; |
| 409 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 410 |
for(int j = 0 ; j < 4 ; j++) { |
| 411 |
const int idx_b = j + (lane << 2); |
| 412 |
const int idx_a = j + (i << 2); |
| 413 |
acc += HEDLEY_STATIC_CAST(uint32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(uint32_t, b_.values[idx_b]); |
| 414 |
} |
| 415 |
r_.values[i] += acc; |
| 416 |
} |
| 417 |
|
| 418 |
result = simde_uint32x4_from_private(r_); |
| 419 |
#endif |
| 420 |
return result; |
| 421 |
} |
| 422 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 423 |
#undef vdotq_lane_u32 |
| 424 |
#define vdotq_lane_u32(r, a, b, lane) simde_vdotq_lane_u32((r), (a), (b), (lane)) |
| 425 |
#endif |
| 426 |
|
| 427 |
SIMDE_FUNCTION_ATTRIBUTES |
| 428 |
simde_int32x4_t |
| 429 |
simde_vdotq_lane_s32(simde_int32x4_t r, simde_int8x16_t a, simde_int8x8_t b, const int lane) |
| 430 |
SIMDE_REQUIRE_CONSTANT_RANGE(lane, 0, 1) { |
| 431 |
simde_int32x4_t result; |
| 432 |
#if defined(SIMDE_ARM_NEON_A64V8_NATIVE) && defined(__ARM_FEATURE_DOTPROD) |
| 433 |
SIMDE_CONSTIFY_2_(vdotq_lane_s32, result, (HEDLEY_UNREACHABLE(), result), lane, r, a, b); |
| 434 |
#elif defined(SIMDE_ARM_NEON_A32V7_NATIVE) |
| 435 |
simde_int32x2_t |
| 436 |
b_lane, |
| 437 |
b_32 = vreinterpret_s32_s8(b); |
| 438 |
SIMDE_CONSTIFY_2_(simde_vdup_lane_s32, b_lane, (HEDLEY_UNREACHABLE(), b_lane), lane, b_32); |
| 439 |
|
| 440 |
result = |
| 441 |
vcombine_s32( |
| 442 |
vadd_s32( |
| 443 |
vget_low_s32(r), |
| 444 |
vmovn_s64( |
| 445 |
vpaddlq_s32( |
| 446 |
vpaddlq_s16( |
| 447 |
vmull_s8(vget_low_s8(a), vreinterpret_s8_s32(b_lane)) |
| 448 |
) |
| 449 |
) |
| 450 |
) |
| 451 |
), |
| 452 |
vadd_s32( |
| 453 |
vget_high_s32(r), |
| 454 |
vmovn_s64( |
| 455 |
vpaddlq_s32( |
| 456 |
vpaddlq_s16( |
| 457 |
vmull_s8(vget_high_s8(a), vreinterpret_s8_s32(b_lane)) |
| 458 |
) |
| 459 |
) |
| 460 |
) |
| 461 |
) |
| 462 |
); |
| 463 |
#else |
| 464 |
simde_int32x4_private r_ = simde_int32x4_to_private(r); |
| 465 |
simde_int8x16_private a_ = simde_int8x16_to_private(a); |
| 466 |
simde_int8x8_private b_ = simde_int8x8_to_private(b); |
| 467 |
|
| 468 |
for(int i = 0 ; i < 4 ; i++) { |
| 469 |
int32_t acc = 0; |
| 470 |
SIMDE_VECTORIZE_REDUCTION(+:acc) |
| 471 |
for(int j = 0 ; j < 4 ; j++) { |
| 472 |
const int idx_b = j + (lane << 2); |
| 473 |
const int idx_a = j + (i << 2); |
| 474 |
acc += HEDLEY_STATIC_CAST(int32_t, a_.values[idx_a]) * HEDLEY_STATIC_CAST(int32_t, b_.values[idx_b]); |
| 475 |
} |
| 476 |
r_.values[i] += acc; |
| 477 |
} |
| 478 |
|
| 479 |
result = simde_int32x4_from_private(r_); |
| 480 |
#endif |
| 481 |
return result; |
| 482 |
} |
| 483 |
#if defined(SIMDE_ARM_NEON_A32V8_ENABLE_NATIVE_ALIASES) || (defined(SIMDE_ENABLE_NATIVE_ALIASES) && !defined(__ARM_FEATURE_DOTPROD)) |
| 484 |
#undef vdotq_lane_s32 |
| 485 |
#define vdotq_lane_s32(r, a, b, lane) simde_vdotq_lane_s32((r), (a), (b), (lane)) |
| 486 |
#endif |
| 487 |
|
| 488 |
SIMDE_END_DECLS_ |
| 489 |
HEDLEY_DIAGNOSTIC_POP |
| 490 |
|
| 491 |
#endif /* !defined(SIMDE_ARM_NEON_DOT_LANE_H) */ |