| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/f16-rminmax/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/reduce.h" |
| 16 |
|
| 17 |
|
| 18 |
void xnn_f16_rminmax_ukernel__neonfp16arith_u64_acc4( |
| 19 |
size_t batch, |
| 20 |
const void* input, |
| 21 |
void* output, |
| 22 |
const struct xnn_f16_default_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS |
| 23 |
{ |
| 24 |
assert(batch != 0); |
| 25 |
assert(batch % sizeof(uint16_t) == 0); |
| 26 |
assert(input != NULL); |
| 27 |
assert(output != NULL); |
| 28 |
|
| 29 |
const uint16_t* i = (const uint16_t*) input; |
| 30 |
uint16_t* o = (uint16_t*) output; |
| 31 |
float16x8_t vmin0 = vreinterpretq_f16_u16(vld1q_dup_u16(i)); |
| 32 |
float16x8_t vmax0 = vmin0; |
| 33 |
float16x8_t vmin1 = vmin0; |
| 34 |
float16x8_t vmax1 = vmax0; |
| 35 |
float16x8_t vmin2 = vmin0; |
| 36 |
float16x8_t vmax2 = vmax0; |
| 37 |
float16x8_t vmin3 = vmin0; |
| 38 |
float16x8_t vmax3 = vmax0; |
| 39 |
for (; batch >= 64 * sizeof(uint16_t); batch -= 64 * sizeof(uint16_t)) { |
| 40 |
const float16x8_t vt0 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 41 |
const float16x8_t vt1 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 42 |
const float16x8_t vt2 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 43 |
const float16x8_t vt3 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 44 |
const float16x8_t vt4 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 45 |
const float16x8_t vt5 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 46 |
const float16x8_t vt6 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 47 |
const float16x8_t vt7 = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 48 |
|
| 49 |
vmin0 = vminq_f16(vmin0, vt0); |
| 50 |
vmax0 = vmaxq_f16(vmax0, vt0); |
| 51 |
vmin1 = vminq_f16(vmin1, vt1); |
| 52 |
vmax1 = vmaxq_f16(vmax1, vt1); |
| 53 |
vmin2 = vminq_f16(vmin2, vt2); |
| 54 |
vmax2 = vmaxq_f16(vmax2, vt2); |
| 55 |
vmin3 = vminq_f16(vmin3, vt3); |
| 56 |
vmax3 = vmaxq_f16(vmax3, vt3); |
| 57 |
vmin0 = vminq_f16(vmin0, vt4); |
| 58 |
vmax0 = vmaxq_f16(vmax0, vt4); |
| 59 |
vmin1 = vminq_f16(vmin1, vt5); |
| 60 |
vmax1 = vmaxq_f16(vmax1, vt5); |
| 61 |
vmin2 = vminq_f16(vmin2, vt6); |
| 62 |
vmax2 = vmaxq_f16(vmax2, vt6); |
| 63 |
vmin3 = vminq_f16(vmin3, vt7); |
| 64 |
vmax3 = vmaxq_f16(vmax3, vt7); |
| 65 |
} |
| 66 |
vmin0 = vminq_f16(vmin0, vmin1); |
| 67 |
vmax0 = vmaxq_f16(vmax0, vmax1); |
| 68 |
vmin2 = vminq_f16(vmin2, vmin3); |
| 69 |
vmax2 = vmaxq_f16(vmax2, vmax3); |
| 70 |
vmin0 = vminq_f16(vmin0, vmin2); |
| 71 |
vmax0 = vmaxq_f16(vmax0, vmax2); |
| 72 |
for (; batch >= 8 * sizeof(uint16_t); batch -= 8 * sizeof(uint16_t)) { |
| 73 |
const float16x8_t vt = vreinterpretq_f16_u16(vld1q_u16(i)); i += 8; |
| 74 |
vmin0 = vminq_f16(vmin0, vt); |
| 75 |
vmax0 = vmaxq_f16(vmax0, vt); |
| 76 |
} |
| 77 |
float16x4_t vmin_lo = vmin_f16(vget_low_f16(vmin0), vget_high_f16(vmin0)); |
| 78 |
float16x4_t vmax_lo = vmax_f16(vget_low_f16(vmax0), vget_high_f16(vmax0)); |
| 79 |
|
| 80 |
if (XNN_UNLIKELY(batch != 0)) { |
| 81 |
const float16x8_t vt = vreinterpretq_f16_u16(vld1q_u16(i)); |
| 82 |
float16x4_t vt_lo = vget_low_f16(vt); |
| 83 |
if (batch & (4 * sizeof(uint16_t))) { |
| 84 |
vmin_lo = vmin_f16(vmin_lo, vt_lo); |
| 85 |
vmax_lo = vmax_f16(vmax_lo, vt_lo); |
| 86 |
vt_lo = vget_high_f16(vt); |
| 87 |
} |
| 88 |
if (batch & (2 * sizeof(uint16_t))) { |
| 89 |
vmin_lo = vmin_f16(vmin_lo, vext_f16(vmin_lo, vt_lo, 2)); |
| 90 |
vmax_lo = vmax_f16(vmax_lo, vext_f16(vmax_lo, vt_lo, 2)); |
| 91 |
vt_lo = vext_f16(vt_lo, vt_lo, 2); |
| 92 |
} |
| 93 |
if (batch & (1 * sizeof(uint16_t))) { |
| 94 |
vmin_lo = vmin_f16(vmin_lo, vext_f16(vmin_lo, vt_lo, 1)); |
| 95 |
vmax_lo = vmax_f16(vmax_lo, vext_f16(vmax_lo, vt_lo, 1)); |
| 96 |
} |
| 97 |
} |
| 98 |
#if XNN_ARCH_ARM64 && defined(__GNUC__) |
| 99 |
*((__fp16*) o) = vminv_f16(vmin_lo); |
| 100 |
#else |
| 101 |
vmin_lo = vpmin_f16(vmin_lo, vmin_lo); |
| 102 |
vmin_lo = vpmin_f16(vmin_lo, vmin_lo); |
| 103 |
vst1_lane_u16(o, vreinterpret_u16_f16(vmin_lo), 0); |
| 104 |
#endif |
| 105 |
#if XNN_ARCH_ARM64 && defined(__GNUC__) |
| 106 |
*((__fp16*) o + 1) = vmaxv_f16(vmax_lo); |
| 107 |
#else |
| 108 |
vmax_lo = vpmax_f16(vmax_lo, vmax_lo); |
| 109 |
vmax_lo = vpmax_f16(vmax_lo, vmax_lo); |
| 110 |
vst1_lane_u16(o + 1, vreinterpret_u16_f16(vmax_lo), 0); |
| 111 |
#endif |
| 112 |
} |