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_4x__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_4x__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   const float* x3 = (const float*) ((uintptr_t) x2 + x_stride);
31   if (m != 4) {
32     x3 = x2;
33   }
34 
35   float*restrict y_f32 = (float*) y;
36 
37   do {
38     const float vx0 = *x0++;
39     const float vx1 = *x1++;
40     const float vx2 = *x2++;
41     const float vx3 = *x3++;
42 
43     y_f32[0] = vx0;
44     y_f32[1] = vx1;
45     y_f32[2] = vx2;
46     y_f32[3] = vx3;
47     y_f32 += 4;
48   } while (--k != 0);
49 }
50