Debian Codegraph @

src/f32-vrelu/gen/f32-vrelu-avx512f-u16.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vrelu/avx512f.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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 <immintrin.h>
13
14 #include "xnnpack/vunary.h"
15 #include "xnnpack/common.h"
16 #include "xnnpack/intrinsics-polyfill.h"
17
18
19 void xnn_f32_vrelu_ukernel__avx512f_u16(
20 size_t batch,
21 const float* input,
22 float* output,
23 const struct xnn_f32_relu_params params[restrict XNN_MIN_ELEMENTS(1)])
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(float) == 0);
27 assert(input != NULL);
28 assert(output != NULL);
29
30 const __m512 vzero = _mm512_setzero_ps();
31
32 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
33 __m512 vacc0123456789ABCDEF = _mm512_loadu_ps(input);
34 input += 16;
35
36 vacc0123456789ABCDEF = _mm512_max_ps(vacc0123456789ABCDEF, vzero);
37
38 _mm512_storeu_ps(output, vacc0123456789ABCDEF);
39 output += 16;
40 }
41 if XNN_UNLIKELY(batch != 0) {
42 assert(batch >= 1 * sizeof(float));
43 assert(batch <= 15 * sizeof(float));
44 // Prepare mask for valid 32-bit elements (depends on batch).
45 batch >>= XNN_LOG2_SIZEOF_FLOAT;
46 const __mmask16 vmask = _cvtu32_mask16((uint32_t) ((UINT32_C(1) << batch) - UINT32_C(1)));
47
48 __m512 vacc = _mm512_maskz_loadu_ps(vmask, input);
49 vacc = _mm512_max_ps(vacc, vzero);
50 _mm512_mask_storeu_ps(output, vmask, vacc);
51 }
52 }