1 // Auto-generated file. Do not edit!
2 // Template: src/f16-vsqrt/neonfp16arith-sqrt.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2022 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/vunary.h>
16
17
xnn_f16_vsqrt_ukernel__neonfp16arith_sqrt_x16(size_t n,const void * input,void * output,const union xnn_f16_sqrt_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f16_vsqrt_ukernel__neonfp16arith_sqrt_x16(
19 size_t n,
20 const void* input,
21 void* output,
22 const union xnn_f16_sqrt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
23 {
24 assert(n != 0);
25 assert(n % sizeof(__fp16) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const __fp16* i = (const __fp16*) input;
30 __fp16* o = (__fp16*) output;
31 for (; n >= 8 * sizeof(__fp16); n -= 8 * sizeof(__fp16)) {
32 float16x8_t vacc = vld1q_f16(i); i += 8;
33 vacc = vsqrtq_f16(vacc);
34 vst1q_f16(o, vacc); o += 8;
35 }
36 if XNN_UNLIKELY(n != 0) {
37 const float16x8_t vacc = vld1q_f16(i);
38 float16x4_t vacc_lo = vsqrt_f16(vget_low_f16(vacc));
39 if (n & (4 * sizeof(__fp16))) {
40 vst1_f16(o, vacc_lo); o += 4;
41 vacc_lo = vsqrt_f16(vget_high_f16(vacc));
42 }
43 if (n & (2 * sizeof(__fp16))) {
44 vst1_lane_u32((void*) o, vreinterpret_u32_f16(vacc_lo), 0); o += 2;
45 vacc_lo = vext_f16(vacc_lo, vacc_lo, 2);
46 }
47 if (n & (1 * sizeof(__fp16))) {
48 vst1_lane_f16(o, vacc_lo, 0);
49 }
50 }
51 }
52