• 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/unpool.h>
11 
12 
xnn_x32_unpool_ukernel__neon(size_t kernel_elements,size_t channels,uint32_t fill,const uint32_t * input,const uint32_t * index,uint32_t ** output)13 void xnn_x32_unpool_ukernel__neon(
14     size_t kernel_elements,
15     size_t channels,
16     uint32_t fill,
17     const uint32_t* input,
18     const uint32_t* index,
19     uint32_t** output)
20 {
21   // Pre-initialize outputs with constant.
22   const uint32x4_t vfill = vdupq_n_u32(fill);
23   uint32_t** os = output;
24   do {
25     uint32_t* o = *os++;
26     size_t c = channels;
27     for (; c >= 4; c -= 4) {
28       vst1q_u32(o, vfill); o += 4;
29     }
30     if (c != 0) {
31       if (c & 2) {
32         vst1_u32(o, vget_low_u32(vfill)); o += 2;
33       }
34       if (c & 1) {
35         vst1q_lane_u32(o, vfill, 0);
36       }
37     }
38   } while (--kernel_elements != 0);
39 
40   // Copy indexed elements to output.
41   size_t offset = 0;
42   do {
43     const uint32_t i = *index++;
44     *((uint32_t*) ((uintptr_t) output[i] + offset)) = *input++;
45     offset += sizeof(uint32_t);
46   } while (--channels != 0);
47 }
48