Debian Codegraph @

src/f32-vclamp/gen/f32-vclamp-neon-u4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vclamp/neon.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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
18 void xnn_f32_vclamp_ukernel__neon_u4(
19 size_t batch,
20 const float* input,
21 float* output,
22 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 #if XNN_ARCH_ARM64
30 const float32x4x2_t vminmax = vld2q_dup_f32(&params->scalar.min);
31 const float32x4_t vmin = vminmax.val[0];
32 const float32x4_t vmax = vminmax.val[1];
33 #else
34 const float32x2x2_t vminmax = vld2_dup_f32(&params->scalar.min);
35 const float32x4_t vmin = vcombine_f32(vminmax.val[0], vminmax.val[0]);
36 const float32x4_t vmax = vcombine_f32(vminmax.val[1], vminmax.val[1]);
37 #endif
38
39 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
40 float32x4_t vacc0123 = vld1q_f32(input); input += 4;
41
42 vacc0123 = vmaxq_f32(vacc0123, vmin);
43
44 vacc0123 = vminq_f32(vacc0123, vmax);
45
46 vst1q_f32(output, vacc0123); output += 4;
47 }
48 if XNN_UNLIKELY(batch != 0) {
49 if (batch & (2 * sizeof(float))) {
50 float32x2_t vacc = vld1_f32(input); input += 2;
51 vacc = vmax_f32(vacc, vget_low_f32(vmin));
52 vacc = vmin_f32(vacc, vget_low_f32(vmax));
53 vst1_f32(output, vacc); output += 2;
54 }
55 if (batch & (1 * sizeof(float))) {
56 float32x2_t vacc = vld1_dup_f32(input);
57 vacc = vmax_f32(vacc, vget_low_f32(vmin));
58 vacc = vmin_f32(vacc, vget_low_f32(vmax));
59 vst1_lane_f32(output, vacc, 0);
60 }
61 }
62 }