• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) Facebook, Inc. and its affiliates.
2 // All rights reserved.
3 //
4 // Copyright 2019 Google LLC
5 //
6 // This source code is licensed under the BSD-style license found in the
7 // LICENSE file in the root directory of this source tree.
8 
9 #include <gtest/gtest.h>
10 
11 #include <xnnpack/common.h>
12 #include <xnnpack/isa-checks.h>
13 
14 #include <xnnpack/rmax.h>
15 #include "rmax-microkernel-tester.h"
16 
17 
18 #if XNN_ARCH_ARM || XNN_ARCH_ARM64
TEST(U8RMAX__NEON,n_lt_16)19   TEST(U8RMAX__NEON, n_lt_16) {
20     TEST_REQUIRES_ARM_NEON;
21     for (size_t n = 1; n < 16; n++) {
22       RMaxMicrokernelTester()
23         .n(n)
24         .Test(xnn_u8_rmax_ukernel__neon);
25     }
26   }
27 
TEST(U8RMAX__NEON,n_eq_16)28   TEST(U8RMAX__NEON, n_eq_16) {
29     TEST_REQUIRES_ARM_NEON;
30     RMaxMicrokernelTester()
31       .n(16)
32       .Test(xnn_u8_rmax_ukernel__neon);
33   }
34 
TEST(U8RMAX__NEON,n_div_16)35   TEST(U8RMAX__NEON, n_div_16) {
36     TEST_REQUIRES_ARM_NEON;
37     for (size_t n = 16; n < 128; n += 16) {
38       RMaxMicrokernelTester()
39         .n(n)
40         .Test(xnn_u8_rmax_ukernel__neon);
41     }
42   }
43 
TEST(U8RMAX__NEON,n_gt_16)44   TEST(U8RMAX__NEON, n_gt_16) {
45     TEST_REQUIRES_ARM_NEON;
46     for (size_t n = 16; n < 32; n++) {
47       RMaxMicrokernelTester()
48         .n(n)
49         .Test(xnn_u8_rmax_ukernel__neon);
50     }
51   }
52 #endif  // XNN_ARCH_ARM || XNN_ARCH_ARM64
53 
54 #if XNN_ARCH_X86 || XNN_ARCH_X86_64
TEST(U8RMAX__SSE2,n_lt_16)55   TEST(U8RMAX__SSE2, n_lt_16) {
56     TEST_REQUIRES_X86_SSE2;
57     for (size_t n = 1; n < 16; n++) {
58       RMaxMicrokernelTester()
59         .n(n)
60         .Test(xnn_u8_rmax_ukernel__sse2);
61     }
62   }
63 
TEST(U8RMAX__SSE2,n_eq_16)64   TEST(U8RMAX__SSE2, n_eq_16) {
65     TEST_REQUIRES_X86_SSE2;
66     RMaxMicrokernelTester()
67       .n(16)
68       .Test(xnn_u8_rmax_ukernel__sse2);
69   }
70 
TEST(U8RMAX__SSE2,n_div_16)71   TEST(U8RMAX__SSE2, n_div_16) {
72     TEST_REQUIRES_X86_SSE2;
73     for (size_t n = 16; n < 128; n += 16) {
74       RMaxMicrokernelTester()
75         .n(n)
76         .Test(xnn_u8_rmax_ukernel__sse2);
77     }
78   }
79 
TEST(U8RMAX__SSE2,n_gt_16)80   TEST(U8RMAX__SSE2, n_gt_16) {
81     TEST_REQUIRES_X86_SSE2;
82     for (size_t n = 17; n < 32; n++) {
83       RMaxMicrokernelTester()
84         .n(n)
85         .Test(xnn_u8_rmax_ukernel__sse2);
86     }
87   }
88 #endif  // XNN_ARCH_X86 || XNN_ARCH_X86_64
89 
TEST(U8RMAX__SCALAR,n_lt_2)90 TEST(U8RMAX__SCALAR, n_lt_2) {
91   for (size_t n = 1; n < 2; n++) {
92     RMaxMicrokernelTester()
93       .n(n)
94       .Test(xnn_u8_rmax_ukernel__scalar);
95   }
96 }
97 
TEST(U8RMAX__SCALAR,n_eq_2)98 TEST(U8RMAX__SCALAR, n_eq_2) {
99   RMaxMicrokernelTester()
100     .n(2)
101     .Test(xnn_u8_rmax_ukernel__scalar);
102 }
103 
TEST(U8RMAX__SCALAR,n_div_2)104 TEST(U8RMAX__SCALAR, n_div_2) {
105   for (size_t n = 2; n < 16; n += 2) {
106     RMaxMicrokernelTester()
107       .n(n)
108       .Test(xnn_u8_rmax_ukernel__scalar);
109   }
110 }
111 
TEST(U8RMAX__SCALAR,n_gt_2)112 TEST(U8RMAX__SCALAR, n_gt_2) {
113   for (size_t n = 3; n < 4; n++) {
114     RMaxMicrokernelTester()
115       .n(n)
116       .Test(xnn_u8_rmax_ukernel__scalar);
117   }
118 }
119