1 // Auto-generated file. Do not edit!
2 // Template: src/f32-spmm/scalar.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(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(
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 (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 size_t n = nc;
39 while (n >= 1) {
40 uint32_t nnz = *nnzmap++;
41 float vacc0x0 = *w++;
42 if XNN_LIKELY(nnz != 0) {
43 do {
44 const intptr_t diff = *dmap++;
45 const float vi0 = input[0];
46 input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff);
47 const float vw0 = *w++;
48 vacc0x0 += vi0 * vw0;
49 } while (--nnz != 0);
50 }
51 float vout0x0 = math_min_f32(vacc0x0, vmax);
52 vout0x0 = math_max_f32(vout0x0, vmin);
53 output[0] = vout0x0;
54 output[0] = vout0x0;
55 output = (float*restrict) ((uintptr_t) output + output_stride);
56 n -= 1;
57 }
58 if XNN_UNLIKELY(n != 0) {
59 do {
60 uint32_t nnz = *nnzmap++;
61 float vacc0 = *w++;
62 if XNN_LIKELY(nnz != 0) {
63 do {
64 const intptr_t diff = *dmap++;
65 const float vi0 = input[0];
66 input = (const float*restrict) ((uintptr_t) input + (uintptr_t) diff);
67 const float vw = *w++;
68 vacc0 += vi0 * vw;
69 } while (--nnz != 0);
70 }
71 float vout0 = math_min_f32(vacc0, vmax);
72 vout0 = math_max_f32(vout0, vmin);
73 output[0] = vout0;
74 output = (float*restrict) ((uintptr_t) output + output_stride);
75 n -= 1;
76 } while (n != 0);
77 }
78 output = (float*restrict) ((uintptr_t) output - output_decrement);
79 input += 1;
80 mc -= 1 * sizeof(float);
81 }
82 if XNN_UNLIKELY(mc != 0) {
83 }
84 }
85