• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2022 Google LLC
2//
3// This source code is licensed under the BSD-style license found in the
4// LICENSE file in the root directory of this source tree.
5
6$assert BATCH_TILE == 1
7#include <assert.h>
8#include <stddef.h>
9#include <stdint.h>
10
11#include <xnnpack/filterbank.h>
12#include <xnnpack/math.h>
13
14
15void xnn_u32_filterbank_accumulate_ukernel__scalar_x${BATCH_TILE}(
16    size_t rows,
17    const uint32_t* input,
18    const uint8_t* weight_widths,
19    const uint16_t* weights,
20    uint64_t* output) {
21
22  assert(rows != 0);
23  assert(input != NULL);
24  assert(weight_widths != NULL);
25  assert(weights != NULL);
26  assert(output != NULL);
27
28  uint64_t weight_accumulator = 0;
29  uint64_t unweight_accumulator = 0;
30
31  // compute unweight as initial weight
32  size_t n = (size_t) *weight_widths++;
33  assert(n != 0);
34  do {
35    const uint32_t vi = *input++;
36    const uint32_t vu = (uint32_t) weights[1];  // unweight
37    weights += 2;
38
39    const uint64_t vuacc = math_mulext_u32(vi, vu);
40
41    weight_accumulator += vuacc;
42
43  } while (--n != 0);
44
45  do {
46    size_t n = (size_t) *weight_widths++;
47    assert(n != 0);
48    do {
49      const uint32_t vi = *input++;
50      const uint32_t vw = (uint32_t) weights[0];  // weight
51      const uint32_t vu = (uint32_t) weights[1];  // unweight
52      weights += 2;
53
54      const uint64_t vwacc = math_mulext_u32(vi, vw);
55      const uint64_t vuacc = math_mulext_u32(vi, vu);
56
57      weight_accumulator += vwacc;
58      unweight_accumulator += vuacc;
59
60    } while (--n != 0);
61
62    *output++ = weight_accumulator;
63    weight_accumulator = unweight_accumulator;
64    unweight_accumulator = 0;
65
66  } while (--rows != 0);
67}
68