• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/rmax.h>
9 
10 
xnn_u8_rmax_ukernel__scalar(size_t n,const uint8_t * x,uint8_t * y)11 void xnn_u8_rmax_ukernel__scalar(
12     size_t n,
13     const uint8_t* x,
14     uint8_t* y)
15 {
16   assert(n != 0);
17 
18   uint8_t vmax0 = 0;
19   uint8_t vmax1 = 0;
20   for (; n >= 2 * sizeof(uint8_t); n -= 2 * sizeof(uint8_t)) {
21     const uint8_t vt0 = x[0];
22     const uint8_t vt1 = x[1];
23     x += 2;
24 
25     vmax0 = vt0 > vmax0 ? vt0 : vmax0;
26     vmax1 = vt1 > vmax1 ? vt1 : vmax1;
27   }
28   uint8_t vmax = vmax0 > vmax1 ? vmax0 : vmax1;
29   if (n != 0) {
30     const uint8_t vt = *x++;
31     vmax = vt > vmax ? vt : vmax;
32   }
33   *y = vmax;
34 }
35