xref: /aosp_15_r20/external/XNNPACK/src/f32-spmm/gen/1x1-minmax-scalar-pipelined.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-spmm/scalar-pipelined.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2019 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/math.h>
13 #include <xnnpack/spmm.h>
14 
15 
xnn_f32_spmm_minmax_ukernel_1x1__scalar_pipelined(size_t mc,size_t nc,const float * restrict input,const float * restrict weights,const int32_t * restrict widx_dmap,const uint32_t * restrict nidx_nnzmap,float * restrict output,size_t output_stride,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])16 void xnn_f32_spmm_minmax_ukernel_1x1__scalar_pipelined(
17     size_t mc,
18     size_t nc,
19     const float*restrict input,
20     const float*restrict weights,
21     const int32_t*restrict widx_dmap,
22     const uint32_t*restrict nidx_nnzmap,
23     float*restrict output,
24     size_t output_stride,
25     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
26 {
27   assert(mc != 0);
28   assert(mc % sizeof(float) == 0);
29   assert(nc != 0);
30 
31   const float vmin = params->scalar.min;
32   const float vmax = params->scalar.max;
33   size_t output_decrement = output_stride * nc - 1 * sizeof(float);
34   while XNN_LIKELY(mc >= 1 * sizeof(float)) {
35     const float*restrict w = weights;
36     const int32_t* dmap = widx_dmap;
37     const uint32_t* nnzmap = nidx_nnzmap;
38     float vw = *w++;
39     intptr_t diff = *dmap++;
40     float vi0 = input[0];
41     size_t n = nc;
42     do {
43       uint32_t nnz = *nnzmap++;
44       float vacc0 = vw;
45       vw = *w++;
46       if XNN_LIKELY(nnz != 0) {
47         do {
48           vacc0 += vi0 * vw;
49           input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff);
50 
51           diff = *dmap++;
52           vw = *w++;
53           vi0 = input[0];
54         } while (--nnz != 0);
55       }
56       float vout0 = math_min_f32(vacc0, vmax);
57       vout0 = math_max_f32(vout0, vmin);
58       output[0] = vout0;
59       output = (float*restrict) ((uintptr_t) output + output_stride);
60     } while (--n != 0);
61     output = (float*restrict) ((uintptr_t) output - output_decrement);
62     input += 1;
63     mc -= 1 * sizeof(float);
64   }
65   if XNN_UNLIKELY(mc != 0) {
66   }
67 }
68