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/unpool.h>
9 
10 
xnn_x32_unpool_ukernel__scalar(size_t kernel_elements,size_t channels,uint32_t fill,const uint32_t * input,const uint32_t * index,uint32_t ** output)11 void xnn_x32_unpool_ukernel__scalar(
12     size_t kernel_elements,
13     size_t channels,
14     uint32_t fill,
15     const uint32_t* input,
16     const uint32_t* index,
17     uint32_t** output)
18 {
19   // Pre-initialize outputs with constant.
20   uint32_t** os = output;
21   do {
22     uint32_t* o = *os++;
23     size_t c = channels;
24     do {
25       *o++ = fill;
26     } while (--c != 0);
27   } while (--kernel_elements != 0);
28 
29   // Copy indexed elements to output.
30   size_t offset = 0;
31   do {
32     const uint32_t i = *index++;
33     *((uint32_t*) ((uintptr_t) output[i] + offset)) = *input++;
34     offset += sizeof(uint32_t);
35   } while (--channels != 0);
36 }
37