| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/qs8-f32-vcvt/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/common.h" |
| 13 |
#include "xnnpack/math.h" |
| 14 |
#include "xnnpack/vcvt.h" |
| 15 |
|
| 16 |
|
| 17 |
void xnn_qu8_f32_vcvt_ukernel__scalar_u2( |
| 18 |
size_t batch, |
| 19 |
const uint8_t* input, |
| 20 |
float* output, |
| 21 |
const struct xnn_qu8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) |
| 22 |
{ |
| 23 |
assert(batch != 0); |
| 24 |
assert(batch % sizeof(uint8_t) == 0); |
| 25 |
assert(input != NULL); |
| 26 |
assert(output != NULL); |
| 27 |
|
| 28 |
const int32_t vzero_point = params->scalar.zero_point; |
| 29 |
const float vscale = params->scalar.scale; |
| 30 |
|
| 31 |
for (; batch >= 2 * sizeof(uint8_t); batch -= 2 * sizeof(uint8_t)) { |
| 32 |
int32_t vx0 = (int32_t) input[0]; |
| 33 |
int32_t vx1 = (int32_t) input[1]; |
| 34 |
input += 2; |
| 35 |
|
| 36 |
vx0 -= vzero_point; |
| 37 |
vx1 -= vzero_point; |
| 38 |
|
| 39 |
float vy0 = (float) vx0; |
| 40 |
float vy1 = (float) vx1; |
| 41 |
|
| 42 |
vy0 *= vscale; |
| 43 |
vy1 *= vscale; |
| 44 |
|
| 45 |
output[0] = vy0; |
| 46 |
output[1] = vy1; |
| 47 |
output += 2; |
| 48 |
} |
| 49 |
if XNN_UNLIKELY(batch != 0) { |
| 50 |
int32_t vx = *input; |
| 51 |
vx -= vzero_point; |
| 52 |
|
| 53 |
float vy = (float) vx; |
| 54 |
vy *= vscale; |
| 55 |
*output = vy; |
| 56 |
} |
| 57 |
} |