| 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_u16( |
| 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(¶ms->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(¶ms->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 >= 16 * sizeof(float); batch -= 16 * sizeof(float)) { |
| 40 |
float32x4_t vacc0123 = vld1q_f32(input); input += 4; |
| 41 |
float32x4_t vacc4567 = vld1q_f32(input); input += 4; |
| 42 |
float32x4_t vacc89AB = vld1q_f32(input); input += 4; |
| 43 |
float32x4_t vaccCDEF = vld1q_f32(input); input += 4; |
| 44 |
|
| 45 |
vacc0123 = vmaxq_f32(vacc0123, vmin); |
| 46 |
vacc4567 = vmaxq_f32(vacc4567, vmin); |
| 47 |
vacc89AB = vmaxq_f32(vacc89AB, vmin); |
| 48 |
vaccCDEF = vmaxq_f32(vaccCDEF, vmin); |
| 49 |
|
| 50 |
vacc0123 = vminq_f32(vacc0123, vmax); |
| 51 |
vacc4567 = vminq_f32(vacc4567, vmax); |
| 52 |
vacc89AB = vminq_f32(vacc89AB, vmax); |
| 53 |
vaccCDEF = vminq_f32(vaccCDEF, vmax); |
| 54 |
|
| 55 |
vst1q_f32(output, vacc0123); output += 4; |
| 56 |
vst1q_f32(output, vacc4567); output += 4; |
| 57 |
vst1q_f32(output, vacc89AB); output += 4; |
| 58 |
vst1q_f32(output, vaccCDEF); output += 4; |
| 59 |
} |
| 60 |
for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) { |
| 61 |
float32x4_t vacc = vld1q_f32(input); input += 4; |
| 62 |
vacc = vmaxq_f32(vacc, vmin); |
| 63 |
vacc = vminq_f32(vacc, vmax); |
| 64 |
vst1q_f32(output, vacc); output += 4; |
| 65 |
} |
| 66 |
if XNN_UNLIKELY(batch != 0) { |
| 67 |
if (batch & (2 * sizeof(float))) { |
| 68 |
float32x2_t vacc = vld1_f32(input); input += 2; |
| 69 |
vacc = vmax_f32(vacc, vget_low_f32(vmin)); |
| 70 |
vacc = vmin_f32(vacc, vget_low_f32(vmax)); |
| 71 |
vst1_f32(output, vacc); output += 2; |
| 72 |
} |
| 73 |
if (batch & (1 * sizeof(float))) { |
| 74 |
float32x2_t vacc = vld1_dup_f32(input); |
| 75 |
vacc = vmax_f32(vacc, vget_low_f32(vmin)); |
| 76 |
vacc = vmin_f32(vacc, vget_low_f32(vmax)); |
| 77 |
vst1_lane_f32(output, vacc, 0); |
| 78 |
} |
| 79 |
} |
| 80 |
} |