1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-vlrelu/scalar-andxor.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 <xnnpack/math.h>
13 #include <xnnpack/vlrelu.h>
14
15
xnn_qs8_vlrelu_ukernel__scalar_andxor_x1(size_t n,const int8_t * x,int8_t * y,const union xnn_qs8_lrelu_params params[restrict XNN_MIN_ELEMENTS (1)])16 void xnn_qs8_vlrelu_ukernel__scalar_andxor_x1(
17 size_t n,
18 const int8_t* x,
19 int8_t* y,
20 const union xnn_qs8_lrelu_params params[restrict XNN_MIN_ELEMENTS(1)])
21 {
22 const int32_t vinput_zero_point = params->scalar_andxor.input_zero_point;
23 const int32_t vmultiplier_diff = params->scalar_andxor.multiplier_diff;
24 const int32_t vmultiplier_base = params->scalar_andxor.multiplier_base;
25 const int32_t vbias = params->scalar_andxor.bias;
26 do {
27 int32_t vacc = (int32_t) *x++ - vinput_zero_point;
28 const int32_t vmultiplier = vmultiplier_base ^ (vmultiplier_diff & math_asr_s32(vacc, 31));
29 vacc = vbias + vacc * vmultiplier;
30
31 int32_t vout = math_asr_s32(vacc, 8);
32 vout = math_max_s32(vout, -128);
33 vout = math_min_s32(vout, 127);
34 *y++ = (int8_t) vout;
35
36 n -= sizeof(int8_t);
37 } while (n != 0);
38 }
39