| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/f16-vcmul/neonfp16arith.c.in |
| 3 |
// Generator: tools/xngen |
| 4 |
// |
| 5 |
// Copyright 2023 Google LLC |
| 6 |
// |
| 7 |
// This source code is licensed under the BSD-style license found in the |
| 8 |
// LICENSE file in the root directory of this source tree. |
| 9 |
|
| 10 |
#include <assert.h> |
| 11 |
|
| 12 |
#include <arm_neon.h> |
| 13 |
|
| 14 |
#include "xnnpack/common.h" |
| 15 |
#include "xnnpack/vbinary.h" |
| 16 |
|
| 17 |
|
| 18 |
void xnn_f16_vcmul_ukernel__neonfp16arith_u8( |
| 19 |
size_t batch, |
| 20 |
const xnn_float16* input_a, |
| 21 |
const xnn_float16* input_b, |
| 22 |
xnn_float16* output, |
| 23 |
const struct xnn_f16_default_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS |
| 24 |
{ |
| 25 |
assert(batch != 0); |
| 26 |
assert(batch % sizeof(uint16_t) == 0); |
| 27 |
assert(input_a != NULL); |
| 28 |
assert(input_b != NULL); |
| 29 |
assert(output != NULL); |
| 30 |
|
| 31 |
const uint16_t* ar = (const uint16_t*) input_a; |
| 32 |
const uint16_t* ai = (const uint16_t*) ((uintptr_t) input_a + batch); |
| 33 |
const uint16_t* br = (const uint16_t*) input_b; |
| 34 |
const uint16_t* bi = (const uint16_t*) ((uintptr_t) input_b + batch); |
| 35 |
uint16_t* or = (uint16_t*) output; |
| 36 |
uint16_t* oi = (uint16_t*) ((uintptr_t) output + batch); |
| 37 |
for (; batch >= 8 * sizeof(uint16_t); batch -= 8 * sizeof(uint16_t)) { |
| 38 |
const float16x8_t var = vreinterpretq_f16_u16(vld1q_u16(ar)); ar += 8; |
| 39 |
const float16x8_t vai = vreinterpretq_f16_u16(vld1q_u16(ai)); ai += 8; |
| 40 |
const float16x8_t vbr = vreinterpretq_f16_u16(vld1q_u16(br)); br += 8; |
| 41 |
const float16x8_t vbi = vreinterpretq_f16_u16(vld1q_u16(bi)); bi += 8; |
| 42 |
|
| 43 |
float16x8_t vaccr = vmulq_f16(var, vbr); |
| 44 |
float16x8_t vacci = vmulq_f16(var, vbi); |
| 45 |
|
| 46 |
vaccr = vfmsq_f16(vaccr, vai, vbi); |
| 47 |
vacci = vfmaq_f16(vacci, vai, vbr); |
| 48 |
|
| 49 |
vst1q_u16(or, vreinterpretq_u16_f16(vaccr)); or += 8; |
| 50 |
vst1q_u16(oi, vreinterpretq_u16_f16(vacci)); oi += 8; |
| 51 |
} |
| 52 |
if XNN_UNLIKELY(batch != 0) { |
| 53 |
const float16x8_t var = vreinterpretq_f16_u16(vld1q_u16(ar)); ar += 8; |
| 54 |
const float16x8_t vai = vreinterpretq_f16_u16(vld1q_u16(ai)); ai += 8; |
| 55 |
const float16x8_t vbr = vreinterpretq_f16_u16(vld1q_u16(br)); br += 8; |
| 56 |
const float16x8_t vbi = vreinterpretq_f16_u16(vld1q_u16(bi)); bi += 8; |
| 57 |
|
| 58 |
float16x8_t vaccr = vmulq_f16(var, vbr); |
| 59 |
float16x8_t vacci = vmulq_f16(var, vbi); |
| 60 |
|
| 61 |
vaccr = vfmsq_f16(vaccr, vai, vbi); |
| 62 |
vacci = vfmaq_f16(vacci, vai, vbr); |
| 63 |
|
| 64 |
float16x4_t vaccr_lo = vget_low_f16(vaccr); |
| 65 |
float16x4_t vacci_lo = vget_low_f16(vacci); |
| 66 |
if (batch & (4 * sizeof(uint16_t))) { |
| 67 |
vst1_u16(or, vreinterpret_u16_f16(vaccr_lo)); or += 4; |
| 68 |
vst1_u16(oi, vreinterpret_u16_f16(vacci_lo)); oi += 4; |
| 69 |
vaccr_lo = vget_high_f16(vaccr); |
| 70 |
vacci_lo = vget_high_f16(vacci); |
| 71 |
} |
| 72 |
if (batch & (2 * sizeof(uint16_t))) { |
| 73 |
vst1_lane_u32((void*) or, vreinterpret_u32_f16(vaccr_lo), 0); or += 2; |
| 74 |
vst1_lane_u32((void*) oi, vreinterpret_u32_f16(vacci_lo), 0); oi += 2; |
| 75 |
vaccr_lo = vext_f16(vaccr_lo, vaccr_lo, 2); |
| 76 |
vacci_lo = vext_f16(vacci_lo, vacci_lo, 2); |
| 77 |
} |
| 78 |
if (batch & (1 * sizeof(uint16_t))) { |
| 79 |
vst1_lane_u16(or, vreinterpret_u16_f16(vaccr_lo), 0); |
| 80 |
vst1_lane_u16(oi, vreinterpret_u16_f16(vacci_lo), 0); |
| 81 |
} |
| 82 |
} |
| 83 |
} |