xref: /aosp_15_r20/external/XNNPACK/src/x32-packx/x3-scalar.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Copyright 2019 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 #include <assert.h>
7 
8 #include <xnnpack/packx.h>
9 
10 
xnn_x32_packx_ukernel_3x__scalar(size_t m,size_t k,const uint32_t * restrict x,size_t x_stride,uint32_t * restrict y)11 void xnn_x32_packx_ukernel_3x__scalar(
12     size_t m,
13     size_t k,
14     const uint32_t* restrict x,
15     size_t x_stride,
16     uint32_t* restrict y)
17 {
18   assert(m != 0);
19   assert(k != 0);
20 
21   const float* x0 = (const float*) x;
22   const float* x1 = (const float*) ((uintptr_t) x0 + x_stride);
23   if (m < 2) {
24     x1 = x0;
25   }
26   const float* x2 = (const float*) ((uintptr_t) x1 + x_stride);
27   if (m <= 2) {
28     x2 = x1;
29   }
30 
31   float*restrict y_f32 = (float*) y;
32 
33   do {
34     const float vx0 = *x0++;
35     const float vx1 = *x1++;
36     const float vx2 = *x2++;
37 
38     y_f32[0] = vx0;
39     y_f32[1] = vx1;
40     y_f32[2] = vx2;
41     y_f32 += 3;
42   } while (--k != 0);
43 }
44