Debian Codegraph @

src/qu8-vaddc/gen/qu8-vaddc-minmax-scalar-u1.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-vaddc/scalar.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 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/vbinary.h"
14
15
16 void xnn_qu8_vaddc_minmax_ukernel__scalar_u1(
17 size_t batch,
18 const uint8_t* input_a,
19 const uint8_t* input_b,
20 uint8_t* output,
21 const struct xnn_qu8_add_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
22 {
23 assert(batch != 0);
24 assert(batch % sizeof(uint8_t) == 0);
25 assert(input_a != NULL);
26 assert(input_b != NULL);
27 assert(output != NULL);
28
29 const int32_t vbias = params->scalar.bias + (int32_t) *input_b * params->scalar.b_multiplier;
30 const int32_t va_multiplier = params->scalar.a_multiplier;
31 const uint32_t vshift = params->scalar.shift;
32 const int32_t voutput_min = params->scalar.output_min;
33 const int32_t voutput_max = params->scalar.output_max;
34 const int32_t voutput_zero_point = params->scalar.output_zero_point;
35
36 do {
37 const int32_t va = *input_a++;
38 const int32_t vacc = vbias + va * va_multiplier;
39
40 int32_t vout = math_asr_s32(vacc, vshift);
41 vout = vout + voutput_zero_point;
42 vout = math_max_s32(vout, voutput_min);
43 vout = math_min_s32(vout, voutput_max);
44 *output++ = (uint8_t) vout;
45
46 batch -= sizeof(uint8_t);
47 } while (batch != 0);
48 }