• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 <arm_neon.h>
9 
10 #include <xnnpack/fill.h>
11 
12 
xnn_x32_fill_ukernel__neon(size_t rows,size_t channels,uint32_t * output,size_t output_stride,const uint32_t * fill_value)13 void xnn_x32_fill_ukernel__neon(
14     size_t rows,
15     size_t channels,
16     uint32_t* output,
17     size_t output_stride,
18     const uint32_t* fill_value)
19 {
20   assert(rows != 0);
21   assert(channels != 0);
22   assert(channels % sizeof(uint32_t) == 0);
23   assert(fill_value != NULL);
24 
25   const size_t output_increment = output_stride - channels;
26 
27   const uint32x4_t vfill = vld1q_dup_u32(fill_value);
28   do {
29     size_t c = channels;
30     for (; c >= 16 * sizeof(uint32_t); c -= 16 * sizeof(uint32_t)) {
31       vst1q_u32(output, vfill); output += 4;
32       vst1q_u32(output, vfill); output += 4;
33       vst1q_u32(output, vfill); output += 4;
34       vst1q_u32(output, vfill); output += 4;
35     }
36     for (; c >= 4 * sizeof(uint32_t); c -= 4 * sizeof(uint32_t)) {
37       vst1q_u32(output, vfill); output += 4;
38     }
39     if XNN_UNLIKELY(c != 0) {
40       if XNN_LIKELY(c & (2 * sizeof(uint32_t))) {
41         vst1_u32(output, vget_low_u32(vfill)); output += 2;
42       }
43       if XNN_LIKELY(c & (1 * sizeof(uint32_t))) {
44         vst1q_lane_u32(output, vfill, 0); output += 1;
45       }
46     }
47     output = (void*) ((uintptr_t) output + output_increment);
48   } while (--rows != 0);
49 }
50