Debian Codegraph @

src/qu8-rsum/gen/qu8-rsum-avx2-u128-acc4.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/qu8-rsum/avx2.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 #include <assert.h>
10
11 #include <immintrin.h>
12
13 #include "xnnpack/common.h"
14 #include "xnnpack/reduce.h"
15
16
17 void xnn_qu8_rsum_ukernel__avx2_u128_acc4(
18 size_t batch,
19 const uint8_t* input,
20 uint32_t* output,
21 const struct xnn_qs8_rsum_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
22 {
23 assert(batch != 0);
24 assert(input != NULL);
25 assert(output != NULL);
26 assert(params != NULL);
27
28 XNN_ALIGN(16) static const int8_t mask_table[32] = {
29 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
30 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
31 };
32
33 const __m256i vzero = _mm256_setzero_si256();
34 __m256i vacc0 = _mm256_setzero_si256();
35 __m256i vacc1 = _mm256_setzero_si256();
36 __m256i vacc2 = _mm256_setzero_si256();
37 __m256i vacc3 = _mm256_setzero_si256();
38
39 for (; batch >= 128; batch -= 128) {
40 const __m256i vin0 = _mm256_loadu_si256((const __m256i*) (input + 0));
41 const __m256i vin1 = _mm256_loadu_si256((const __m256i*) (input + 32));
42 const __m256i vin2 = _mm256_loadu_si256((const __m256i*) (input + 64));
43 const __m256i vin3 = _mm256_loadu_si256((const __m256i*) (input + 96));
44 input += 128;
45 const __m256i vt0 = _mm256_sad_epu8(vin0, vzero);
46 const __m256i vt1 = _mm256_sad_epu8(vin1, vzero);
47 const __m256i vt2 = _mm256_sad_epu8(vin2, vzero);
48 const __m256i vt3 = _mm256_sad_epu8(vin3, vzero);
49 vacc0 = _mm256_add_epi32(vacc0, vt0);
50 vacc1 = _mm256_add_epi32(vacc1, vt1);
51 vacc2 = _mm256_add_epi32(vacc2, vt2);
52 vacc3 = _mm256_add_epi32(vacc3, vt3);
53 }
54 vacc0 = _mm256_add_epi32(vacc0, vacc1);
55 vacc2 = _mm256_add_epi32(vacc2, vacc3);
56 vacc0 = _mm256_add_epi32(vacc0, vacc2);
57
58 __m128i vacc = _mm_add_epi32(_mm256_castsi256_si128(vacc0), _mm256_extractf128_si256(vacc0, 1));
59
60 for (; batch >= 16; batch -= 16) {
61 const __m128i vin = _mm_loadu_si128((const __m128i*) input);
62 input += 16;
63 const __m128i vt = _mm_sad_epu8(vin, _mm_setzero_si128());
64 vacc = _mm_add_epi32(vacc, vt);
65 }
66
67 if (XNN_UNLIKELY(batch != 0)) {
68 assert(batch >= 1 && batch <= 15);
69 const __m128i vmask = _mm_loadu_si128((const __m128i*) &mask_table[16 - batch]);
70 const __m128i vt = _mm_sad_epu8(_mm_and_si128(_mm_loadu_si128((const __m128i*) input), vmask), _mm_setzero_si128());
71 vacc = _mm_add_epi32(vacc, vt);
72 }
73
74 vacc = _mm_hadd_epi32(vacc, vacc);
75 vacc = _mm_hadd_epi32(vacc, vacc);
76 *output += (uint32_t)_mm_cvtsi128_si32(vacc);
77 }
78
79
80