1 // Auto-generated file. Do not edit!
2 // Template: src/f32-prelu/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/prelu.h>
14
15
xnn_f32_prelu_ukernel__scalar_2x1(size_t rows,size_t channels,const float * restrict input,size_t input_stride,const float * restrict weights,float * restrict output,size_t output_stride)16 void xnn_f32_prelu_ukernel__scalar_2x1(
17 size_t rows,
18 size_t channels,
19 const float*restrict input,
20 size_t input_stride,
21 const float*restrict weights,
22 float*restrict output,
23 size_t output_stride)
24 {
25 assert(rows != 0);
26 assert(channels != 0);
27 assert(channels % sizeof(float) == 0);
28
29 const float* i0 = input;
30 float* o0 = output;
31 const float* i1 = (const float*) ((uintptr_t) i0 + input_stride);
32 float* o1 = (float*) ((uintptr_t) o0 + output_stride);
33 if XNN_UNPREDICTABLE(rows < 2) {
34 i1 = i0;
35 o1 = o0;
36 }
37
38 const size_t input_increment = input_stride * 2 - channels;
39 const size_t output_increment = output_stride * 2 - channels;
40
41 do {
42 const float* w = weights;
43 size_t c = channels;
44 do {
45 const float vw = *w++;
46
47 const float vi0 = *i0++;
48 const float vi1 = *i1++;
49
50 const float vacc0 = XNN_UNPREDICTABLE(vi0 < 0.0f) ? vi0 * vw : vi0;
51 const float vacc1 = XNN_UNPREDICTABLE(vi1 < 0.0f) ? vi1 * vw : vi1;
52
53 *o0++ = vacc0;
54 *o1++ = vacc1;
55
56 c -= sizeof(float);
57 } while (c != 0);
58 i0 = (const float*) ((uintptr_t) i0 + input_increment);
59 o0 = (float*) ((uintptr_t) o0 + output_increment);
60 i1 = (const float*) ((uintptr_t) i1 + input_increment);
61 o1 = (float*) ((uintptr_t) o1 + output_increment);
62 if XNN_UNPREDICTABLE(rows < 4) {
63 i1 = i0;
64 o1 = o0;
65 }
66 rows = doz(rows, 2);
67 } while (rows != 0);
68 }
69