blob: 2c07aa41ab4bf5b3408e2855715d0cbaa4d764f7 [file] [log] [blame]
// Copyright 2021 Google LLC
//
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree.
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <arm_neon.h>
#include <xnnpack/intrinsics-polyfill.h>
#include <xnnpack/math-stubs.h>
void xnn_math_f32_qs8_cvt__neonv8(
size_t n,
const float* input,
int8_t* output,
int8_t output_zero_point)
{
assert(n % (8 * sizeof(int8_t)) == 0);
const int16x8_t voutput_zero_point = vdupq_n_s16((int16_t) output_zero_point);
for (; n != 0; n -= 8 * sizeof(int8_t)) {
const float32x4_t vx_lo = vld1q_f32(input); input += 4;
const float32x4_t vx_hi = vld1q_f32(input); input += 4;
const int32x4_t vy_lo = vcvtnq_s32_f32(vx_lo);
const int32x4_t vy_hi = vcvtnq_s32_f32(vx_hi);
const int16x8_t vy = vqaddq_s16(vcombine_s16(vqmovn_s32(vy_lo), vqmovn_s32(vy_hi)), voutput_zero_point);
const int8x8_t vout = vqmovn_s16(vy);
vst1_s8(output, vout); output += 8;
}
}