• 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 <xnnpack/fill.h>
9 
10 
xnn_x32_fill_ukernel__scalar_float(size_t rows,size_t channels,uint32_t * output,size_t output_stride,const uint32_t * fill_value)11 void xnn_x32_fill_ukernel__scalar_float(
12     size_t rows,
13     size_t channels,
14     uint32_t* output,
15     size_t output_stride,
16     const uint32_t* fill_value)
17 {
18   assert(rows != 0);
19   assert(channels != 0);
20   assert(channels % sizeof(float) == 0);
21   assert(fill_value != NULL);
22 
23   const size_t output_increment = output_stride - channels;
24 
25   const float vfill = *((const float*) fill_value);
26   float* o = (float*) output;
27   do {
28     size_t c = channels;
29     for (; c >= 4 * sizeof(uint32_t); c -= 4 * sizeof(uint32_t)) {
30       o[0] = vfill;
31       o[1] = vfill;
32       o[2] = vfill;
33       o[3] = vfill;
34       o += 4;
35     }
36     if XNN_UNLIKELY(c != 0) {
37       do {
38         *o++ = vfill;
39         c -= sizeof(uint32_t);
40       } while (c != 0);
41     }
42     o = (void*) ((uintptr_t) o + output_increment);
43   } while (--rows != 0);
44 }
45