| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/s8-vclamp/rvv.c.in |
| 3 |
// Generator: tools/xngen |
| 4 |
// |
| 5 |
// Copyright 2024 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 |
|
| 11 |
#include <assert.h> |
| 12 |
|
| 13 |
#include <riscv_vector.h> |
| 14 |
|
| 15 |
#include "xnnpack/common.h" |
| 16 |
#include "xnnpack/intrinsics-polyfill.h" |
| 17 |
#include "xnnpack/vunary.h" |
| 18 |
|
| 19 |
|
| 20 |
void xnn_s8_vclamp_ukernel__rvv_u4v( |
| 21 |
size_t batch, |
| 22 |
const int8_t* input, |
| 23 |
int8_t* output, |
| 24 |
const struct xnn_s8_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) |
| 25 |
{ |
| 26 |
assert(batch != 0); |
| 27 |
assert(batch % sizeof(int8_t) == 0); |
| 28 |
assert(input != NULL); |
| 29 |
assert(output != NULL); |
| 30 |
|
| 31 |
const int8_t vmin = params->scalar.min; |
| 32 |
const int8_t vmax = params->scalar.max; |
| 33 |
|
| 34 |
do { |
| 35 |
const size_t n = __riscv_vsetvl_e8m4(batch); |
| 36 |
vint8m4_t vacc = __riscv_vle8_v_i8m4(input, n); |
| 37 |
vacc = __riscv_vmax_vx_i8m4(vacc, vmin, n); |
| 38 |
vacc = __riscv_vmin_vx_i8m4(vacc, vmax, n); |
| 39 |
__riscv_vse8_v_i8m4(output, vacc, n); |
| 40 |
input += n; |
| 41 |
output += n; |
| 42 |
batch -= n; |
| 43 |
} while (batch != 0); |
| 44 |
} |